/**
  * Adds a new User to the provider.
  *
  * @param AccountInterface $user A AccountInterface instance
  */
 public function createUser(AccountInterface $user)
 {
     if (isset($this->users[strtolower($user->getUsername())])) {
         throw new \LogicException('Another user with the same username already exist.');
     }
     $this->users[strtolower($user->getUsername())] = $user;
 }
 /**
  * @return ServerGrove\SGLiveChatBundle\Document\Operator
  */
 public function loadUserByAccount(AccountInterface $user)
 {
     if ($user instanceof Operator) {
         return $user;
     }
     return $this->loadUserByUsername($user->getUsername());
 }
Ejemplo n.º 3
0
 /**
  * Finds a user by account
  *
  * It is strongly discouraged to use this method manually as it bypasses
  * all ACL checks.
  *
  * @param AccountInterface $user
  * @return User
  */
 public function loadUserByAccount(AccountInterface $user)
 {
     if (!$user instanceof User) {
         throw new UnsupportedAccountException('Account is not supported.');
     }
     return $this->loadUserByUsername($user->getUsername());
 }
 /**
  * Creates a user security identity from an AccountInterface
  *
  * @param AccountInterface $user
  * @return UserSecurityIdentity
  */
 public static function fromAccount(AccountInterface $user)
 {
     return new self($user->getUsername(), get_class($user));
 }