Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

81 Zeilen
2.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. use Orkestra\EaSortable\SortableTrait;
  7. /**
  8. * @ORM\MappedSuperclass()
  9. */
  10. abstract class ProductCategory extends AbstractDocumentEntity
  11. {
  12. /**
  13. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\ProductCategoryInterface", inversedBy="productCategories")
  14. */
  15. protected $productCategory;
  16. /**
  17. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\ProductCategoryInterface", mappedBy="productCategory")
  18. */
  19. protected $productCategories;
  20. public function __toString()
  21. {
  22. // TODO: Implement __toString() method.
  23. return $this->getTitle();
  24. }
  25. public function __construct()
  26. {
  27. $this->productCategories = new ArrayCollection();
  28. }
  29. public function getProductCategory(): ?self
  30. {
  31. return $this->productCategory;
  32. }
  33. public function setProductCategory(?self $productCategory): self
  34. {
  35. $this->productCategory = $productCategory;
  36. return $this;
  37. }
  38. /**
  39. * @return Collection|self[]
  40. */
  41. public function getProductCategories(): Collection
  42. {
  43. return $this->productCategories;
  44. }
  45. public function addProductCategory(self $productCategory): self
  46. {
  47. if (!$this->productCategories->contains($productCategory)) {
  48. $this->productCategories[] = $productCategory;
  49. $productCategory->setProductCategory($this);
  50. }
  51. return $this;
  52. }
  53. public function removeProductCategory(self $productCategory): self
  54. {
  55. if ($this->productCategories->contains($productCategory)) {
  56. $this->productCategories->removeElement($productCategory);
  57. // set the owning side to null (unless already changed)
  58. if ($productCategory->getProductCategory() === $this) {
  59. $productCategory->setProductCategory(null);
  60. }
  61. }
  62. return $this;
  63. }
  64. }