|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392 |
- <?php
-
- namespace Lc\ShopBundle\Model;
-
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- use Lc\ShopBundle\Context\CreditConfigInterface;
- use Lc\ShopBundle\Context\GroupUserInterface;
-
- /**
- * @ORM\MappedSuperclass()
- */
- abstract class Merchant extends AbstractDocumentEntity
- {
- /**
- * @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\CreditConfigInterface", cascade={"persist", "remove"})
- * @ORM\JoinColumn(nullable=true)
- */
- protected $creditConfig;
-
- /**
- * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\TaxRateInterface")
- * @ORM\JoinColumn(nullable=false)
- */
- protected $taxRate;
-
- /**
- * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\PointSaleInterface", mappedBy="merchants")
- */
- protected $pointSales;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\ProductFamilyInterface", mappedBy="merchant")
- */
- protected $productFamilies;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\MerchantConfigInterface", mappedBy="merchant", orphanRemoval=true, cascade={"persist"})
- */
- protected $merchantConfigs;
-
- /**
- * @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\AddressInterface", inversedBy="merchant", cascade={"persist", "remove"})
- * @ORM\JoinColumn(nullable=true)
- */
- protected $address;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\ProductCategoryInterface", mappedBy="merchant", orphanRemoval=true)
- */
- protected $productCategories;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\NewsInterface", mappedBy="merchant", orphanRemoval=true)
- */
- protected $news;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\PageInterface", mappedBy="merchant", orphanRemoval=true)
- */
- protected $pages;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\NewsletterInterface", mappedBy="merchant")
- */
- protected $newsletters;
-
- /**
- * @ORM\OneToMany(targetEntity="App\Entity\GroupUser", mappedBy="merchant")
- */
- protected $groupUsers;
-
-
- public function __construct()
- {
- $this->pointSales = new ArrayCollection();
- $this->productFamilies = new ArrayCollection();
- $this->merchantConfigs = new ArrayCollection();
- $this->productCategories = new ArrayCollection();
- $this->news = new ArrayCollection();
- $this->groupUsers = new ArrayCollection();
- $this->newsletters = new ArrayCollection();
- }
-
- public function getCreditConfig(): ?CreditConfig
- {
- return $this->creditConfig;
- }
-
- public function setCreditConfig(CreditConfigInterface $creditConfig): self
- {
- $this->creditConfig = $creditConfig;
-
- return $this;
- }
-
- public function getTaxRate(): ?TaxRate
- {
- return $this->taxRate;
- }
-
- public function setTaxRate(?TaxRate $taxRate): self
- {
- $this->taxRate = $taxRate;
-
- return $this;
- }
-
- /**
- * @return Collection|PointSale[]
- */
- public function getPointSales(): Collection
- {
- return $this->pointSales;
- }
-
- public function addPointSale(PointSale $pointSale): self
- {
- if (!$this->pointSales->contains($pointSale)) {
- $this->pointSales[] = $pointSale;
- $pointSale->addMerchant($this);
- }
-
- return $this;
- }
-
- public function removePointSale(PointSale $pointSale): self
- {
- if ($this->pointSales->contains($pointSale)) {
- $this->pointSales->removeElement($pointSale);
- $pointSale->removeMerchant($this);
- }
-
- return $this;
- }
-
- /**
- * @return Collection|ProductFamily[]
- */
- public function getProductFamilies(): Collection
- {
- return $this->productFamilies;
- }
-
- public function addProductFamily(ProductFamily $productFamily): self
- {
- if (!$this->productFamilies->contains($productFamily)) {
- $this->productFamilies[] = $productFamily;
- $productFamily->setMerchant($this);
- }
-
- return $this;
- }
-
- public function removeProductFamily(ProductFamily $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|MerchantConfig[]
- */
- public function getMerchantConfigs(): Collection
- {
- return $this->merchantConfigs;
- }
-
- public function addMerchantConfig(MerchantConfig $merchantConfig): self
- {
- if (!$this->merchantConfigs->contains($merchantConfig)) {
- $this->merchantConfigs[] = $merchantConfig;
- $merchantConfig->setMerchant($this);
- }
-
- return $this;
- }
-
- public function removeMerchantConfig(MerchantConfig $merchantConfig): self
- {
- if ($this->merchantConfigs->contains($merchantConfig)) {
- $this->merchantConfigs->removeElement($merchantConfig);
- // set the owning side to null (unless already changed)
- if ($merchantConfig->getMerchant() === $this) {
- $merchantConfig->setMerchant(null);
- }
- }
-
- return $this;
- }
-
- public function getMerchantConfig($name)
- {
- if($this->getMerchantConfigs()) {
- foreach($this->getMerchantConfigs() as $merchantConfig) {
- if($merchantConfig->getName() == $name) {
- return $merchantConfig->getValue() ;
- }
- }
- }
-
- return false ;
- }
-
- public function getAddress(): ?Address
- {
- return $this->address;
- }
-
- public function setAddress(Address $address): self
- {
- $this->address = $address;
-
- return $this;
- }
-
- /**
- * @return Collection|ProductCategory[]
- */
- public function getProductCategories(): Collection
- {
- return $this->productCategories;
- }
-
- public function addProductCategory(ProductCategory $productCategory): self
- {
- if (!$this->productCategories->contains($productCategory)) {
- $this->productCategories[] = $productCategory;
- $productCategory->setMerchant($this);
- }
-
- return $this;
- }
-
- public function removeProductCategory(ProductCategory $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|News[]
- */
- public function getNews(): Collection
- {
- return $this->news;
- }
-
- public function addNews(News $news): self
- {
- if (!$this->news->contains($news)) {
- $this->news[] = $news;
- $news->setMerchant($this);
- }
-
- return $this;
- }
-
- public function removeNews(News $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|Page[]
- */
- public function getPages(): Collection
- {
- return $this->pages;
- }
-
- public function addPage(Page $page): self
- {
- if (!$this->pages->contains($page)) {
- $this->pages[] = $page;
- $page->setMerchant($this);
- }
-
- return $this;
- }
-
- public function removePage(Page $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|Newsletter[]
- */
- public function getNewsletters(): Collection
- {
- return $this->newsletters;
- }
-
- public function addNewsletter(Newsletter $newsletter): self
- {
- if (!$this->newsletters->contains($newsletter)) {
- $this->newsletters[] = $newsletter;
- $newsletter->setMerchant($this);
- }
-
- return $this;
- }
-
- public function removeNewsletter(News $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|GroupUser[]
- */
- public function getGroupUsers(): Collection
- {
- return $this->groupUsers;
- }
-
- public function addGroupUser(GroupUser $groupUser): self
- {
- if (!$this->groupUsers->contains($groupUser)) {
- $this->groupUsers[] = $groupUser;
- $groupUser->setMerchant($this);
- }
-
- return $this;
- }
-
- public function removeGroupUser(GroupUser $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;
- }
- }
|