diff --git a/core/modules/user/lib/Drupal/user/Plugin/views/argument/Uid.php b/core/modules/user/lib/Drupal/user/Plugin/views/argument/Uid.php index 4137ef1..0c299d1 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/views/argument/Uid.php +++ b/core/modules/user/lib/Drupal/user/Plugin/views/argument/Uid.php @@ -8,7 +8,9 @@ namespace Drupal\user\Plugin\views\argument; use Drupal\Component\Utility\String; +use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\views\Plugin\views\argument\Numeric; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Argument handler to accept a user id. @@ -20,6 +22,38 @@ class Uid extends Numeric { /** + * The user storage controller. + * + * @var \Drupal\Core\Entity\EntityStorageControllerInterface + */ + protected $storageController; + + /** + * Constructs a Drupal\Component\Plugin\PluginBase object. + * + * @param array $configuration + * A configuration array containing information about the plugin instance. + * @param string $plugin_id + * The plugin_id for the plugin instance. + * @param array $plugin_definition + * The plugin implementation definition. + * @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage_controller + * The user storage controller. + */ + public function __construct(array $configuration, $plugin_id, array $plugin_definition, EntityStorageControllerInterface $storage_controller) { + parent::__construct($configuration, $plugin_id, $plugin_definition); + $this->storageController = $storage_controller; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, array $plugin_definition) { + return new static($configuration, $plugin_id, $plugin_definition, + $container->get('entity.manager')->getStorageController('user')); + } + + /** * Override the behavior of title(). Get the name of the user. * * @return array @@ -28,7 +62,7 @@ class Uid extends Numeric { public function titleQuery() { return array_map(function($account) { return String::checkPlain($account->label()); - }, user_load_multiple($this->value)); + }, $this->storageController->loadMultiple($this->value)); } } diff --git a/core/modules/user/lib/Drupal/user/Tests/Views/HandlerArgumentUserUidTest.php b/core/modules/user/lib/Drupal/user/Tests/Views/HandlerArgumentUserUidTest.php index 1d6dacf..2c44bd8 100644 --- a/core/modules/user/lib/Drupal/user/Tests/Views/HandlerArgumentUserUidTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/Views/HandlerArgumentUserUidTest.php @@ -45,13 +45,14 @@ public function testArgumentTitle() { $view->destroy(); // Tests the anonymous user. + $anonymous = $this->container->get('config.factory')->get('user.settings')->get('anonymous'); $this->executeView($view, array(0)); - $this->assertEqual($view->getTitle(), \Drupal::config('user.settings')->get('anonymous')); + $this->assertEqual($view->getTitle(), $anonymous); $view->destroy(); $view->getDisplay()->getHandler('argument', 'uid')->options['break_phrase'] = TRUE; $this->executeView($view, array($account->id() . ',0')); - $this->assertEqual($view->getTitle(), $account->label() . ', ' . \Drupal::config('user.settings')->get('anonymous')); + $this->assertEqual($view->getTitle(), $account->label() . ', ' . $anonymous); $view->destroy(); }