/Drupal 8

class AccountProxy

A proxied implementation of AccountInterface.

The reason why we need an account proxy is that we don't want to have global state directly stored in the container.

This proxy object avoids multiple invocations of the authentication manager which can happen if the current user is accessed in constructors. It also allows legacy code to change the current user where the user cannot be directly injected into dependent code.



core/lib/Drupal/Core/Session/AccountProxy.php, line 16




Name Modifiers Type Description
AccountInterface::ANONYMOUS_ROLE constant Role ID for anonymous users.
AccountInterface::AUTHENTICATED_ROLE constant Role ID for authenticated users.
AccountProxy::$account protected property The instantiated account.
AccountProxy::$initialAccountId protected property Initial account id.
AccountProxy::getAccount public function Gets the currently wrapped account. Overrides AccountProxyInterface::getAccount
AccountProxy::getAccountName public function Returns the unaltered login name of this account. Overrides AccountInterface::getAccountName
AccountProxy::getDisplayName public function Returns the display name of this account. Overrides AccountInterface::getDisplayName
AccountProxy::getEmail public function Returns the email address of this account. Overrides AccountInterface::getEmail
AccountProxy::getLastAccessedTime public function The timestamp when the account last accessed the site. Overrides AccountInterface::getLastAccessedTime
AccountProxy::getPreferredAdminLangcode public function Returns the preferred administrative language code of the account. Overrides AccountInterface::getPreferredAdminLangcode
AccountProxy::getPreferredLangcode public function Returns the preferred language code of the account. Overrides AccountInterface::getPreferredLangcode
AccountProxy::getRoles public function Returns a list of roles. Overrides AccountInterface::getRoles
AccountProxy::getTimeZone public function Returns the timezone of this account. Overrides AccountInterface::getTimeZone
AccountProxy::getUsername public function Returns the unaltered login name of this account. Overrides AccountInterface::getUsername
AccountProxy::hasPermission public function Checks whether a user has a certain permission. Overrides AccountInterface::hasPermission
AccountProxy::id public function Returns the user ID or 0 for anonymous. Overrides AccountInterface::id
AccountProxy::isAnonymous public function Returns TRUE if the account is anonymous. Overrides AccountInterface::isAnonymous
AccountProxy::isAuthenticated public function Returns TRUE if the account is authenticated. Overrides AccountInterface::isAuthenticated
AccountProxy::loadUserEntity protected function Load a user entity.
AccountProxy::setAccount public function Sets the currently wrapped account. Overrides AccountProxyInterface::setAccount
AccountProxy::setInitialAccountId public function Sets the id of the initial account. Overrides AccountProxyInterface::setInitialAccountId

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.