Uid.php in Drupal 8
File
core/modules/user/src/Plugin/views/argument/Uid.php
View source
<?php
namespace Drupal\user\Plugin\views\argument;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\views\Plugin\views\argument\NumericArgument;
use Symfony\Component\DependencyInjection\ContainerInterface;
class Uid extends NumericArgument {
protected $storage;
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityStorageInterface $storage) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->storage = $storage;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('entity_type.manager')
->getStorage('user'));
}
public function titleQuery() {
return array_map(function ($account) {
return $account
->label();
}, $this->storage
->loadMultiple($this->value));
}
}
Classes
Name |
Description |
Uid |
Argument handler to accept a user id. |