* @return User
*/
public function addSubscriber(User $subscriber): User {
+ //Add from owning side
+ $subscriber->addSubscription($this);
+
$this->subscribers[] = $subscriber;
return $this;
* @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);
}
* @return User
*/
public function addSubscription(User $subscription): User {
- //Add from owning side
- $subscription->addSubscriber($this);
-
$this->subscriptions[] = $subscription;
return $this;
* @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);
}