Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / user / src / Plugin / views / argument_default / CurrentUser.php
1 <?php
2
3 namespace Drupal\user\Plugin\views\argument_default;
4
5 use Drupal\Core\Cache\Cache;
6 use Drupal\Core\Cache\CacheableDependencyInterface;
7 use Drupal\views\Plugin\views\argument_default\ArgumentDefaultPluginBase;
8
9 /**
10  * Default argument plugin to extract the current user
11  *
12  * This plugin actually has no options so it does not need to do a great deal.
13  *
14  * @ViewsArgumentDefault(
15  *   id = "current_user",
16  *   title = @Translation("User ID from logged in user")
17  * )
18  */
19 class CurrentUser extends ArgumentDefaultPluginBase implements CacheableDependencyInterface {
20
21   /**
22    * {@inheritdoc}
23    */
24   public function getArgument() {
25     return \Drupal::currentUser()->id();
26   }
27
28   /**
29    * {@inheritdoc}
30    */
31   public function getCacheMaxAge() {
32     return Cache::PERMANENT;
33   }
34
35   /**
36    * {@inheritdoc}
37    */
38   public function getCacheContexts() {
39     return ['user'];
40   }
41
42 }