Issue #2864922 by vaplas, dawehner, Lendude: \Drupal\views\Plugin\views\display\EntityReference::render returns the wrong datatype for empty results
parent
89605308b1
commit
0287e533ac
|
@ -90,13 +90,16 @@ class EntityReference extends DisplayPluginBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* Builds the view result as a renderable array.
|
||||
*
|
||||
* @return array
|
||||
* Renderable array or empty array.
|
||||
*/
|
||||
public function render() {
|
||||
if (!empty($this->view->result) && $this->view->style_plugin->evenEmpty()) {
|
||||
return $this->view->style_plugin->render($this->view->result);
|
||||
}
|
||||
return '';
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -249,6 +249,12 @@ class DisplayEntityReferenceTest extends ViewTestBase {
|
|||
$this->executeView($view);
|
||||
|
||||
$this->assertEqual(count($view->result), 2, 'Search returned two rows');
|
||||
|
||||
// Test that the render() return empty array for empty result.
|
||||
$view = Views::getView('test_display_entity_reference');
|
||||
$view->setDisplay('entity_reference_1');
|
||||
$render = $view->display_handler->render();
|
||||
$this->assertSame([], $render, 'Render returned empty array');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue