mirror of
https://gitlab.aliens-lyon.fr/encartes/backend.git
synced 2026-03-17 22:51:04 +01:00
94 lines
2.0 KiB
PHP
94 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use App\Repository\PlaceRepository;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
/**
|
|
* @ORM\Entity(repositoryClass=PlaceRepository::class)
|
|
*/
|
|
class Place
|
|
{
|
|
/**
|
|
* @ORM\Id
|
|
* @ORM\GeneratedValue
|
|
* @ORM\Column(type="integer")
|
|
*/
|
|
private $id;
|
|
|
|
/**
|
|
* @ORM\ManyToMany(targetEntity=Place::class, inversedBy="connectedPlaces")
|
|
*/
|
|
private $connection;
|
|
|
|
/**
|
|
* @ORM\ManyToMany(targetEntity=Place::class, mappedBy="connection")
|
|
*/
|
|
private $connectedPlaces;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->connection = new ArrayCollection();
|
|
$this->connectedPlaces = new ArrayCollection();
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
/**
|
|
* @return Collection<int, self>
|
|
*/
|
|
public function getConnection(): Collection
|
|
{
|
|
return $this->connection;
|
|
}
|
|
|
|
public function addConnection(self $connection): self
|
|
{
|
|
if (!$this->connection->contains($connection)) {
|
|
$this->connection[] = $connection;
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeConnection(self $connection): self
|
|
{
|
|
$this->connection->removeElement($connection);
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection<int, self>
|
|
*/
|
|
public function getConnectedPlaces(): Collection
|
|
{
|
|
return $this->connectedPlaces;
|
|
}
|
|
|
|
public function addConnectedPlace(self $connectedPlace): self
|
|
{
|
|
if (!$this->connectedPlaces->contains($connectedPlace)) {
|
|
$this->connectedPlaces[] = $connectedPlace;
|
|
$connectedPlace->addConnection($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeConnectedPlace(self $connectedPlace): self
|
|
{
|
|
if ($this->connectedPlaces->removeElement($connectedPlace)) {
|
|
$connectedPlace->removeConnection($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
}
|