| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?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 App\Entity\Education\EducationStudent;
- 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\Entity]
- class Mail extends AbstractMessage
- {
- #[ORM\ManyToOne(inversedBy: 'mails')]
- #[ORM\JoinColumn(nullable: true)]
- private ?Access $author = null;
- /** @var Collection<int, Tagg> */
- #[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 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;
- }
- }
|