diff -u b/core/modules/views/lib/Drupal/views/Plugin/views/area/Entity.php b/core/modules/views/lib/Drupal/views/Plugin/views/area/Entity.php --- b/core/modules/views/lib/Drupal/views/Plugin/views/area/Entity.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/area/Entity.php @@ -47,6 +47,7 @@ $options['entity_id'] = array('default' => ''); $options['view_mode'] = array('default' => ''); + $options['tokenize'] = array('default' => TRUE, 'bool' => TRUE); return $options; } @@ -92,9 +93,14 @@ */ function render($empty = FALSE) { if (!$empty || !empty($this->options['empty'])) { - $entity_id = $this->globalTokenReplace($this->options['entity_id']); + $entity_id = $this->options['entity_id']; + if ($this->options['tokenize']) { + $entity_id = $this->view->style_plugin->tokenize_value($entity_id, 0); + } + $entity_id = $this->globalTokenReplace($entity_id); if ($entity = entity_load($this->entityType, $entity_id)) { $build = entity_view($entity, $this->options['view_mode']); + // @todo Support to just return a render array. return drupal_render($build); } } diff -u b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaEntityTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaEntityTest.php --- b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaEntityTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaEntityTest.php @@ -77,16 +77,25 @@ * Tests the area handler. */ public function testEntityArea() { - $random_label = $this->randomName(); - $data = array('bundle' => 'entity_test_render', 'name' => $random_label); - $entity_test = $this->container->get('plugin.manager.entity')->getStorageController('entity_test_render')->create($data); - $entity_test->save(); + + $entities = array(); + for ($i = 0; $i < 2; $i++) { + $random_label = $this->randomName(); + $data = array('bundle' => 'entity_test_render', 'name' => $random_label); + $entity_test = $this->container->get('plugin.manager.entity')->getStorageController('entity_test_render')->create($data); + $entity_test->save(); + $entities[] = $entity_test; + } $view = views_get_view('test_entity_area'); - $this->drupalSetContent($view->preview()); + $this->drupalSetContent($view->preview('default', array($entities[1]->id()))); $result = $this->xpath('//div[@class = "view-header"]'); - $this->assertTrue(strpos(trim((string) $result[0]), $random_label) !== FALSE, 'The rendered entity appears in the header of the view.'); + $this->assertTrue(strpos(trim((string) $result[0]), $entities[0]->label()) !== FALSE, 'The rendered entity appears in the header of the view.'); + $this->assertTrue(strpos(trim((string) $result[0]), 'full') !== FALSE, 'The rendered entity appeared in the right view mode.'); + + $result = $this->xpath('//div[@class = "view-footer"]'); + $this->assertTrue(strpos(trim((string) $result[0]), $entities[1]->label()) !== FALSE, 'The rendered entity appears in the header of the view.'); $this->assertTrue(strpos(trim((string) $result[0]), 'full') !== FALSE, 'The rendered entity appeared in the right view mode.'); // Change the view mode of the area handler. @@ -95,12 +104,11 @@ $item['view_mode'] = 'test'; $view->setItem('default', 'header', 'entity_entity_test_render', $item); - $this->drupalSetContent($view->preview()); + $this->drupalSetContent($view->preview('default', array($entities[1]->id()))); $result = $this->xpath('//div[@class = "view-header"]'); - $this->assertTrue(strpos(trim((string) $result[0]), $random_label) !== FALSE, 'The rendered entity appears in the header of the view.'); + $this->assertTrue(strpos(trim((string) $result[0]), $entities[0]->label()) !== FALSE, 'The rendered entity appears in the header of the view.'); $this->assertTrue(strpos(trim((string) $result[0]), 'test') !== FALSE, 'The rendered entity appeared in the right view mode.'); - } } diff -u b/core/modules/views/tests/views_test_config/test_views/views.view.test_entity_area.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_entity_area.yml --- b/core/modules/views/tests/views_test_config/test_views/views.view.test_entity_area.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_entity_area.yml @@ -18,6 +18,14 @@ entity_id: 1 view_mode: full plugin_id: entity + footer: + entity_entity_test_render: + field: entity_entity_test_render + id: entity_entity_test_render + table: views + entity_id: !1 + view_mode: full + plugin_id: entity fields: id: field: id @@ -25,6 +33,12 @@ relationship: none table: views_test_data plugin_id: numeric + arguments: + id: + id: id + table: views_test_data + field: id + plugin_id: numeric pager: options: offset: '0'