PHP Класс Prado\Security\TUser

TUser implements basic user functionality for a Prado application. To get the name of the user, use {@link getName Name} property. The property {@link getIsGuest IsGuest} tells if the user a guest/anonymous user. To obtain or test the roles that the user is in, use property {@link getRoles Roles} and call {@link isInRole()}, respectively. TUser is meant to be used together with {@link IUserManager}.
С версии: 3.0
Автор: Qiang Xue ([email protected])
Наследование: extends Prado\TComponent, implements Prado\Security\IUser
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__construct ( IUserManager $manager ) Constructor.
getIsGuest ( ) : boolean
getManager ( ) : IUserManager
getName ( ) : string
getRoles ( ) : array
getStateChanged ( ) : boolean
isInRole ( $role ) : boolean
loadFromString ( $data ) : Prado\Security\IUser
saveToString ( ) : string
setIsGuest ( $value )
setName ( $value )
setRoles ( $value ) : array | string
setStateChanged ( $value )

Защищенные методы

Метод Описание
getState ( $key, $defaultValue = null ) : mixed Returns the value of a variable that is stored in user session.
setState ( $key, $value, $defaultValue = null ) Stores a variable in user session.

Описание методов

__construct() публичный Метод

Constructor.
public __construct ( IUserManager $manager )
$manager IUserManager

getIsGuest() публичный Метод

public getIsGuest ( ) : boolean
Результат boolean if the user is a guest, defaults to true.

getManager() публичный Метод

public getManager ( ) : IUserManager
Результат IUserManager user manager

getName() публичный Метод

public getName ( ) : string
Результат string username, defaults to empty string.

getRoles() публичный Метод

public getRoles ( ) : array
Результат array list of roles that the user is of

getState() защищенный Метод

This function is designed to be used by TUser descendant classes who want to store additional user information in user session. A variable, if stored in user session using {@link setState} can be retrieved back using this function.
См. также: setState
protected getState ( $key, $defaultValue = null ) : mixed
Результат mixed the value of the variable. If it doesn't exist, the provided default value will be returned

getStateChanged() публичный Метод

public getStateChanged ( ) : boolean
Результат boolean whether user session state is changed (i.e., setState() is called)

isInRole() публичный Метод

public isInRole ( $role ) : boolean
Результат boolean whether the user is of this role

loadFromString() публичный Метод

public loadFromString ( $data ) : Prado\Security\IUser
Результат Prado\Security\IUser the user object

saveToString() публичный Метод

public saveToString ( ) : string
Результат string user data that is serialized and will be stored in session

setIsGuest() публичный Метод

public setIsGuest ( $value )

setName() публичный Метод

public setName ( $value )

setRoles() публичный Метод

public setRoles ( $value ) : array | string
Результат array | string list of roles that the user is of. If it is a string, roles are assumed by separated by comma

setState() защищенный Метод

This function is designed to be used by TUser descendant classes who want to store additional user information in user session. By storing a variable using this function, the variable may be retrieved back later using {@link getState}. The variable will be persistent across page requests during a user session.
См. также: getState
protected setState ( $key, $value, $defaultValue = null )

setStateChanged() публичный Метод

public setStateChanged ( $value )