| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- declare(strict_types=1);
- namespace App\Entity\Message;
- use ApiPlatform\Metadata\ApiResource;
- use App\Entity\Access\Access;
- use App\Entity\Core\Tagg;
- // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- use Ramsey\Uuid\Uuid;
- /**
- * @todo : A la suite de la migration, il faut supprimer le nom de la table pour avoir une table Mail, et supprimer l'attribut discr.
- * @todo : migration table tag_message
- *
- * Classe ... qui ...
- */
- #[ApiResource(operations: [])]
- // #[Auditable]
- #[ORM\Table(name: 'Message')]
- #[ORM\Entity]
- class Mail extends AbstractMessage
- {
- #[ORM\Column(length: 255, nullable: false)]
- protected string $discr = 'mail';
- #[ORM\ManyToOne(inversedBy: 'mails')]
- #[ORM\JoinColumn(nullable: true)]
- private Access $author;
- #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'mails', cascade: ['persist'])]
- #[ORM\JoinTable(name: 'tag_message')]
- #[ORM\JoinColumn(name: 'message_id', referencedColumnName: 'id')]
- #[ORM\InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id')]
- protected Collection $tags;
- public function __construct()
- {
- $this->uuid = Uuid::uuid4();
- $this->files = new ArrayCollection();
- $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 getAuthor(): ?Access
- {
- return $this->author;
- }
- public function setAuthor(?Access $author): self
- {
- $this->author = $author;
- 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;
- }
- }
|