protected function FormBuilder::currentUser

protected FormBuilder::currentUser()

Gets the current active user.

Return value

\Drupal\Core\Session\AccountInterface

File

core/lib/Drupal/Core/Form/FormBuilder.php, line 1383

Class

FormBuilder
Provides form building and processing.

Namespace

Drupal\Core\Form

Code

protected function currentUser() {
  if (!$this->currentUser && \Drupal::hasService('current_user')) {
    $this->currentUser = \Drupal::currentUser();
  }
  return $this->currentUser;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Form!FormBuilder.php/function/FormBuilder::currentUser/8.1.x