You are here

public function CurrentUserContext::__construct in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/user/src/ContextProvider/CurrentUserContext.php \Drupal\user\ContextProvider\CurrentUserContext::__construct()
  2. 10 core/modules/user/src/ContextProvider/CurrentUserContext.php \Drupal\user\ContextProvider\CurrentUserContext::__construct()

Constructs a new CurrentUserContext.

Parameters

\Drupal\Core\Session\AccountInterface $account: The current user.

\Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager: The entity type manager.

File

core/modules/user/src/ContextProvider/CurrentUserContext.php, line 41

Class

CurrentUserContext
Sets the current user as a context.

Namespace

Drupal\user\ContextProvider

Code

public function __construct(AccountInterface $account, EntityTypeManagerInterface $entity_type_manager) {
  $this->account = $account;
  $this->userStorage = $entity_type_manager
    ->getStorage('user');
}