| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- declare(strict_types=1);
- namespace App\Entity\Place;
- // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
- use ApiPlatform\Metadata\ApiResource;
- use App\Entity\Core\AbstractControl;
- use App\Entity\Core\Tagg;
- 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 RoomControl, et supprimer l'attribut discr.
- *
- * Classe ... qui ...
- */
- // #[Auditable]
- #[ApiResource(operations: [])]
- #[ORM\Entity]
- class RoomControl extends AbstractControl
- {
- #[ORM\ManyToOne(inversedBy: 'controls')]
- private ?Room $room = null;
- #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'controls', cascade: ['persist'], orphanRemoval: false)]
- #[ORM\JoinTable(name: 'tag_control')]
- #[ORM\JoinColumn(name: 'control_id')]
- #[ORM\InverseJoinColumn(name: 'tag_id')]
- protected Collection $tags;
- public function getRoom(): ?Room
- {
- return $this->room;
- }
- public function setRoom(?Room $room): self
- {
- $this->room = $room;
- return $this;
- }
- public function getTags(): Collection
- {
- return $this->tags;
- }
- public function addTag(Tagg $tag): self
- {
- if (!$this->tags->contains($tag)) {
- $this->tags[] = $tag;
- $tag->addControl($this);
- }
- return $this;
- }
- public function removeTag(Tagg $tag): self
- {
- if ($this->tags->removeElement($tag)) {
- $tag->removeControl($this);
- }
- return $this;
- }
- }
|