PHP Class 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}.
Since: 3.0
Author: Qiang Xue ([email protected])
Inheritance: extends Prado\TComponent, implements Prado\Security\IUser
Afficher le fichier Open project: pradosoft/prado Class Usage Examples

Méthodes publiques

Méthode Description
__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 )

Méthodes protégées

Méthode Description
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.

Method Details

__construct() public méthode

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

getIsGuest() public méthode

public getIsGuest ( ) : boolean
Résultat boolean if the user is a guest, defaults to true.

getManager() public méthode

public getManager ( ) : IUserManager
Résultat IUserManager user manager

getName() public méthode

public getName ( ) : string
Résultat string username, defaults to empty string.

getRoles() public méthode

public getRoles ( ) : array
Résultat array list of roles that the user is of

getState() protected méthode

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.
See also: setState
protected getState ( $key, $defaultValue = null ) : mixed
Résultat mixed the value of the variable. If it doesn't exist, the provided default value will be returned

getStateChanged() public méthode

public getStateChanged ( ) : boolean
Résultat boolean whether user session state is changed (i.e., setState() is called)

isInRole() public méthode

public isInRole ( $role ) : boolean
Résultat boolean whether the user is of this role

loadFromString() public méthode

public loadFromString ( $data ) : Prado\Security\IUser
Résultat Prado\Security\IUser the user object

saveToString() public méthode

public saveToString ( ) : string
Résultat string user data that is serialized and will be stored in session

setIsGuest() public méthode

public setIsGuest ( $value )

setName() public méthode

public setName ( $value )

setRoles() public méthode

public setRoles ( $value ) : array | string
Résultat array | string list of roles that the user is of. If it is a string, roles are assumed by separated by comma

setState() protected méthode

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.
See also: getState
protected setState ( $key, $value, $defaultValue = null )

setStateChanged() public méthode

public setStateChanged ( $value )