diff --git a/core/modules/views/src/Plugin/views/area/Entity.php b/core/modules/views/src/Plugin/views/area/Entity.php index d1ae19f..982a004 100644 --- a/core/modules/views/src/Plugin/views/area/Entity.php +++ b/core/modules/views/src/Plugin/views/area/Entity.php @@ -9,6 +9,7 @@ use Drupal\Component\Uuid\Uuid; use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\Query\QueryFactory; use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\ViewExecutable; @@ -38,6 +39,13 @@ class Entity extends TokenizeAreaPluginBase { protected $entityManager; /** + * The entity query factory. + * + * @var \Drupal\Core\Entity\Query\QueryFactory + */ + protected $queryFactory; + + /** * Constructs a new Entity instance. * * @param array $configuration @@ -48,11 +56,14 @@ class Entity extends TokenizeAreaPluginBase { * The plugin implementation definition. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. + * @param \Drupal\Core\Entity\Query\QueryFactory $query_factory + * The entity query factory. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager, QueryFactory $query_factory) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->entityManager = $entity_manager; + $this->queryFactory = $query_factory; } /** @@ -166,9 +177,12 @@ public function render($empty = FALSE) { protected function loadEntityByIdOrUuid($entity_id_uuid) { $entity_storage = $this->entityManager->getStorage($this->entityType); $is_uuid = Uuid::isValid($entity_id_uuid); - if ((!$is_uuid && $entity = $entity_storage->load($entity_id_uuid)) || ($entities = $entity_storage->loadByProperties(['uuid' => $entity_id_uuid])) && ($entity = reset($entities))) { - return $entity; + if ($is_uuid) { + $result = $this->queryFactory->get($this->entityType)->condition('uuid', $entity_id_uuid) + ->execute(); + $entity_id_uuid = reset($result); } + return $entity_storage->load($entity_id_uuid); }