src/Entity/SousThematique.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SousThematiqueRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=SousThematiqueRepository::class)
  9.  */
  10. class SousThematique
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column
  16.      */
  17.     private ?int $id null;
  18.     /**
  19.      * @ORM\Column(length=255, unique=true)
  20.      */
  21.     private ?string $name null;
  22.     /**
  23.      * @ORM\Column(length=255, unique=true)
  24.      */
  25.     private ?string $slug null;
  26.     public function getSlug(): ?string
  27.     {
  28.         return $this->slug;
  29.     }
  30.     public function setSlug(?string $slug): void
  31.     {
  32.         $this->slug $slug;
  33.     }
  34.     /**
  35.      * @ORM\ManyToMany(targetEntity=Thematique::class, mappedBy="sousThematique")
  36.      */
  37.     private Collection $thematiques;
  38.     /**
  39.      * @ORM\ManyToMany(targetEntity=Blog::class, mappedBy="sous_thematique")
  40.      */
  41.     private Collection $blogs;
  42.     public function __construct()
  43.     {
  44.         $this->thematiques = new ArrayCollection();
  45.         $this->blogs = new ArrayCollection();
  46.     }
  47.     public function getId(): ?int
  48.     {
  49.         return $this->id;
  50.     }
  51.     public function getName(): ?string
  52.     {
  53.         return $this->name;
  54.     }
  55.     public function setName(string $name): self
  56.     {
  57.         $this->name $name;
  58.         return $this;
  59.     }
  60.     /**
  61.      * @return Collection<int, Thematique>
  62.      */
  63.     public function getThematiques(): Collection
  64.     {
  65.         return $this->thematiques;
  66.     }
  67.     public function addThematique(Thematique $thematique): self
  68.     {
  69.         if (!$this->thematiques->contains($thematique)) {
  70.             $this->thematiques->add($thematique);
  71.             $thematique->addSousThematique($this);
  72.         }
  73.         return $this;
  74.     }
  75.     public function removeThematique(Thematique $thematique): self
  76.     {
  77.         if ($this->thematiques->removeElement($thematique)) {
  78.             $thematique->removeSousThematique($this);
  79.         }
  80.         return $this;
  81.     }
  82.     /**
  83.      * @return Collection<int, Blog>
  84.      */
  85.     public function getBlogs(): Collection
  86.     {
  87.         return $this->blogs;
  88.     }
  89.     public function addBlog(Blog $blog): self
  90.     {
  91.         if (!$this->blogs->contains($blog)) {
  92.             $this->blogs->add($blog);
  93.             $blog->addSousThematique($this);
  94.         }
  95.         return $this;
  96.     }
  97.     public function removeBlog(Blog $blog): self
  98.     {
  99.         if ($this->blogs->removeElement($blog)) {
  100.             $blog->removeSousThematique($this);
  101.         }
  102.         return $this;
  103.     }
  104. }