src/Entity/StakeholderTag.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\StakeholderTagRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. #[ORM\Entity(repositoryClassStakeholderTagRepository::class)]
  9. #[ORM\Table(name'stakeholder_tag')]
  10. #[ORM\UniqueConstraint(
  11.     name'unique_slug_firm',
  12.     columns: ["slug""accounting_firm_id"]
  13. )]
  14. class StakeholderTag
  15. {
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue]
  18.     #[ORM\Column(type'integer')]
  19.     private $id;
  20.     #[ORM\Column(type'string'length255)]
  21.     private $name;
  22.     #[Gedmo\Slug(fields: ['name'], updatabletrue)]
  23.     #[ORM\Column(type'string'length255)]
  24.     private $slug;
  25.     #[ORM\ManyToOne(targetEntityAccountingFirm::class, inversedBy'stakeholderTags')]
  26.     #[ORM\JoinColumn(nullablefalse)]
  27.     private $accountingFirm;
  28.     #[ORM\ManyToMany(targetEntityStakeholder::class, mappedBy'stakeholderTags')]
  29.     private $stakeholders;
  30.     public function __construct()
  31.     {
  32.         $this->stakeholders = new ArrayCollection();
  33.     }
  34.     public function getId(): ?int
  35.     {
  36.         return $this->id;
  37.     }
  38.     public function getName(): ?string
  39.     {
  40.         return $this->name;
  41.     }
  42.     public function setName(string $name): self
  43.     {
  44.         $this->name $name;
  45.         return $this;
  46.     }
  47.     public function getSlug(): ?string
  48.     {
  49.         return $this->slug;
  50.     }
  51.     public function setSlug(string $slug): self
  52.     {
  53.         $this->slug $slug;
  54.         return $this;
  55.     }
  56.     public function getAccountingFirm(): ?AccountingFirm
  57.     {
  58.         return $this->accountingFirm;
  59.     }
  60.     public function setAccountingFirm(?AccountingFirm $accountingFirm): self
  61.     {
  62.         $this->accountingFirm $accountingFirm;
  63.         return $this;
  64.     }
  65.     /**
  66.      * @return Collection<int, Stakeholder>
  67.      */
  68.     public function getStakeholders(): Collection
  69.     {
  70.         return $this->stakeholders;
  71.     }
  72.     public function addStakeholder(Stakeholder $stakeholder): self
  73.     {
  74.         if (!$this->stakeholders->contains($stakeholder)) {
  75.             $this->stakeholders[] = $stakeholder;
  76.             $stakeholder->addStakeholderTag($this);
  77.         }
  78.         return $this;
  79.     }
  80.     public function removeStakeholder(Stakeholder $stakeholder): self
  81.     {
  82.         if ($this->stakeholders->removeElement($stakeholder)) {
  83.             $stakeholder->removeStakeholderTag($this);
  84.         }
  85.         return $this;
  86.     }
  87. }