X-Git-Url: https://git.rapsys.eu/airbundle/blobdiff_plain/1c376852cd0277866cbb7345ea00993f0b37ad76..3f4eae21e72bf3261fa8b939a50408de6b119f74:/Entity/Dance.php diff --git a/Entity/Dance.php b/Entity/Dance.php index dccee33..0b132c8 100644 --- a/Entity/Dance.php +++ b/Entity/Dance.php @@ -209,6 +209,9 @@ class Dance { * @return Dance */ public function addUser(User $user): Dance { + //Add from owning side + $user->addDance($this); + $this->users[] = $user; return $this; @@ -222,6 +225,13 @@ class Dance { * @return bool */ public function removeUser(User $user): bool { + if (!$this->dances->contains($user)) { + return true; + } + + //Remove from owning side + $user->removeDance($this); + return $this->users->removeElement($user); } @@ -239,7 +249,7 @@ class Dance { */ public function preUpdate(PreUpdateEventArgs $eventArgs) { //Check that we have a dance instance - if (($dance = $eventArgs->getEntity()) instanceof Dance) { + if (($dance = $eventArgs->getObject()) instanceof Dance) { //Set updated value $dance->setUpdated(new \DateTime('now')); }