eZ\Publish\Core\Persistence\Legacy\User\Mapper::mapUser PHP Method

mapUser() public method

Map user data into user object.
public mapUser ( array $data ) : eZ\Publish\SPI\Persistence\User
$data array
return eZ\Publish\SPI\Persistence\User
    public function mapUser(array $data)
    {
        $user = new User();
        $user->id = $data['contentobject_id'];
        $user->login = $data['login'];
        $user->email = $data['email'];
        $user->passwordHash = $data['password_hash'];
        $user->hashAlgorithm = $data['password_hash_type'];
        $user->isEnabled = (bool) $data['is_enabled'];
        $user->maxLogin = $data['max_login'];
        return $user;
    }

Usage Example

Beispiel #1
0
 /**
  * Loads user with user login.
  *
  * @param string $login
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If user is not found
  *
  * @return \eZ\Publish\SPI\Persistence\User
  */
 public function loadByLogin($login)
 {
     $data = $this->userGateway->loadByLogin($login);
     if (empty($data)) {
         throw new NotFound('user', $login);
     } elseif (isset($data[1])) {
         throw new LogicException("Found more then one user with login '{$login}'");
     }
     return $this->mapper->mapUser($data[0]);
 }