|
- <?php
-
- namespace Lc\CaracoleBundle\Model\Merchant;
-
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- use Lc\CaracoleBundle\Model\Address\AddressInterface;
- use Lc\CaracoleBundle\Model\Config\TaxRateInterface;
- use Lc\CaracoleBundle\Model\Credit\CreditConfigInterface;
- use Lc\CaracoleBundle\Model\Newsletter\NewsletterInterface;
- use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface;
- use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface;
- use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
- use Lc\CaracoleBundle\Model\Setting\EntitySettingTrait;
- use Lc\CaracoleBundle\Model\Setting\MerchantSettingInterface;
- use Lc\CaracoleBundle\Model\Site\NewsInterface;
- use Lc\CaracoleBundle\Model\Site\PageInterface;
- use Lc\CaracoleBundle\Model\User\GroupUserInterface;
- use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;
-
- /**
- * @ORM\MappedSuperclass()
- */
- abstract class MerchantModel extends AbstractFullEntity
- {
-
- use EntitySettingTrait;
-
- /**
- * @ORM\OneToOne(targetEntity="Lc\CaracoleBundle\Model\Credit\CreditConfigInterface", cascade={"persist", "remove"})
- * @ORM\JoinColumn(nullable=true)
- */
- protected $creditConfig;
-
- /**
- * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Config\TaxRateInterface")
- * @ORM\JoinColumn(nullable=false)
- */
- protected $taxRate;
-
- /**
- * @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\PointSale\PointSaleInterface", mappedBy="merchants")
- */
- protected $pointSales;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductFamilyInterface", mappedBy="merchant")
- */
- protected $productFamilies;
-
- /**
- * @ORM\OneToOne(targetEntity="Lc\CaracoleBundle\Model\Address\AddressInterface", inversedBy="merchant", cascade={"persist", "remove"})
- * @ORM\JoinColumn(nullable=true)
- */
- protected $address;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductCategoryInterface", mappedBy="merchant", orphanRemoval=true)
- */
- protected $productCategories;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Site\NewsInterface", mappedBy="merchant", orphanRemoval=true)
- */
- protected $news;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Site\PageInterface", mappedBy="merchant", orphanRemoval=true)
- */
- protected $pages;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Newsletter\NewsletterInterface", mappedBy="merchant")
- */
- protected $newsletters;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\User\GroupUserInterface", mappedBy="merchant")
- */
- protected $groupUsers;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Setting\MerchantSettingInterface", mappedBy="merchant", orphanRemoval=true, cascade={"persist"}, fetch="EAGER")
- */
- protected $settings;
-
-
- public function __construct()
- {
- $this->pointSales = new ArrayCollection();
- $this->productFamilies = new ArrayCollection();
- $this->productCategories = new ArrayCollection();
- $this->news = new ArrayCollection();
- $this->groupUsers = new ArrayCollection();
- $this->newsletters = new ArrayCollection();
- }
-
- public function __toString()
- {
- return $this->getTitle() ;
- }
-
- public function getCreditConfig(): ?CreditConfigInterface
- {
- return $this->creditConfig;
- }
-
- public function setCreditConfig(CreditConfigInterface $creditConfig): self
- {
- $this->creditConfig = $creditConfig;
-
- return $this;
- }
-
- public function getTaxRate(): ?TaxRateInterface
- {
- return $this->taxRate;
- }
-
- public function setTaxRate(?TaxRateInterface $taxRate): self
- {
- $this->taxRate = $taxRate;
-
- return $this;
- }
-
- /**
- * @return Collection|PointSaleInterface[]
- */
- public function getPointSales(): Collection
- {
- return $this->pointSales;
- }
-
- public function addPointSale(PointSaleInterface $pointSale): self
- {
- if (!$this->pointSales->contains($pointSale)) {
- $this->pointSales[] = $pointSale;
- $pointSale->addMerchant($this);
- }
-
- return $this;
- }
-
- public function removePointSale(PointSaleInterface $pointSale): self
- {
- if ($this->pointSales->contains($pointSale)) {
- $this->pointSales->removeElement($pointSale);
- $pointSale->removeMerchant($this);
- }
-
- return $this;
- }
-
- /**
- * @return Collection|ProductFamilyInterface[]
- */
- public function getProductFamilies(): Collection
- {
- return $this->productFamilies;
- }
-
- public function addProductFamily(ProductFamilyInterface $productFamily): self
- {
- if (!$this->productFamilies->contains($productFamily)) {
- $this->productFamilies[] = $productFamily;
- $productFamily->setMerchant($this);
- }
-
- return $this;
- }
-
- public function removeProductFamily(ProductFamilyInterface $productFamily): self
- {
- if ($this->productFamilies->contains($productFamily)) {
- $this->productFamilies->removeElement($productFamily);
- // set the owning side to null (unless already changed)
- if ($productFamily->getMerchant() === $this) {
- $productFamily->setMerchant(null);
- }
- }
-
- return $this;
- }
-
- /**
- * @return Collection|MerchantSettingInterface[]
- */
- public function getSettings(): Collection
- {
- return $this->settings;
- }
-
- public function addSetting(MerchantSettingInterface $merchantSetting): self
- {
- if (!$this->settings->contains($merchantSetting)) {
- $this->settings[] = $merchantSetting;
- $merchantSetting->setMerchant($this);
- }
-
- return $this;
- }
-
- public function removeSetting(MerchantSettingInterface $merchantSetting): self
- {
- if ($this->settings->contains($merchantSetting)) {
- $this->settings->removeElement($merchantSetting);
- // set the owning side to null (unless already changed)
- if ($merchantSetting->getMerchant() === $this) {
- $merchantSetting->setMerchant(null);
- }
- }
-
- return $this;
- }
-
- public function getAddress(): ?AddressInterface
- {
- return $this->address;
- }
-
- public function setAddress(AddressInterface $address): self
- {
- $this->address = $address;
-
- return $this;
- }
-
- /**
- * @return Collection|ProductCategoryInterface[]
- */
- public function getProductCategories(): Collection
- {
- return $this->productCategories;
- }
-
- public function addProductCategory(ProductCategoryInterface $productCategory): self
- {
- if (!$this->productCategories->contains($productCategory)) {
- $this->productCategories[] = $productCategory;
- $productCategory->setMerchant($this);
- }
-
- return $this;
- }
-
- public function removeProductCategory(ProductCategoryInterface $productCategory): self
- {
- if ($this->productCategories->contains($productCategory)) {
- $this->productCategories->removeElement($productCategory);
- // set the owning side to null (unless already changed)
- if ($productCategory->getMerchant() === $this) {
- $productCategory->setMerchant(null);
- }
- }
-
- return $this;
- }
-
- /**
- * @return Collection|NewsInterface[]
- */
- public function getNews(): Collection
- {
- return $this->news;
- }
-
- public function addNews(NewsInterface $news): self
- {
- if (!$this->news->contains($news)) {
- $this->news[] = $news;
- $news->setMerchant($this);
- }
-
- return $this;
- }
-
- public function removeNews(NewsInterface $news): self
- {
- if ($this->news->contains($news)) {
- $this->news->removeElement($news);
- // set the owning side to null (unless already changed)
- if ($news->getMerchant() === $this) {
- $news->setMerchant(null);
- }
- }
-
- return $this;
- }
-
- /**
- * @return Collection|PageInterface[]
- */
- public function getPages(): Collection
- {
- return $this->pages;
- }
-
- public function addPage(PageInterface $page): self
- {
- if (!$this->pages->contains($page)) {
- $this->pages[] = $page;
- $page->setMerchant($this);
- }
-
- return $this;
- }
-
- public function removePage(PageInterface $page): self
- {
- if ($this->pages->contains($page)) {
- $this->pages->removeElement($page);
- // set the owning side to null (unless already changed)
- if ($page->getMerchant() === $this) {
- $page->setMerchant(null);
- }
- }
-
- return $this;
- }
-
- /**
- * @return Collection|NewsletterInterface[]
- */
- public function getNewsletters(): Collection
- {
- return $this->newsletters;
- }
-
- public function addNewsletter(NewsletterInterface $newsletter): self
- {
- if (!$this->newsletters->contains($newsletter)) {
- $this->newsletters[] = $newsletter;
- $newsletter->setMerchant($this);
- }
-
- return $this;
- }
-
- public function removeNewsletter(NewsletterInterface $newsletter): self
- {
- if ($this->newsletters->contains($newsletter)) {
- $this->newsletters->removeElement($newsletter);
- // set the owning side to null (unless already changed)
- if ($newsletter->getMerchant() === $this) {
- $newsletter->setMerchant(null);
- }
- }
-
- return $this;
- }
-
- public function getNewsletter()
- {
- $newsletters = $this->getNewsletters();
-
- foreach ($newsletters as $newsletter) {
- if ($newsletter->getIsMain()) {
- return $newsletter;
- }
- }
-
- return false;
- }
-
- /**
- * @return Collection|GroupUserInterface[]
- */
- public function getGroupUsers(): Collection
- {
- return $this->groupUsers;
- }
-
- public function addGroupUser(GroupUserInterface $groupUser): self
- {
- if (!$this->groupUsers->contains($groupUser)) {
- $this->groupUsers[] = $groupUser;
- $groupUser->setMerchant($this);
- }
-
- return $this;
- }
-
- public function removeGroupUser(GroupUserInterface $groupUser): self
- {
- if ($this->groupUsers->contains($groupUser)) {
- $this->groupUsers->removeElement($groupUser);
- // set the owning side to null (unless already changed)
- if ($groupUser->getMerchant() === $this) {
- $groupUser->setMerchant(null);
- }
- }
-
- return $this;
- }
- }
|