src/Entity/PointCategory.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PointCategoryRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use JMS\Serializer\Annotation\Groups;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. /**
  10. * @ORM\Entity(repositoryClass=PointCategoryRepository::class)
  11. * @ORM\Table(name="point_category")
  12. */
  13. class PointCategory
  14. {
  15. /**
  16. * @ORM\Id
  17. * @ORM\GeneratedValue
  18. * @ORM\Column(type="integer")
  19. */
  20. private $id;
  21. /**
  22. * @Assert\Valid()
  23. * @ORM\OneToMany(targetEntity=PointCategoryItem::class, mappedBy="pointCategory", orphanRemoval=true, cascade={"persist","remove"})
  24. *
  25. * @Groups({ "pointCategory" })
  26. */
  27. private Collection $pointCategoryItems;
  28. /**
  29. * @ORM\Column(type="boolean", nullable=true)
  30. *
  31. * @Groups({ "pointCategory" })
  32. */
  33. private ?bool $canBeReplacedByParent = false;
  34. public function __construct()
  35. {
  36. $this->pointCategoryItems = new ArrayCollection();
  37. }
  38. public function getId(): ?int
  39. {
  40. return $this->id;
  41. }
  42. /**
  43. * @return Collection<int, PointCategoryItem>
  44. */
  45. public function getPointCategoryItems(): Collection
  46. {
  47. return $this->pointCategoryItems;
  48. }
  49. public function addPointCategoryItem(PointCategoryItem $pointCategoryItem): self
  50. {
  51. if (!$this->pointCategoryItems->contains($pointCategoryItem)) {
  52. $this->pointCategoryItems[] = $pointCategoryItem;
  53. $pointCategoryItem->setPointCategory($this);
  54. }
  55. return $this;
  56. }
  57. public function removePointCategoryItem(PointCategoryItem $pointCategoryItem): self
  58. {
  59. if ($this->pointCategoryItems->removeElement($pointCategoryItem)) {
  60. // set the owning side to null (unless already changed)
  61. if ($pointCategoryItem->getPointCategory() === $this) {
  62. $pointCategoryItem->setPointCategory(null);
  63. }
  64. }
  65. return $this;
  66. }
  67. public function isCanBeReplacedByParent(): ?bool
  68. {
  69. return $this->canBeReplacedByParent;
  70. }
  71. public function setCanBeReplacedByParent(?bool $CanBeReplacedByParent): self
  72. {
  73. $this->canBeReplacedByParent = $CanBeReplacedByParent;
  74. return $this;
  75. }
  76. }