You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

117 lines
3.3KB

  1. <?php
  2. namespace Lc\ShopBundle\Model;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7. * @ORM\MappedSuperclass()
  8. */
  9. class Section extends AbstractDocumentEntity
  10. {
  11. /**
  12. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface")
  13. * @ORM\JoinColumn(nullable=false)
  14. */
  15. protected $merchant;
  16. /**
  17. * @ORM\Column(type="string", length=32)
  18. */
  19. protected $cycle;
  20. const SECTION_CYCLE_DAY = 'day' ;
  21. const SECTION_CYCLE_WEEK = 'week' ;
  22. const SECTION_CYCLE_MONTH = 'month' ;
  23. const SECTION_CYCLE_YEAR = 'year' ;
  24. /**
  25. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\ProductFamilyInterface", mappedBy="sections")
  26. */
  27. protected $productFamilies;
  28. /**
  29. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", mappedBy="section")
  30. */
  31. protected $orderShops;
  32. public function __construct()
  33. {
  34. $this->productFamilies = new ArrayCollection();
  35. $this->orderShops = new ArrayCollection();
  36. }
  37. public function getCycle(): ?string
  38. {
  39. return $this->cycle;
  40. }
  41. public function setCycle(string $cycle): self
  42. {
  43. $this->cycle = $cycle;
  44. return $this;
  45. }
  46. /**
  47. * @return Collection|ProductFamily[]
  48. */
  49. public function getProductFamilies(): Collection
  50. {
  51. return $this->productFamilies;
  52. }
  53. public function addProductFamily(ProductFamily $productFamily): self
  54. {
  55. if (!$this->productFamilies->contains($productFamily)) {
  56. $this->productFamilies[] = $productFamily;
  57. $productFamily->addSection($this);
  58. }
  59. return $this;
  60. }
  61. public function removeProductFamily(ProductFamily $productFamily): self
  62. {
  63. if ($this->productFamilies->contains($productFamily)) {
  64. $this->productFamilies->removeElement($productFamily);
  65. $productFamily->removeSection($this);
  66. }
  67. return $this;
  68. }
  69. /**
  70. * @return Collection|OrderShop[]
  71. */
  72. public function getOrderShops(): Collection
  73. {
  74. return $this->orderShops;
  75. }
  76. public function addOrderShop(OrderShop $orderShop): self
  77. {
  78. if (!$this->orderShops->contains($orderShop)) {
  79. $this->orderShops[] = $orderShop;
  80. $orderShop->setSection($this);
  81. }
  82. return $this;
  83. }
  84. public function removeOrderShop(OrderShop $orderShop): self
  85. {
  86. if ($this->orderShops->contains($orderShop)) {
  87. $this->orderShops->removeElement($orderShop);
  88. // set the owning side to null (unless already changed)
  89. if ($orderShop->getSection() === $this) {
  90. $orderShop->setSection(null);
  91. }
  92. }
  93. return $this;
  94. }
  95. }