src/Entity/StakeholderCategory.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\StakeholderCategoryRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassStakeholderCategoryRepository::class)]
  8. class StakeholderCategory
  9. {
  10.     const CUSTOMER_SLUG "customer";
  11.     const COLLABORATOR_SLUG "collaborator";
  12.     const PARTNER_SLUG "partner";
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column(type'integer')]
  16.     private $id;
  17.     #[ORM\Column(type'string'length255)]
  18.     private $name;
  19.     #[ORM\Column(type'string'length255)]
  20.     private $slug;
  21.     #[ORM\OneToMany(mappedBy'stakeholderCategory'targetEntityStakeholder::class, orphanRemovaltrue)]
  22.     private $stakeholders;
  23.     public function __construct()
  24.     {
  25.         $this->stakeholders = new ArrayCollection();
  26.     }
  27.     public function getId(): ?int
  28.     {
  29.         return $this->id;
  30.     }
  31.     public function getName(): ?string
  32.     {
  33.         return $this->name;
  34.     }
  35.     public function setName(string $name): self
  36.     {
  37.         $this->name $name;
  38.         return $this;
  39.     }
  40.     public function getSlug(): ?string
  41.     {
  42.         return $this->slug;
  43.     }
  44.     public function setSlug(string $slug): self
  45.     {
  46.         $this->slug $slug;
  47.         return $this;
  48.     }
  49.     /**
  50.      * @return Collection<int, Stakeholder>
  51.      */
  52.     public function getStakeholders(): Collection
  53.     {
  54.         return $this->stakeholders;
  55.     }
  56.     public function addStakeholder(Stakeholder $stakeholder): self
  57.     {
  58.         if (!$this->stakeholders->contains($stakeholder)) {
  59.             $this->stakeholders[] = $stakeholder;
  60.             $stakeholder->setStakeholderCategory($this);
  61.         }
  62.         return $this;
  63.     }
  64.     public function removeStakeholder(Stakeholder $stakeholder): self
  65.     {
  66.         if ($this->stakeholders->removeElement($stakeholder)) {
  67.             // set the owning side to null (unless already changed)
  68.             if ($stakeholder->getStakeholderCategory() === $this) {
  69.                 $stakeholder->setStakeholderCategory(null);
  70.             }
  71.         }
  72.         return $this;
  73.     }
  74. }