src/Entity/Tag.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\TagRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassTagRepository::class)]
  8. class Tag
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\Column(length255)]
  15.     private ?string $libelle null;
  16.     #[ORM\ManyToMany(targetEntityPublication::class, mappedBy'tag')]
  17.     private Collection $publications;
  18.     public function __construct()
  19.     {
  20.         $this->publications = new ArrayCollection();
  21.     }
  22.     public function getId(): ?int
  23.     {
  24.         return $this->id;
  25.     }
  26.     public function getLibelle(): ?string
  27.     {
  28.         return $this->libelle;
  29.     }
  30.     public function setLibelle(string $libelle): static
  31.     {
  32.         $this->libelle $libelle;
  33.         return $this;
  34.     }
  35.     /**
  36.      * @return Collection<int, Publication>
  37.      */
  38.     public function getPublications(): Collection
  39.     {
  40.         return $this->publications;
  41.     }
  42.     public function addPublication(Publication $publication): static
  43.     {
  44.         if (!$this->publications->contains($publication)) {
  45.             $this->publications->add($publication);
  46.             $publication->addTag($this);
  47.         }
  48.         return $this;
  49.     }
  50.     public function removePublication(Publication $publication): static
  51.     {
  52.         if ($this->publications->removeElement($publication)) {
  53.             $publication->removeTag($this);
  54.         }
  55.         return $this;
  56.     }
  57.     
  58. }