diff --git a/core/lib/Drupal/Core/Entity/EntityAutocomplete.php b/core/lib/Drupal/Core/Entity/EntityAutocomplete.php index 30647bb..9b74b69 100644 --- a/core/lib/Drupal/Core/Entity/EntityAutocomplete.php +++ b/core/lib/Drupal/Core/Entity/EntityAutocomplete.php @@ -10,7 +10,7 @@ use Drupal\Core\Entity\Query\QueryFactory; /** - * Provides a generic autocompletion service, + * Provides a generic entity autocompletion service, */ class EntityAutocomplete { @@ -29,7 +29,7 @@ class EntityAutocomplete { protected $entityManager; /** - * Constructs a UserAutocomplete object. + * Constructs a EntityAutocomplete object. * * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. diff --git a/core/modules/system/system.routing.yml b/core/modules/system/system.routing.yml index 1e49291..4222345 100644 --- a/core/modules/system/system.routing.yml +++ b/core/modules/system/system.routing.yml @@ -458,7 +458,7 @@ system.admin_content: _permission: 'access administration pages' system.entity_autocomplete: - path: '/entity_autocomplete/{entity_type}' + path: '/system/entity_autocomplete/{entity_type}' defaults: _controller: '\Drupal\system\Controller\EntityAutocompleteController::autocompleteEntity' requirements: diff --git a/core/modules/views/src/Plugin/views/area/Entity.php b/core/modules/views/src/Plugin/views/area/Entity.php index 87097e2..6caff2b 100644 --- a/core/modules/views/src/Plugin/views/area/Entity.php +++ b/core/modules/views/src/Plugin/views/area/Entity.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\area; +use Drupal\Component\Uuid\Uuid; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\display\DisplayPluginBase; @@ -30,6 +31,13 @@ class Entity extends TokenizeAreaPluginBase { protected $entityType; /** + * The entity manager. + * + * @var \Drupal\Core\Entity\EntityManagerInterface + */ + protected $entityManager; + + /** * Constructs a new Entity instance. * * @param array $configuration @@ -99,8 +107,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { ); $form['entity_id_uuid'] = [ - '#title' => $this->t('ID / UUID'), - '#description' => $this->t('You can put in either the entity ID or the UUID'), + '#title' => $this->t('Entity ID or UUID'), '#type' => 'textfield', '#default_value' => $this->options['entity_id_uuid'], '#autocomplete_route_name' => 'system.entity_autocomplete', @@ -136,7 +143,8 @@ public function render($empty = FALSE) { $entity_storage = $this->entityManager->getStorage($this->entityType); $view_builder = $this->entityManager->getViewBuilder($this->entityType); // Try to load by ID and then by UUID. - if (($entity = $entity_storage->load($entity_id_uuid)) || (($entities = $entity_storage->loadByProperties(['uuid' => $entity_id_uuid])) && ($entity = reset($entities)))) { + $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))) { if (!empty($this->options['bypass_access']) || $entity->access('view')) { return $view_builder->view($entity, $this->options['view_mode']); }