|
- <?php
-
- namespace Lc\ShopBundle\Model;
-
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- use Orkestra\EaSortable\SortableTrait;
-
- /**
- * @ORM\MappedSuperclass()
- */
- abstract class ProductCategory extends AbstractDocumentEntity
- {
-
-
- /**
- * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\ProductCategoryInterface", inversedBy="productCategories")
- */
- protected $productCategory;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\ProductCategoryInterface", mappedBy="productCategory")
- */
- protected $productCategories;
-
- public function __toString()
- {
- // TODO: Implement __toString() method.
- return $this->getTitle();
- }
-
- public function __construct()
- {
- $this->productCategories = new ArrayCollection();
- }
-
- public function getProductCategory(): ?self
- {
- return $this->productCategory;
- }
-
- public function setProductCategory(?self $productCategory): self
- {
- $this->productCategory = $productCategory;
-
- return $this;
- }
-
- /**
- * @return Collection|self[]
- */
- public function getProductCategories(): Collection
- {
- return $this->productCategories;
- }
-
- public function addProductCategory(self $productCategory): self
- {
- if (!$this->productCategories->contains($productCategory)) {
- $this->productCategories[] = $productCategory;
- $productCategory->setProductCategory($this);
- }
-
- return $this;
- }
-
- public function removeProductCategory(self $productCategory): self
- {
- if ($this->productCategories->contains($productCategory)) {
- $this->productCategories->removeElement($productCategory);
- // set the owning side to null (unless already changed)
- if ($productCategory->getProductCategory() === $this) {
- $productCategory->setProductCategory(null);
- }
- }
-
- return $this;
- }
- }
|