X-Git-Url: https://git.rapsys.eu/airbundle/blobdiff_plain/2165a9bd9a68d72ab31f2c4c6f07e276736509da..5f9555c61970832ea2a3f1672ab4c21324c14ba5:/Entity/User.php?ds=sidebyside diff --git a/Entity/User.php b/Entity/User.php index 387b196..807fece 100644 --- a/Entity/User.php +++ b/Entity/User.php @@ -347,6 +347,9 @@ class User extends BaseUser { * @return User */ public function addSubscriber(User $subscriber): User { + //Add from owning side + $subscriber->addSubscription($this); + $this->subscribers[] = $subscriber; return $this; @@ -358,6 +361,13 @@ class User extends BaseUser { * @param User $subscriber */ public function removeSubscriber(User $subscriber): bool { + if (!$this->subscriptions->contains($subscriber)) { + return true; + } + + //Remove from owning side + $subscriber->removeSubscription($this); + return $this->subscribers->removeElement($subscriber); } @@ -378,9 +388,6 @@ class User extends BaseUser { * @return User */ public function addSubscription(User $subscription): User { - //Add from owning side - $subscription->addSubscriber($this); - $this->subscriptions[] = $subscription; return $this; @@ -392,13 +399,6 @@ class User extends BaseUser { * @param User $subscription */ public function removeSubscription(User $subscription): bool { - if (!$this->users->contains($user)) { - return true; - } - - //Remove from owning side - $subscription->removeSubscriber($this); - return $this->subscriptions->removeElement($subscription); }