/** * Subscribe specific user to this message * * @param User $user * @return boolean */ function subscribeUser(User $user) { if ($this->isNew()) { throw new Error('Can\'t subscribe user to object that is not saved'); } // if if ($this->isSubscriber($user)) { return true; } // if $this->subscribers = null; // New subscription $subscription = new ObjectSubscription(); $subscription->setObjectId($this->getId()); $subscription->setObjectManager(get_class($this->manager())); $subscription->setUserId($user->getId()); return $subscription->save(); }