src/Entity/Topic.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. #[ORM\Entity(repositoryClass\App\Repository\TopicRepository::class)]
  7. class Topic implements \Stringable
  8. {
  9.     #[ORM\Id]
  10.     #[ORM\GeneratedValue]
  11.     #[ORM\Column(type'integer')]
  12.     private int $id;
  13.     #[ORM\Column(type'string'length255nullabletrue)]
  14.     private ?string $kindnull;
  15.     #[ORM\Column(type'string'length255nullabletrue)]
  16.     private ?string $display_namenull;
  17.     #[ORM\ManyToMany(targetEntity\App\Entity\Post::class, mappedBy'topics')]
  18.     private mixed $posts;
  19.     #[ORM\ManyToMany(targetEntity\App\Entity\User::class, mappedBy'thematiques')]
  20.     private mixed $users;
  21.     #[ORM\ManyToMany(targetEntityRssArticle::class, mappedBy'thematiques')]
  22.     private mixed $rssArticles;
  23.     #[ORM\ManyToMany(targetEntityRssEvent::class, mappedBy'thematiques')]
  24.     private mixed $rssEvents;
  25.     public function __construct()
  26.     {
  27.         $this->posts = new ArrayCollection();
  28.         $this->users = new ArrayCollection();
  29.         $this->rssArticles = new ArrayCollection();
  30.         $this->rssEvents = new ArrayCollection();
  31.     }
  32.     public function getId(): ?int
  33.     {
  34.         return $this->id;
  35.     }
  36.     public function getKind(): ?string
  37.     {
  38.         return $this->kind;
  39.     }
  40.     public function setKind(?string $kind): self
  41.     {
  42.         $this->kind $kind;
  43.         return $this;
  44.     }
  45.     public function getDisplayName(): ?string
  46.     {
  47.         return $this->display_name;
  48.     }
  49.     public function setDisplayName(?string $display_name): self
  50.     {
  51.         $this->display_name $display_name;
  52.         return $this;
  53.     }
  54.     /**
  55.      * @return Collection|Post[]
  56.      */
  57.     public function getPosts(): Collection
  58.     {
  59.         return $this->posts;
  60.     }
  61.     public function addPost(Post $post): self
  62.     {
  63.         if (!$this->posts->contains($post)) {
  64.             $this->posts[] = $post;
  65.             $post->addTopic($this);
  66.         }
  67.         return $this;
  68.     }
  69.     public function removePost(Post $post): self
  70.     {
  71.         if ($this->posts->contains($post)) {
  72.             $this->posts->removeElement($post);
  73.             $post->removeTopic($this);
  74.         }
  75.         return $this;
  76.     }
  77.     public function __toString(): string
  78.     {
  79.         return (string) $this->display_name;
  80.     }
  81.     /**
  82.      * @return Collection|User[]
  83.      */
  84.     public function getUsers(): Collection
  85.     {
  86.         return $this->users;
  87.     }
  88.     public function addUser(User $user): self
  89.     {
  90.         if (!$this->users->contains($user)) {
  91.             $this->users[] = $user;
  92.             $user->addThematique($this);
  93.         }
  94.         return $this;
  95.     }
  96.     public function removeUser(User $user): self
  97.     {
  98.         if ($this->users->contains($user)) {
  99.             $this->users->removeElement($user);
  100.             $user->removeThematique($this);
  101.         }
  102.         return $this;
  103.     }
  104.     /**
  105.      * @return Collection|RssArticle[]
  106.      */
  107.     public function getRssArticles(): Collection
  108.     {
  109.         return $this->rssArticles;
  110.     }
  111.     public function addRssArticle(RssArticle $rssArticle): self
  112.     {
  113.         if (!$this->rssArticles->contains($rssArticle)) {
  114.             $this->rssArticles[] = $rssArticle;
  115.             $rssArticle->addThematique($this);
  116.         }
  117.         return $this;
  118.     }
  119.     public function removeRssArticle(RssArticle $rssArticle): self
  120.     {
  121.         if ($this->rssArticles->contains($rssArticle)) {
  122.             $this->rssArticles->removeElement($rssArticle);
  123.             $rssArticle->removeThematique($this);
  124.         }
  125.         return $this;
  126.     }
  127.     /**
  128.      * @return Collection|RssEvent[]
  129.      */
  130.     public function getRssEvents(): Collection
  131.     {
  132.         return $this->rssEvents;
  133.     }
  134.     public function addRssEvent(RssEvent $rssEvent): self
  135.     {
  136.         if (!$this->rssEvents->contains($rssEvent)) {
  137.             $this->rssEvents[] = $rssEvent;
  138.             $rssEvent->addThematique($this);
  139.         }
  140.         return $this;
  141.     }
  142.     public function removeRssEvent(RssEvent $rssEvent): self
  143.     {
  144.         if ($this->rssEvents->contains($rssEvent)) {
  145.             $this->rssEvents->removeElement($rssEvent);
  146.             $rssEvent->removeThematique($this);
  147.         }
  148.         return $this;
  149.     }
  150. }