Commit b659cbd9 authored by alexpott's avatar alexpott

Issue #2967567 by WalkingDexter, borisson_, catch, dawehner, Lendude: Views...

Issue #2967567 by WalkingDexter, borisson_, catch, dawehner, Lendude: Views display extenders validation
parent 44664acf
......@@ -2479,6 +2479,14 @@ public function validate() {
}
}
// Validate extenders.
foreach ($this->extenders as $extender) {
$result = $extender->validate();
if (!empty($result) && is_array($result)) {
$errors = array_merge($errors, $result);
}
}
return $errors;
}
......
<?php
namespace Drupal\views_test_data\Plugin\views\display_extender;
/**
* Defines the third display extender test plugin.
*
* @ViewsDisplayExtender(
* id = "display_extender_test_3",
* title = @Translation("Display extender test number three")
* )
*/
class DisplayExtenderTest3 extends DisplayExtenderTest {
/**
* {@inheritdoc}
*/
public function validate() {
return ['Display extender test error.'];
}
}
......@@ -42,4 +42,18 @@ public function testDisplayExtenders() {
$this->assertTrue($display_extender->testState['query'], 'Make sure the display extender was able to react on query.');
}
/**
* Test display extenders validation.
*/
public function testDisplayExtendersValidate() {
$this->config('views.settings')->set('display_extenders', ['display_extender_test_3'])->save();
$view = Views::getView('test_view');
$errors = $view->validate();
foreach ($view->displayHandlers as $id => $display) {
$this->assertTrue(isset($errors[$id]) && in_array('Display extender test error.', $errors[$id]), format_string('Error message found for @id display', ['@id' => $id]));
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment