<?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\TerritoryRepository::class)]
class Territory implements \Stringable
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private int $id;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $display_name= null;
#[ORM\OneToMany(targetEntity: \App\Entity\Organization::class, mappedBy: 'territory')]
private mixed $organizations;
#[ORM\OneToMany(targetEntity: \App\Entity\Contact::class, mappedBy: 'territory')]
private mixed $contacts;
#[ORM\ManyToMany(targetEntity: \App\Entity\Post::class, mappedBy: 'territories')]
private mixed $posts;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $kind= null;
#[ORM\Column(type: 'integer', nullable: true)]
private int $ordre;
#[ORM\OneToMany(targetEntity: \App\Entity\Cantons::class, mappedBy: 'territory')]
private mixed $cantons;
#[ORM\ManyToMany(targetEntity: \App\Entity\User::class, mappedBy: 'territoires')]
private mixed $users;
#[ORM\ManyToMany(targetEntity: RssArticle::class, mappedBy: 'lieux')]
private mixed $rssArticles;
#[ORM\ManyToMany(targetEntity: RssEvent::class, mappedBy: 'lieux')]
private mixed $rssEvents;
#[ORM\OneToMany(mappedBy: 'territoire', targetEntity: Commune::class)]
private Collection $communes;
public function __construct()
{
$this->organizations = new ArrayCollection();
$this->contacts = new ArrayCollection();
$this->posts = new ArrayCollection();
$this->cantons = new ArrayCollection();
$this->users = new ArrayCollection();
$this->rssArticles = new ArrayCollection();
$this->rssEvents = new ArrayCollection();
$this->communes = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getDisplayName(): ?string
{
return $this->display_name;
}
public function setDisplayName(?string $display_name): self
{
$this->display_name = $display_name;
return $this;
}
/**
* @return Collection|Organization[]
*/
public function getOrganizations(): Collection
{
return $this->organizations;
}
public function addOrganization(Organization $organization): self
{
if (!$this->organizations->contains($organization)) {
$this->organizations[] = $organization;
$organization->setTerritory($this);
}
return $this;
}
public function removeOrganization(Organization $organization): self
{
if ($this->organizations->contains($organization)) {
$this->organizations->removeElement($organization);
// set the owning side to null (unless already changed)
if ($organization->getTerritory() === $this) {
$organization->setTerritory(null);
}
}
return $this;
}
/**
* @return Collection|Contact[]
*/
public function getContacts(): Collection
{
return $this->contacts;
}
public function addContact(Contact $contact): self
{
if (!$this->contacts->contains($contact)) {
$this->contacts[] = $contact;
$contact->setTerritory($this);
}
return $this;
}
public function removeContact(Contact $contact): self
{
if ($this->contacts->contains($contact)) {
$this->contacts->removeElement($contact);
// set the owning side to null (unless already changed)
if ($contact->getTerritory() === $this) {
$contact->setTerritory(null);
}
}
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->addTerritory($this);
}
return $this;
}
public function removePost(Post $post): self
{
if ($this->posts->contains($post)) {
$this->posts->removeElement($post);
$post->removeTerritory($this);
}
return $this;
}
public function __toString(): string
{
return (string) $this->display_name;
}
public function getKind(): ?string
{
return $this->kind;
}
public function setKind(?string $kind): self
{
$this->kind = $kind;
return $this;
}
public function getOrdre(): ?int
{
return $this->ordre;
}
public function setOrdre(?int $ordre): self
{
$this->ordre = $ordre;
return $this;
}
/**
* @return Collection|Cantons[]
*/
public function getCantons(): Collection
{
return $this->cantons;
}
public function addCanton(Cantons $canton): self
{
if (!$this->cantons->contains($canton)) {
$this->cantons[] = $canton;
$canton->setTerritory($this);
}
return $this;
}
public function removeCanton(Cantons $canton): self
{
if ($this->cantons->contains($canton)) {
$this->cantons->removeElement($canton);
// set the owning side to null (unless already changed)
if ($canton->getTerritory() === $this) {
$canton->setTerritory(null);
}
}
return $this;
}
/**
* @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->addTerritoire($this);
}
return $this;
}
public function removeUser(User $user): self
{
if ($this->users->contains($user)) {
$this->users->removeElement($user);
$user->removeTerritoire($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->addLieux($this);
}
return $this;
}
public function removeRssArticle(RssArticle $rssArticle): self
{
if ($this->rssArticles->contains($rssArticle)) {
$this->rssArticles->removeElement($rssArticle);
$rssArticle->removeLieux($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->addLieux($this);
}
return $this;
}
public function removeRssEvent(RssEvent $rssEvent): self
{
if ($this->rssEvents->contains($rssEvent)) {
$this->rssEvents->removeElement($rssEvent);
$rssEvent->removeLieux($this);
}
return $this;
}
/**
* @return Collection<int, Commune>
*/
public function getCommunes(): Collection
{
return $this->communes;
}
public function addCommune(Commune $commune): self
{
if (!$this->communes->contains($commune)) {
$this->communes->add($commune);
$commune->setTerritoire($this);
}
return $this;
}
public function removeCommune(Commune $commune): self
{
if ($this->communes->removeElement($commune)) {
// set the owning side to null (unless already changed)
if ($commune->getTerritoire() === $this) {
$commune->setTerritoire(null);
}
}
return $this;
}
}