You are here

public function Loader::loadCurrentUser in Bamboo Twig 8.5

Same name and namespace in other branches
  1. 8.2 bamboo_twig_loader/src/TwigExtension/Loader.php \Drupal\bamboo_twig_loader\TwigExtension\Loader::loadCurrentUser()
  2. 8.3 bamboo_twig_loader/src/TwigExtension/Loader.php \Drupal\bamboo_twig_loader\TwigExtension\Loader::loadCurrentUser()
  3. 8.4 bamboo_twig_loader/src/TwigExtension/Loader.php \Drupal\bamboo_twig_loader\TwigExtension\Loader::loadCurrentUser()

Return the current user object.

Return value

\Drupal\user\Entity\User|null The current user object or NULL when anonymous.

File

bamboo_twig_loader/src/TwigExtension/Loader.php, line 116

Class

Loader
Provides some loaders as Twig Extensions.

Namespace

Drupal\bamboo_twig_loader\TwigExtension

Code

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