Пример #1
0
 function setUser(UserInterface $user)
 {
     $this->user = array_toClass(['id' => $user->idField(), 'active' => $user->activeField(), 'username' => $user->usernameField(), 'password' => $user->passwordField(), 'token' => $user->tokenField(), 'registrationDate' => $user->registrationDateField(), 'lastLogin' => $user->lastLoginField(), 'role' => $user->roleField(), 'realName' => $user->realNameField()], GenericUser::class);
     $this->isValid = true;
 }
Пример #2
0
/**
 * Converts a PHP array of maps to an array if instances of the specified class.
 *
 * @param array  $array
 * @param string $className
 *
 * @return array
 */
function array_hidrate(array $array, $className)
{
    $o = [];
    foreach ($array as $k => $v) {
        $o[$k] = array_toClass($v, $className);
    }
    return $o;
}
Пример #3
0
 /**
  * Converts a PHP array map to an instance of the specified class.
  *
  * @param string $className
  *
  * @return mixed An instance of the specified class.
  */
 function toClass($className)
 {
     return array_toClass($this->A, $className);
 }