You are here

class CurrentUser in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/user/src/Plugin/views/argument_default/CurrentUser.php \Drupal\user\Plugin\views\argument_default\CurrentUser
  2. 9 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

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',
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheableDependencyInterface::getCacheTags public function The cache tags associated with this object. 14
CurrentUser::getArgument public function
CurrentUser::getCacheContexts public function The cache contexts associated with this object. Overrides CacheableDependencyInterface::getCacheContexts
CurrentUser::getCacheMaxAge public function The maximum age for which this object may be cached. Overrides CacheableDependencyInterface::getCacheMaxAge