diff --git a/core/modules/views/src/Plugin/views/area/Entity.php b/core/modules/views/src/Plugin/views/area/Entity.php index a452ff9..2a6acad 100644 --- a/core/modules/views/src/Plugin/views/area/Entity.php +++ b/core/modules/views/src/Plugin/views/area/Entity.php @@ -114,7 +114,9 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { // If the target does not contain tokens, try to load the entity and // display the entity ID to the admin form user. - if (!$this->view->getStyle()->hasToken($this->options['target'])) { + // @todo Use a method to check for tokens in + // https://www.drupal.org/node/2396607. + if (strpos($this->options['target'], '{{') === FALSE || strpos($this->options['target'], '!') === FALSE || strpos($this->options['target'], '%') === FALSE) { // @todo If the entity does not exist, this will will show the config // target identifier. Is that the correct behavior? if ($target_entity = $this->entityManager->loadEntityByConfigTarget($this->entityType, $this->options['target'])) { @@ -145,7 +147,9 @@ public function submitOptionsForm(&$form, FormStateInterface $form_state) { // Load the referenced entity and store its config target identifier if // the target does not contains tokens. - if (!$this->view->getStyle()->hasToken($this->options['target'])) { + // @todo Use a method to check for tokens in + // https://www.drupal.org/node/2396607. + if (strpos($this->options['target'], '{{') === FALSE || strpos($this->options['target'], '!') === FALSE || strpos($this->options['target'], '%') === FALSE) { $options = $form_state->getValue('options'); if ($entity = $this->entityManager->getStorage($this->entityType)->load($options['target'])) { $options['target'] = $entity->getConfigTarget(); @@ -160,7 +164,9 @@ public function submitOptionsForm(&$form, FormStateInterface $form_state) { public function render($empty = FALSE) { // @todo Simplify this code. if (!$empty || !empty($this->options['empty'])) { - if ($this->view->getStyle()->hasToken($this->options['target'])) { + // @todo Use a method to check for tokens in + // https://www.drupal.org/node/2396607. + if (strpos($this->options['target'], '{{') !== FALSE || strpos($this->options['target'], '!') !== FALSE || strpos($this->options['target'], '%') !== FALSE) { $target_id = $this->tokenizeValue($this->options['target']); if ($entity = $this->entityManager->getStorage($this->entityType)->load($target_id)) { $target_entity = $entity; @@ -188,7 +194,9 @@ public function calculateDependencies() { // Ensure that we don't add dependencies for placeholders. // @todo No tests fail even if this never is false; add coverage. - if (!$this->view->getStyle()->hasToken($this->options['target'])) { + // @todo Use a method to check for tokens in + // https://www.drupal.org/node/2396607. + if (strpos($this->options['target'], '{{') === FALSE || strpos($this->options['target'], '!') === FALSE || strpos($this->options['target'], '%') === FALSE) { if ($entity = $this->entityManager->loadEntityByConfigTarget($this->entityType, $this->options['target'])) { $dependencies[$this->entityManager->getDefinition($this->entityType)->getConfigDependencyKey()][] = $entity->getConfigDependencyName(); } diff --git a/core/modules/views/tests/src/Unit/Plugin/area/EntityTest.php b/core/modules/views/tests/src/Unit/Plugin/area/EntityTest.php index b4cb957..a859fab 100644 --- a/core/modules/views/tests/src/Unit/Plugin/area/EntityTest.php +++ b/core/modules/views/tests/src/Unit/Plugin/area/EntityTest.php @@ -178,10 +178,6 @@ public function testRenderWithIdAndToken() { ->method('tokenizeValue') ->with('!1', 0) ->willReturn(5); - $this->stylePlugin->expects($this->once()) - ->method('hasToken') - ->with('!1') - ->willReturn(TRUE); $this->entityStorage->expects($this->never()) ->method('loadByProperties');