Skip to content
Snippets Groups Projects
Commit 0287e533 authored by catch's avatar catch
Browse files

Issue #2864922 by vaplas, dawehner, Lendude:...

Issue #2864922 by vaplas, dawehner, Lendude: \Drupal\views\Plugin\views\display\EntityReference::render returns the wrong datatype for empty results
parent 89605308
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -90,13 +90,16 @@ public function execute() { ...@@ -90,13 +90,16 @@ public function execute() {
} }
/** /**
* {@inheritdoc} * Builds the view result as a renderable array.
*
* @return array
* Renderable array or empty array.
*/ */
public function render() { public function render() {
if (!empty($this->view->result) && $this->view->style_plugin->evenEmpty()) { if (!empty($this->view->result) && $this->view->style_plugin->evenEmpty()) {
return $this->view->style_plugin->render($this->view->result); return $this->view->style_plugin->render($this->view->result);
} }
return ''; return [];
} }
/** /**
......
...@@ -249,6 +249,12 @@ public function testEntityReferenceDisplay() { ...@@ -249,6 +249,12 @@ public function testEntityReferenceDisplay() {
$this->executeView($view); $this->executeView($view);
$this->assertEqual(count($view->result), 2, 'Search returned two rows'); $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');
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment