class CurrentUser

Same name and namespace in other branches
  1. 11.x core/modules/user/src/Plugin/views/argument_default/CurrentUser.php \Drupal\user\Plugin\views\argument_default\CurrentUser
  2. 10 core/modules/user/src/Plugin/views/argument_default/CurrentUser.php \Drupal\user\Plugin\views\argument_default\CurrentUser
  3. 8.9.x core/modules/user/src/Plugin/views/argument_default/CurrentUser.php \Drupal\user\Plugin\views\argument_default\CurrentUser

Default argument plugin to extract the current user.

This plugin actually has no options so it does not need to do a great deal.

Plugin annotation


@ViewsArgumentDefault(
  id = "current_user",
  title = @Translation("User ID from logged in user")
)

Hierarchy

Expanded class hierarchy of CurrentUser

3 string references to 'CurrentUser'
FormBuilderTest::testInvalidToken in core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php
@covers ::doBuildForm[[api-linebreak]]
SharedTempStoreTest::testLegacyConstructor in core/tests/Drupal/Tests/Core/TempStore/SharedTempStoreTest.php
@group legacy
SharedTempStoreTest::testLegacyFactoryConstructor in core/tests/Drupal/Tests/Core/TempStore/SharedTempStoreTest.php
@group legacy @covers \Drupal\Core\TempStore\SharedTempStoreFactory::__construct[[api-linebreak]]

File

core/modules/user/src/Plugin/views/argument_default/CurrentUser.php, line 19

Namespace

Drupal\user\Plugin\views\argument_default
View source
class CurrentUser extends ArgumentDefaultPluginBase implements CacheableDependencyInterface {
  
  /**
   * {@inheritdoc}
   */
  public function getArgument() {
    return \Drupal::currentUser()->id();
  }
  
  /**
   * {@inheritdoc}
   */
  public function getCacheMaxAge() {
    return Cache::PERMANENT;
  }
  
  /**
   * {@inheritdoc}
   */
  public function getCacheContexts() {
    return [
      'user',
    ];
  }

}

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