X-Git-Url: https://git.rapsys.eu/airbundle/blobdiff_plain/89206adbc7af13fc281d31dabcc416d973982428..484e99987490d5b250841f3a04e38bd6ee46c3ad:/Entity/Location.php?ds=sidebyside diff --git a/Entity/Location.php b/Entity/Location.php index c379b56..85283df 100644 --- a/Entity/Location.php +++ b/Entity/Location.php @@ -429,6 +429,9 @@ class Location { * @return Location */ public function addUser(User $user): Location { + //Add from owning side + $user->addLocation($this); + $this->users[] = $user; return $this; @@ -441,6 +444,13 @@ class Location { * @return bool */ public function removeUser(User $user): bool { + if (!$this->locations->contains($user)) { + return true; + } + + //Remove from owning side + $user->removeLocation($this); + return $this->users->removeElement($user); } @@ -458,7 +468,7 @@ class Location { */ public function preUpdate(PreUpdateEventArgs $eventArgs) { //Check that we have a location instance - if (($location = $eventArgs->getEntity()) instanceof Location) { + if (($location = $eventArgs->getObject()) instanceof Location) { //Set updated value $location->setUpdated(new \DateTime('now')); }