mirror of
https://gitlab.aliens-lyon.fr/encartes/backend.git
synced 2026-09-11 16:50:46 +02:00
Modify Connections to be symetric and to be beautiful + add connectedFloors to get_floor
This commit is contained in:
+28
-35
@@ -28,8 +28,6 @@ class Place
|
||||
private $floors;
|
||||
|
||||
#[ORM\ManyToMany(targetEntity: Place::class, inversedBy: "connectedPlaces")]
|
||||
private $connection;
|
||||
#[ORM\ManyToMany(targetEntity: Place::class, mappedBy: "connection")]
|
||||
private $connectedPlaces;
|
||||
|
||||
#[ORM\OneToMany(targetEntity: ThreeDObjectFile::class, mappedBy: "place")]
|
||||
@@ -46,7 +44,6 @@ class Place
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->connection = new ArrayCollection();
|
||||
$this->connectedPlaces = new ArrayCollection();
|
||||
$this->names = new ArrayCollection();
|
||||
$this->users = new ArrayCollection();
|
||||
@@ -77,12 +74,12 @@ class Place
|
||||
/**
|
||||
* @return Collection<int, self>
|
||||
*/
|
||||
public function getNames(): Collection
|
||||
public function getNames(): Collection //of PlaceName
|
||||
{
|
||||
return $this->names;
|
||||
}
|
||||
|
||||
public function getJoinedNames(): array
|
||||
public function getJoinedNames(): array //of sting
|
||||
{
|
||||
$names = array();
|
||||
foreach ($this->names as $plName) {
|
||||
@@ -160,6 +157,14 @@ class Place
|
||||
{
|
||||
return $this->floors;
|
||||
}
|
||||
public function getFloorsId(): array
|
||||
{
|
||||
$response = array();
|
||||
foreach ($this->floors as $f) {
|
||||
$response[] = $f->getId();
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function addFloor(Floor $floor): self
|
||||
{
|
||||
@@ -174,27 +179,6 @@ class Place
|
||||
$this->floors->removeElement($floor);
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @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>
|
||||
@@ -204,20 +188,29 @@ class Place
|
||||
return $this->connectedPlaces;
|
||||
}
|
||||
|
||||
public function addConnectedPlace(self $connectedPlace): self
|
||||
public function addConnection(self $connection): self
|
||||
{
|
||||
if (!$this->connectedPlaces->contains($connectedPlace)) {
|
||||
$this->connectedPlaces[] = $connectedPlace;
|
||||
$connectedPlace->addConnection($this);
|
||||
$this->addConnectedPlace($connection);
|
||||
$connection->addConnectedPlace($this);
|
||||
return $this;
|
||||
}
|
||||
private function addConnectedPlace(Place $place_to_connect): self
|
||||
{
|
||||
if (!$this->connectedPlaces->contains($place_to_connect)) {
|
||||
$this->connectedPlaces[] = $place_to_connect;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeConnectedPlace(self $connectedPlace): self
|
||||
|
||||
public function removeConnection(self $connection): self
|
||||
{
|
||||
if ($this->connectedPlaces->removeElement($connectedPlace)) {
|
||||
$connectedPlace->removeConnection($this);
|
||||
}
|
||||
$this->removeConnectedPlace($connection);
|
||||
$connection->removeConnectedPlace($this);
|
||||
return $this;
|
||||
}
|
||||
private function removeConnectedPlace(Place $place_to_deconnect): self
|
||||
{
|
||||
$this->connectedPlaces->removeElement($place_to_deconnect);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user