src/Entity/Territory.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\TerritoryRepository::class)]
  7. class Territory 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 $display_namenull;
  15.     #[ORM\OneToMany(targetEntity\App\Entity\Organization::class, mappedBy'territory')]
  16.     private mixed $organizations;
  17.     #[ORM\OneToMany(targetEntity\App\Entity\Contact::class, mappedBy'territory')]
  18.     private mixed $contacts;
  19.     #[ORM\ManyToMany(targetEntity\App\Entity\Post::class, mappedBy'territories')]
  20.     private mixed $posts;
  21.     #[ORM\Column(type'string'length255nullabletrue)]
  22.     private ?string $kindnull;
  23.     #[ORM\Column(type'integer'nullabletrue)]
  24.     private int $ordre;
  25.     #[ORM\OneToMany(targetEntity\App\Entity\Cantons::class, mappedBy'territory')]
  26.     private mixed $cantons;
  27.     #[ORM\ManyToMany(targetEntity\App\Entity\User::class, mappedBy'territoires')]
  28.     private mixed $users;
  29.     #[ORM\ManyToMany(targetEntityRssArticle::class, mappedBy'lieux')]
  30.     private mixed $rssArticles;
  31.     #[ORM\ManyToMany(targetEntityRssEvent::class, mappedBy'lieux')]
  32.     private mixed $rssEvents;
  33.     #[ORM\OneToMany(mappedBy'territoire'targetEntityCommune::class)]
  34.     private Collection $communes;
  35.     public function __construct()
  36.     {
  37.         $this->organizations = new ArrayCollection();
  38.         $this->contacts = new ArrayCollection();
  39.         $this->posts = new ArrayCollection();
  40.         $this->cantons = new ArrayCollection();
  41.         $this->users = new ArrayCollection();
  42.         $this->rssArticles = new ArrayCollection();
  43.         $this->rssEvents = new ArrayCollection();
  44.         $this->communes = new ArrayCollection();
  45.     }
  46.     public function getId(): ?int
  47.     {
  48.         return $this->id;
  49.     }
  50.     public function getDisplayName(): ?string
  51.     {
  52.         return $this->display_name;
  53.     }
  54.     public function setDisplayName(?string $display_name): self
  55.     {
  56.         $this->display_name $display_name;
  57.         return $this;
  58.     }
  59.     /**
  60.      * @return Collection|Organization[]
  61.      */
  62.     public function getOrganizations(): Collection
  63.     {
  64.         return $this->organizations;
  65.     }
  66.     public function addOrganization(Organization $organization): self
  67.     {
  68.         if (!$this->organizations->contains($organization)) {
  69.             $this->organizations[] = $organization;
  70.             $organization->setTerritory($this);
  71.         }
  72.         return $this;
  73.     }
  74.     public function removeOrganization(Organization $organization): self
  75.     {
  76.         if ($this->organizations->contains($organization)) {
  77.             $this->organizations->removeElement($organization);
  78.             // set the owning side to null (unless already changed)
  79.             if ($organization->getTerritory() === $this) {
  80.                 $organization->setTerritory(null);
  81.             }
  82.         }
  83.         return $this;
  84.     }
  85.     /**
  86.      * @return Collection|Contact[]
  87.      */
  88.     public function getContacts(): Collection
  89.     {
  90.         return $this->contacts;
  91.     }
  92.     public function addContact(Contact $contact): self
  93.     {
  94.         if (!$this->contacts->contains($contact)) {
  95.             $this->contacts[] = $contact;
  96.             $contact->setTerritory($this);
  97.         }
  98.         return $this;
  99.     }
  100.     public function removeContact(Contact $contact): self
  101.     {
  102.         if ($this->contacts->contains($contact)) {
  103.             $this->contacts->removeElement($contact);
  104.             // set the owning side to null (unless already changed)
  105.             if ($contact->getTerritory() === $this) {
  106.                 $contact->setTerritory(null);
  107.             }
  108.         }
  109.         return $this;
  110.     }
  111.     /**
  112.      * @return Collection|Post[]
  113.      */
  114.     public function getPosts(): Collection
  115.     {
  116.         return $this->posts;
  117.     }
  118.     public function addPost(Post $post): self
  119.     {
  120.         if (!$this->posts->contains($post)) {
  121.             $this->posts[] = $post;
  122.             $post->addTerritory($this);
  123.         }
  124.         return $this;
  125.     }
  126.     public function removePost(Post $post): self
  127.     {
  128.         if ($this->posts->contains($post)) {
  129.             $this->posts->removeElement($post);
  130.             $post->removeTerritory($this);
  131.         }
  132.         return $this;
  133.     }
  134.     public function __toString(): string
  135.     {
  136.         return (string) $this->display_name;
  137.     }
  138.     public function getKind(): ?string
  139.     {
  140.         return $this->kind;
  141.     }
  142.     public function setKind(?string $kind): self
  143.     {
  144.         $this->kind $kind;
  145.         return $this;
  146.     }
  147.     public function getOrdre(): ?int
  148.     {
  149.         return $this->ordre;
  150.     }
  151.     public function setOrdre(?int $ordre): self
  152.     {
  153.         $this->ordre $ordre;
  154.         return $this;
  155.     }
  156.     /**
  157.      * @return Collection|Cantons[]
  158.      */
  159.     public function getCantons(): Collection
  160.     {
  161.         return $this->cantons;
  162.     }
  163.     public function addCanton(Cantons $canton): self
  164.     {
  165.         if (!$this->cantons->contains($canton)) {
  166.             $this->cantons[] = $canton;
  167.             $canton->setTerritory($this);
  168.         }
  169.         return $this;
  170.     }
  171.     public function removeCanton(Cantons $canton): self
  172.     {
  173.         if ($this->cantons->contains($canton)) {
  174.             $this->cantons->removeElement($canton);
  175.             // set the owning side to null (unless already changed)
  176.             if ($canton->getTerritory() === $this) {
  177.                 $canton->setTerritory(null);
  178.             }
  179.         }
  180.         return $this;
  181.     }
  182.     /**
  183.      * @return Collection|User[]
  184.      */
  185.     public function getUsers(): Collection
  186.     {
  187.         return $this->users;
  188.     }
  189.     public function addUser(User $user): self
  190.     {
  191.         if (!$this->users->contains($user)) {
  192.             $this->users[] = $user;
  193.             $user->addTerritoire($this);
  194.         }
  195.         return $this;
  196.     }
  197.     public function removeUser(User $user): self
  198.     {
  199.         if ($this->users->contains($user)) {
  200.             $this->users->removeElement($user);
  201.             $user->removeTerritoire($this);
  202.         }
  203.         return $this;
  204.     }
  205.     /**
  206.      * @return Collection|RssArticle[]
  207.      */
  208.     public function getRssArticles(): Collection
  209.     {
  210.         return $this->rssArticles;
  211.     }
  212.     public function addRssArticle(RssArticle $rssArticle): self
  213.     {
  214.         if (!$this->rssArticles->contains($rssArticle)) {
  215.             $this->rssArticles[] = $rssArticle;
  216.             $rssArticle->addLieux($this);
  217.         }
  218.         return $this;
  219.     }
  220.     public function removeRssArticle(RssArticle $rssArticle): self
  221.     {
  222.         if ($this->rssArticles->contains($rssArticle)) {
  223.             $this->rssArticles->removeElement($rssArticle);
  224.             $rssArticle->removeLieux($this);
  225.         }
  226.         return $this;
  227.     }
  228.     /**
  229.      * @return Collection|RssEvent[]
  230.      */
  231.     public function getRssEvents(): Collection
  232.     {
  233.         return $this->rssEvents;
  234.     }
  235.     public function addRssEvent(RssEvent $rssEvent): self
  236.     {
  237.         if (!$this->rssEvents->contains($rssEvent)) {
  238.             $this->rssEvents[] = $rssEvent;
  239.             $rssEvent->addLieux($this);
  240.         }
  241.         return $this;
  242.     }
  243.     public function removeRssEvent(RssEvent $rssEvent): self
  244.     {
  245.         if ($this->rssEvents->contains($rssEvent)) {
  246.             $this->rssEvents->removeElement($rssEvent);
  247.             $rssEvent->removeLieux($this);
  248.         }
  249.         return $this;
  250.     }
  251.     /**
  252.      * @return Collection<int, Commune>
  253.      */
  254.     public function getCommunes(): Collection
  255.     {
  256.         return $this->communes;
  257.     }
  258.     public function addCommune(Commune $commune): self
  259.     {
  260.         if (!$this->communes->contains($commune)) {
  261.             $this->communes->add($commune);
  262.             $commune->setTerritoire($this);
  263.         }
  264.         return $this;
  265.     }
  266.     public function removeCommune(Commune $commune): self
  267.     {
  268.         if ($this->communes->removeElement($commune)) {
  269.             // set the owning side to null (unless already changed)
  270.             if ($commune->getTerritoire() === $this) {
  271.                 $commune->setTerritoire(null);
  272.             }
  273.         }
  274.         return $this;
  275.     }
  276. }