function ControllerBase::currentUser

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Controller/ControllerBase.php \Drupal\Core\Controller\ControllerBase::currentUser()
  2. 8.9.x core/lib/Drupal/Core/Controller/ControllerBase.php \Drupal\Core\Controller\ControllerBase::currentUser()
  3. 11.x core/lib/Drupal/Core/Controller/ControllerBase.php \Drupal\Core\Controller\ControllerBase::currentUser()

Returns the current user.

Return value

\Drupal\Core\Session\AccountInterface The current user.

1 call to ControllerBase::currentUser()
UserController::resetPass in core/modules/user/src/Controller/UserController.php
Redirects to the user password reset form.

File

core/lib/Drupal/Core/Controller/ControllerBase.php, line 232

Class

ControllerBase
Utility base class for thin controllers.

Namespace

Drupal\Core\Controller

Code

protected function currentUser() {
  if (!$this->currentUser) {
    $this->currentUser = $this->container()
      ->get('current_user');
  }
  return $this->currentUser;
}

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