diff --git a/core/modules/views/src/Plugin/views/area/Entity.php b/core/modules/views/src/Plugin/views/area/Entity.php index d1ae19f..931dbfa 100644 --- a/core/modules/views/src/Plugin/views/area/Entity.php +++ b/core/modules/views/src/Plugin/views/area/Entity.php @@ -111,8 +111,6 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { '#title' => $this->t('@entity_type_label ID or UUID', ['@entity_type_label' => $label]), '#type' => 'textfield', '#default_value' => $this->options['entity_id_uuid'], - '#autocomplete_route_name' => 'system.entity_autocomplete', - '#autocomplete_route_parameters' => ['entity_type' => $this->entityType], ]; $form['bypass_access'] = array( @@ -126,13 +124,15 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { /** * {@inheritdoc} */ - public function submitOptionsForm(&$form, FormStateInterface $form_state, &$options = []) { + public function submitOptionsForm(&$form, FormStateInterface $form_state) { parent::submitOptionsForm($form, $form_state); // Always try to store the UUID, if possible. + $options = $form_state->getValue('options'); if ($entity = $this->entityManager->getStorage($this->entityType)->load($options['entity_id_uuid'])) { $options['entity_id_uuid'] = $entity->uuid(); } + $form_state->setValue('options', $options); } /** @@ -142,8 +142,6 @@ public function render($empty = FALSE) { if (!$empty || !empty($this->options['empty'])) { $entity_id_uuid = $this->tokenizeValue($this->options['entity_id_uuid']); - // Validate whether the ID is a UUID, in that case load the entity by UUID - // otherwise use the ID. if ($entity = $this->loadEntityByIdOrUuid($entity_id_uuid)) { if (!empty($this->options['bypass_access']) || $entity->access('view')) { $view_builder = $this->entityManager->getViewBuilder($this->entityType); @@ -165,6 +163,9 @@ public function render($empty = FALSE) { */ protected function loadEntityByIdOrUuid($entity_id_uuid) { $entity_storage = $this->entityManager->getStorage($this->entityType); + + // Validate whether the ID is a UUID, in that case load the entity by UUID + // otherwise use the ID. $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;