function EntityAccessControlHandler::prepareUser

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php \Drupal\Core\Entity\EntityAccessControlHandler::prepareUser()
  2. 10 core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php \Drupal\Core\Entity\EntityAccessControlHandler::prepareUser()
  3. 11.x core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php \Drupal\Core\Entity\EntityAccessControlHandler::prepareUser()

Loads the current account object, if it does not exist yet.

Parameters

\Drupal\Core\Session\AccountInterface $account: The account interface instance.

Return value

\Drupal\Core\Session\AccountInterface Returns the current account object.

6 calls to EntityAccessControlHandler::prepareUser()
EntityAccessControlHandler::access in core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php
Checks access to an operation on a given entity or entity translation.
EntityAccessControlHandler::createAccess in core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php
Checks access to create an entity.
EntityAccessControlHandler::fieldAccess in core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php
Checks access to an operation on a given entity field.
FileAccessControlHandler::checkAccess in core/modules/file/src/FileAccessControlHandler.php
Performs access checks.
NodeAccessControlHandler::access in core/modules/node/src/NodeAccessControlHandler.php
Checks access to an operation on a given entity or entity translation.

... See full list

File

core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php, line 304

Class

EntityAccessControlHandler
Defines a default implementation for entity access control handler.

Namespace

Drupal\Core\Entity

Code

protected function prepareUser(AccountInterface $account = NULL) {
    if (!$account) {
        $account = \Drupal::currentUser();
    }
    return $account;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.