Drupal 8  8.0.2
UserSession Class Reference
Inheritance diagram for UserSession:

Public Member Functions

 __construct (array $values=array())
 
 id ()
 
 getRoles ($exclude_locked_roles=FALSE)
 
 hasPermission ($permission)
 
 isAuthenticated ()
 
 isAnonymous ()
 
 getPreferredLangcode ($fallback_to_default=TRUE)
 
 getPreferredAdminLangcode ($fallback_to_default=TRUE)
 
 getUsername ()
 
 getAccountName ()
 
 getDisplayName ()
 
 getEmail ()
 
 getTimeZone ()
 
 getLastAccessedTime ()
 

Data Fields

 $name = ''
 

Protected Member Functions

 getRoleStorage ()
 

Protected Attributes

 $uid = 0
 
 $roles = array(AccountInterface::ANONYMOUS_ROLE)
 
 $access
 
 $preferred_langcode
 
 $preferred_admin_langcode
 
 $mail
 
 $timezone
 

Detailed Description

An implementation of the user account interface for the global user.

Todo:
: Change all properties to protected.

Constructor & Destructor Documentation

__construct ( array  $values = array())

Constructs a new user session.

Parameters
array$valuesArray of initial values for the user session.

Member Function Documentation

getAccountName ( )

{Returns the unaltered login name of this account.

Returns
string An unsanitized plain-text string with the name of this account that is used to log in. Only display this name to admins and to the user who owns this account, and only in the context of the name used to login. For any other display purposes, use ::getDisplayName() instead.
}

Implements AccountInterface.

Referenced by UserSession\getUsername().

Here is the caller graph for this function:

getDisplayName ( )

{Returns the display name of this account.By default, the passed-in object's 'name' property is used if it exists, or else, the site-defined value for the 'anonymous' variable. However, a module may override this by implementing hook_user_format_name_alter(&$name, $account).

See Also
hook_user_format_name_alter()
Returns
string| Either a string that will be auto-escaped on output or a MarkupInterface object that is already HTML escaped. Either is safe to be printed within HTML fragments.
}

Implements AccountInterface.

References Drupal\config(), and Drupal\moduleHandler().

Here is the call graph for this function:

getEmail ( )

{Returns the email address of this account.

Returns
string The email address.
}

Implements AccountInterface.

getLastAccessedTime ( )

{The timestamp when the account last accessed the site.A value of 0 means the user has never accessed the site.

Returns
int Timestamp of the last access.
}

Implements AccountInterface.

getPreferredAdminLangcode (   $fallback_to_default = TRUE)

{Returns the preferred administrative language code of the account.Defines which language is used on administrative pages.

Parameters
bool$fallback_to_default(optional) Whether the return value will fall back to the site default language if the user has no administration language preference.
Returns
string The language code that is preferred by the account for administration pages. If the preferred language is not set or is a language not configured anymore on the site, the site default is returned or an empty string is returned (if $fallback_to_default is FALSE).
}

Implements AccountInterface.

References Drupal\languageManager().

Here is the call graph for this function:

getPreferredLangcode (   $fallback_to_default = TRUE)

{Returns the preferred language code of the account.

Parameters
bool$fallback_to_default(optional) Whether the return value will fall back to the site default language if the user has no language preference.
Returns
string The language code that is preferred by the account. If the preferred language is not set or is a language not configured anymore on the site, the site default is returned or an empty string is returned (if $fallback_to_default is FALSE).
}

Implements AccountInterface.

References Drupal\languageManager().

Here is the call graph for this function:

getRoles (   $exclude_locked_roles = FALSE)

{Returns a list of roles.

Parameters
bool$exclude_locked_roles(optional) If TRUE, locked roles (anonymous/authenticated) are not returned.
Returns
array List of role IDs.
}

Implements AccountInterface.

References AccountInterface\ANONYMOUS_ROLE, and AccountInterface\AUTHENTICATED_ROLE.

Referenced by UserSession\hasPermission().

Here is the caller graph for this function:

getRoleStorage ( )
protected

Returns the role storage object.

Returns
The role storage object.

Referenced by UserSession\hasPermission().

Here is the caller graph for this function:

getTimeZone ( )

{Returns the timezone of this account.

Returns
string Name of the timezone.
}

Implements AccountInterface.

getUsername ( )

{Returns the unaltered login name of this account.

Returns
string An unsanitized plain-text string with the name of this account that is used to log in. Only display this name to admins and to the user who owns this account, and only in the context of the name used to login. For any other display purposes, use ::getDisplayName() instead.
Deprecated:
in Drupal 8.0.0, will be removed before Drupal 9.0.0. Use ::getAccountName() or ::getDisplayName() instead.
}

Implements AccountInterface.

References UserSession\getAccountName().

Here is the call graph for this function:

hasPermission (   $permission)

{Checks whether a user has a certain permission.

Parameters
string$permissionThe permission string to check.
Returns
bool TRUE if the user has the permission, FALSE otherwise.
}

Implements AccountInterface.

References UserSession\getRoles(), and UserSession\getRoleStorage().

Here is the call graph for this function:

id ( )

{Returns the user ID or 0 for anonymous.

Returns
int The user ID.
}

Implements AccountInterface.

isAnonymous ( )

{Returns TRUE if the account is anonymous.

Returns
bool TRUE if the account is anonymous.
}

Implements AccountInterface.

isAuthenticated ( )

{Returns TRUE if the account is authenticated.

Returns
bool TRUE if the account is authenticated.
}

Implements AccountInterface.


The documentation for this class was generated from the following file: