Bolt\Storage\Repository\UsersRepository::getUser PHP Method

getUser() public method

Get a user.
public getUser ( string | integer $userId ) : Bolt\Storage\Entity\Users | false
$userId string | integer Either the user's ID, username, or email address.
return Bolt\Storage\Entity\Users | false
    public function getUser($userId)
    {
        // Check if we've already retrieved this user.
        if (isset($this->userEntities[$userId])) {
            return $this->userEntities[$userId];
        }
        $query = $this->getUserQuery($userId);
        /** @var Entity\Users $userEntity */
        if ($userEntity = $this->findOneWith($query)) {
            $this->unsetSensitiveFields($userEntity);
        }
        // Remember the user
        $this->userEntities[$userId] = $userEntity;
        return $userEntity;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Get a user, specified by ID, username or email address.
  *
  * @param integer|string $userId
  *
  * @return array|false
  */
 public function getUser($userId)
 {
     if ($userEntity = $this->repository->getUser($userId)) {
         $userEntity->setPassword('**dontchange**');
         return $userEntity->toArray();
     }
     return false;
 }
All Usage Examples Of Bolt\Storage\Repository\UsersRepository::getUser