src/Entity/Keywords.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\KeywordsRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. /**
  9.  * @ORM\Entity(repositoryClass=KeywordsRepository::class)
  10.  */
  11. class Keywords
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @Assert\NotBlank
  21.      * @ORM\Column(type="string", length=255)
  22.      */
  23.     private string $keyword;
  24.     /**
  25.      * @ORM\Column(type="datetime")
  26.      */
  27.     private ?\DateTime $createdAt;
  28.     /**
  29.      * @ORM\ManyToMany(targetEntity="App\Entity\News", mappedBy="listekeywords")
  30.      */
  31.     private $mentionsNews;
  32.     /**
  33.      * @ORM\ManyToMany(targetEntity="App\Entity\Tuto", mappedBy="listekeywords")
  34.      */
  35.     private $mentionsTutos;
  36.     /**
  37.      * @ORM\ManyToMany(targetEntity="App\Entity\Jurisprudence", mappedBy="listekeywords")
  38.      */
  39.     private $mentionsJp;
  40.     public function __construct()
  41.     {
  42.         $this->createdAt = new \DateTime();
  43.         $this->mentionsNews = new ArrayCollection();
  44.         $this->mentionsTutos = new ArrayCollection();
  45.         $this->mentionsJp = new ArrayCollection();
  46.     }
  47.     public function getId(): ?int
  48.     {
  49.         return $this->id;
  50.     }
  51.     public function getKeyword(): ?string
  52.     {
  53.         return $this->keyword;
  54.     }
  55.     public function setKeyword(string $keyword): self
  56.     {
  57.         $this->keyword $keyword;
  58.         return $this;
  59.     }
  60.     public function getCreatedAt(): ?\DateTimeInterface
  61.     {
  62.         return $this->createdAt;
  63.     }
  64.     public function setCreatedAt(?\DateTimeInterface $createdAt): self
  65.     {
  66.         $this->createdAt $createdAt;
  67.         return $this;
  68.     }
  69.     //MANY TO MANY NEWS -> KEYWORDS
  70.     public function getMentionsNews(): Collection
  71.     {
  72.         return $this->mentionsNews;
  73.     }
  74.     public function addMentionNews(News $news): self
  75.     {
  76.         if (!$this->mentionsNews->contains($news)) {
  77.             $this->mentionsNews[] = $news;
  78.             $news->addListekeywords($this);
  79.         }
  80.         return $this;
  81.     }
  82.     public function removeMentionNews(News $news): self
  83.     {
  84.         if ($this->mentionsNews->removeElement($news)) {
  85.             $news->removeListekeywords($this);
  86.         }
  87.         return $this;
  88.     }
  89.     //MANY TO MANY TUTOS -> KEYWORDS
  90.     public function getMentionsTutos(): Collection
  91.     {
  92.         return $this->mentionsTutos;
  93.     }
  94.     public function addMentionTuto(Tuto $tuto): self
  95.     {
  96.         if (!$this->mentionsTutos->contains($tuto)) {
  97.             $this->mentionsTutos[] = $tuto;
  98.             $tuto->addListekeywords($this);
  99.         }
  100.         return $this;
  101.     }
  102.     public function removeMentionTuto(Tuto $tuto): self
  103.     {
  104.         if ($this->mentionsTutos->removeElement($tuto)) {
  105.             $tuto->removeListekeywords($this);
  106.         }
  107.         return $this;
  108.     }
  109.     //MANY TO MANY JPs -> KEYWORDS
  110.     public function getMentionsJp(): Collection
  111.     {
  112.         return $this->mentionsJp;
  113.     }
  114.     public function addMentionJp(Jurisprudence $jurisprudence): self
  115.     {
  116.         if (!$this->mentionsJp->contains($jurisprudence)) {
  117.             $this->mentionsJp[] = $jurisprudence;
  118.             $jurisprudence->addListekeywords($this);
  119.         }
  120.         return $this;
  121.     }
  122.     public function removeMentionJp(Jurisprudence $jurisprudence): self
  123.     {
  124.         if ($this->mentionsJp->removeElement($jurisprudence)) {
  125.             $jurisprudence->removeListekeywords($this);
  126.         }
  127.         return $this;
  128.     }
  129. }