| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- declare(strict_types=1);
- namespace App\Entity\Place;
- use App\Entity\Core\AbstractControl;
- // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
- use App\Entity\Core\Tagg;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- /**
- * @todo : A la suite de la migration, il faut supprimer le nom de la table pour avoir une table PlaceControl, et supprimer l'attribut discr.
- * @todo : migration table tag_control
- * Classe ... qui ...
- */
- // #[Auditable]
- #[ORM\Entity]
- #[ORM\Table(name: 'Control')]
- class PlaceControl extends AbstractControl
- {
- #[ORM\Column(length: 12, nullable: false)]
- protected string $discr = 'place';
- #[ORM\ManyToOne(inversedBy: 'controls')]
- protected AbstractPlace $place;
- #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'placeControls', cascade: ['persist'])]
- #[ORM\JoinTable(name: 'tag_control')]
- #[ORM\JoinColumn(name: 'control_id', referencedColumnName: 'id')]
- #[ORM\InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id')]
- protected Collection $tags;
- public function __construct()
- {
- $this->tags = new ArrayCollection();
- parent::__construct();
- }
- public function getDiscr(): ?string
- {
- return $this->discr;
- }
- public function setDiscr(string $discr): self
- {
- $this->discr = $discr;
- return $this;
- }
- public function getPlace(): ?AbstractPlace
- {
- return $this->place;
- }
- public function setPlace(?AbstractPlace $place): self
- {
- $this->place = $place;
- return $this;
- }
- /**
- * @return Collection<int, Tagg>
- */
- public function getTags(): Collection
- {
- return $this->tags;
- }
- public function addTag(Tagg $tag): self
- {
- if (!$this->tags->contains($tag)) {
- $this->tags[] = $tag;
- }
- return $this;
- }
- public function removeTag(Tagg $tag): self
- {
- $this->tags->removeElement($tag);
- return $this;
- }
- }
|