Esempio n. 1
0
 /**
  * Follows another user
  *
  * @param User $user
  *
  * @throws FollowerException If the user follows already the user to follow
  * @throws ActivationException If the target user to follow is not activated
  */
 public function follow(User $user)
 {
     $this->ensureActivated();
     if (!$user->isActivated()) {
         throw new ActivationException();
     }
     if ($this->follows($user->getCredentials()->getUsername())) {
         throw new FollowerException();
     }
     $this->following->add($user);
 }