Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 6 |
| CurrentUser | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 6 |
| getArgument | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| getCacheMaxAge | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| getCacheContexts | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| <?php | |
| /** | |
| * @file | |
| * Contains \Drupal\user\Plugin\views\argument_default\CurrentUser. | |
| */ | |
| namespace Drupal\user\Plugin\views\argument_default; | |
| use Drupal\Core\Cache\Cache; | |
| use Drupal\Core\Cache\CacheableDependencyInterface; | |
| use Drupal\views\Plugin\views\argument_default\ArgumentDefaultPluginBase; | |
| /** | |
| * Default argument plugin to extract the current user | |
| * | |
| * This plugin actually has no options so it odes not need to do a great deal. | |
| * | |
| * @ViewsArgumentDefault( | |
| * id = "current_user", | |
| * title = @Translation("User ID from logged in user") | |
| * ) | |
| */ | |
| 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']; | |
| } | |
| } |