|
Class TUser
TUser class
TUser implements basic user functionality for a Prado application. To get the
name of the user, use getName Name property. The property getIsGuest IsGuest tells if the user a guest/anonymous user. To obtain or test
the roles that the user is in, use property getRoles Roles and call
TUser::isInRole() , respectively.
TUser is meant to be used together with IUserManager .
-
TComponent
-
TUser
implements
IUser
Methods summary
public
|
#
__construct( IUserManager $manager )
Constructor.
Parameters
Overrides
|
public
IUserManager
|
|
public
string
|
#
getName( )
Returns
string username, defaults to empty string.
Implementation of
|
public
|
#
setName( string $value )
Parameters
Implementation of
|
public
boolean
|
#
getIsGuest( )
Returns
boolean if the user is a guest, defaults to true.
Implementation of
|
public
|
#
setIsGuest( boolean $value )
Parameters
- $value
boolean if the user is a guest
Implementation of
|
public
array
|
#
getRoles( )
Returns
array list of roles that the user is of
Implementation of
|
public
array|string
|
#
setRoles( mixed $value )
Returns
array|string list of roles that the user is of. If it is a string, roles are assumed by
separated by comma
Implementation of
|
public
boolean
|
#
isInRole( string $role )
Parameters
- $role
string role to be tested. Note, role is case-insensitive.
Returns
boolean whether the user is of this role
Implementation of
|
public
string
|
#
saveToString( )
Returns
string user data that is serialized and will be stored in session
Implementation of
|
public
IUser
|
#
loadFromString( string $data )
Parameters
- $data
string user data that is serialized and restored from session
Returns
Implementation of
|
protected
mixed
|
#
getState( string $key, mixed $defaultValue = null )
Returns the value of a variable that is stored in user session.
Returns the value of a variable that is stored in user session.
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 TUser::setState() can be retrieved back using this function.
Parameters
- $key
string variable name
- $defaultValue
mixed default value
Returns
mixed the value of the variable. If it doesn't exist, the provided default value will
be returned
See
|
protected
|
#
setState( string $key, mixed $value, mixed $defaultValue = null )
Stores a variable in user session.
Stores a variable in user session.
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 TUser::getState() .
The variable will be persistent across page requests during a user session.
Parameters
- $key
string variable name
- $value
mixed variable value
- $defaultValue
mixed default value. If $value===$defaultValue, the variable will be removed from
persistent storage.
See
|
public
boolean
|
#
getStateChanged( )
Returns
boolean whether user session state is changed (i.e., setState() is called)
|
public
|
#
setStateChanged( boolean $value )
Parameters
- $value
boolean whether user session state is changed
|
Methods inherited from TComponent
__call(),
__destruct(),
__get(),
__isset(),
__set(),
__sleep(),
__unset(),
__wakeup(),
addParsedObject(),
asa(),
attachBehavior(),
attachBehaviors(),
attachClassBehavior(),
attachEventHandler(),
canGetProperty(),
canSetProperty(),
clearBehaviors(),
createdOnTemplate(),
detachBehavior(),
detachBehaviors(),
detachClassBehavior(),
detachEventHandler(),
disableBehavior(),
disableBehaviors(),
enableBehavior(),
enableBehaviors(),
evaluateExpression(),
evaluateStatements(),
fxAttachClassBehavior(),
fxDetachClassBehavior(),
getAutoGlobalListen(),
getBehaviorsEnabled(),
getClassHierarchy(),
getEventHandlers(),
getListeningToGlobalEvents(),
getSubProperty(),
hasEvent(),
hasEventHandler(),
hasProperty(),
isa(),
listen(),
raiseEvent(),
setSubProperty(),
unlisten()
|
|