function FormBase::currentUser

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

Gets the current user.

Return value

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

11 calls to FormBase::currentUser()
AccountForm::form in core/modules/user/src/AccountForm.php
BookOutlineForm::form in core/modules/book/src/Form/BookOutlineForm.php
ContentEntityForm::validateForm in core/lib/Drupal/Core/Entity/ContentEntityForm.php
Button-level validation handlers are highly discouraged for entity forms, as they will prevent entity validation from running. If the entity is going to be saved during the form submission, this method should be manually invoked from the button-level…
EntityModerationForm::buildForm in core/modules/content_moderation/src/Form/EntityModerationForm.php
MessageForm::form in core/modules/contact/src/MessageForm.php

... See full list

2 methods override FormBase::currentUser()
RevisionDeleteForm::currentUser in core/lib/Drupal/Core/Entity/Form/RevisionDeleteForm.php
RevisionRevertForm::currentUser in core/lib/Drupal/Core/Entity/Form/RevisionRevertForm.php

File

core/lib/Drupal/Core/Form/FormBase.php, line 191

Class

FormBase
Provides a base class for forms.

Namespace

Drupal\Core\Form

Code

protected function currentUser() {
    return \Drupal::currentUser();
}

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