You are here

protected function ControllerBase::currentUser in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Controller/ControllerBase.php \Drupal\Core\Controller\ControllerBase::currentUser()
  2. 9 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.

28 calls to ControllerBase::currentUser()
CommentController::getReplyForm in core/modules/comment/src/Controller/CommentController.php
Form constructor for the comment reply form.
CommentController::renderNewCommentsNodeLinks in core/modules/comment/src/Controller/CommentController.php
Returns a set of nodes' last read timestamps.
CommentController::replyFormAccess in core/modules/comment/src/Controller/CommentController.php
Access check for the reply form.
ContactController::contactSitePage in core/modules/contact/src/Controller/ContactController.php
Presents the site-wide contact form.
ContentTranslationController::overview in core/modules/content_translation/src/Controller/ContentTranslationController.php
Builds the translations overview page.

... See full list

File

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

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;
}