<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: \App\Repository\TopicRepository::class)]
class Topic implements \Stringable
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private int $id;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $kind= null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $display_name= null;
#[ORM\ManyToMany(targetEntity: \App\Entity\Post::class, mappedBy: 'topics')]
private mixed $posts;
#[ORM\ManyToMany(targetEntity: \App\Entity\User::class, mappedBy: 'thematiques')]
private mixed $users;
#[ORM\ManyToMany(targetEntity: RssArticle::class, mappedBy: 'thematiques')]
private mixed $rssArticles;
#[ORM\ManyToMany(targetEntity: RssEvent::class, mappedBy: 'thematiques')]
private mixed $rssEvents;
public function __construct()
{
$this->posts = new ArrayCollection();
$this->users = new ArrayCollection();
$this->rssArticles = new ArrayCollection();
$this->rssEvents = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getKind(): ?string
{
return $this->kind;
}
public function setKind(?string $kind): self
{
$this->kind = $kind;
return $this;
}
public function getDisplayName(): ?string
{
return $this->display_name;
}
public function setDisplayName(?string $display_name): self
{
$this->display_name = $display_name;
return $this;
}
/**
* @return Collection|Post[]
*/
public function getPosts(): Collection
{
return $this->posts;
}
public function addPost(Post $post): self
{
if (!$this->posts->contains($post)) {
$this->posts[] = $post;
$post->addTopic($this);
}
return $this;
}
public function removePost(Post $post): self
{
if ($this->posts->contains($post)) {
$this->posts->removeElement($post);
$post->removeTopic($this);
}
return $this;
}
public function __toString(): string
{
return (string) $this->display_name;
}
/**
* @return Collection|User[]
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$this->users[] = $user;
$user->addThematique($this);
}
return $this;
}
public function removeUser(User $user): self
{
if ($this->users->contains($user)) {
$this->users->removeElement($user);
$user->removeThematique($this);
}
return $this;
}
/**
* @return Collection|RssArticle[]
*/
public function getRssArticles(): Collection
{
return $this->rssArticles;
}
public function addRssArticle(RssArticle $rssArticle): self
{
if (!$this->rssArticles->contains($rssArticle)) {
$this->rssArticles[] = $rssArticle;
$rssArticle->addThematique($this);
}
return $this;
}
public function removeRssArticle(RssArticle $rssArticle): self
{
if ($this->rssArticles->contains($rssArticle)) {
$this->rssArticles->removeElement($rssArticle);
$rssArticle->removeThematique($this);
}
return $this;
}
/**
* @return Collection|RssEvent[]
*/
public function getRssEvents(): Collection
{
return $this->rssEvents;
}
public function addRssEvent(RssEvent $rssEvent): self
{
if (!$this->rssEvents->contains($rssEvent)) {
$this->rssEvents[] = $rssEvent;
$rssEvent->addThematique($this);
}
return $this;
}
public function removeRssEvent(RssEvent $rssEvent): self
{
if ($this->rssEvents->contains($rssEvent)) {
$this->rssEvents->removeElement($rssEvent);
$rssEvent->removeThematique($this);
}
return $this;
}
}