]> Raphaƫl G. Git Repositories - airbundle/blobdiff - Entity/Location.php
Fix dance user add/remove from inverse side
[airbundle] / Entity / Location.php
index c379b560c8a614805d013845a31359e58553fb9b..613e46281c3664f841ddbc86f8790c8bfb50f966 100644 (file)
@@ -429,6 +429,9 @@ class Location {
         * @return Location
         */
        public function addUser(User $user): Location {
         * @return Location
         */
        public function addUser(User $user): Location {
+               //Add from owning side
+               $user->addSubscriber($this);
+
                $this->users[] = $user;
 
                return $this;
                $this->users[] = $user;
 
                return $this;
@@ -441,6 +444,13 @@ class Location {
         * @return bool
         */
        public function removeUser(User $user): bool {
         * @return bool
         */
        public function removeUser(User $user): bool {
+               if (!$this->users->contains($user)) {
+                       return true;
+               }
+
+               //Remove from owning side
+               $user->removeSubscriber($this);
+
                return $this->users->removeElement($user);
        }
 
                return $this->users->removeElement($user);
        }