You are here

public function Security::getCurrentUser in Bamboo Twig 8

Return the current user.

Return value

\Drupal\Core\Session\AccountInterface|null The current user AccountInterface or NULL when anonymous.

File

bamboo_twig_security/src/TwigExtension/Security.php, line 64

Class

Security
Provides a 'Security' Twig Extensions.

Namespace

Drupal\bamboo_twig_security\TwigExtension

Code

public function getCurrentUser($user = NULL) {
  if ($this->currentUser
    ->isAnonymous()) {
    return NULL;
  }
  return $this->userStorage
    ->load($this->currentUser
    ->id());
}