Пример #1
0
 /**
  * Connect a user with his login / password combination
  *
  * @param      string[]  $inputs  Inputs array containing array('login' => 'login', 'password' => 'password')
  *
  * @return     array  The occurred errors or success in a array
  */
 public function connect(array $inputs) : array
 {
     $userEntityManager = new UserEntityManager();
     $response = $userEntityManager->connect($inputs);
     if ($response['success']) {
         $this->user = $userEntityManager->getEntity();
         $response['user'] = $this->user->__toArray();
         $_SESSION['user'] = serialize($this->user);
     }
     return $response;
 }
Пример #2
0
 /**
  * Client object as an array
  *
  * @return     array  Client object as an array
  */
 public function __toArray() : array
 {
     return ['id' => $this->id, 'connection' => $this->connection->getRemoteAddress() . ':' . $this->connection->getRemotePort(), 'user' => $this->user !== null ? $this->user->__toArray() : [], 'location' => $this->location];
 }