public function DisplayPluginBase::validate in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::validate()
Validate that the plugin is correct and can be saved.
Return value
An array of error strings to tell the user what is wrong with this plugin.
Overrides PluginBase::validate
3 calls to DisplayPluginBase::validate()
- DisplayTest::validate in core/
modules/ views/ tests/ modules/ views_test_data/ src/ Plugin/ views/ display/ DisplayTest.php - Validate that the plugin is correct and can be saved.
- EntityReference::validate in core/
modules/ views/ src/ Plugin/ views/ display/ EntityReference.php - Validate that the plugin is correct and can be saved.
- PathPluginBase::validate in core/
modules/ views/ src/ Plugin/ views/ display/ PathPluginBase.php - Validate that the plugin is correct and can be saved.
3 methods override DisplayPluginBase::validate()
- DisplayTest::validate in core/
modules/ views/ tests/ modules/ views_test_data/ src/ Plugin/ views/ display/ DisplayTest.php - Validate that the plugin is correct and can be saved.
- EntityReference::validate in core/
modules/ views/ src/ Plugin/ views/ display/ EntityReference.php - Validate that the plugin is correct and can be saved.
- PathPluginBase::validate in core/
modules/ views/ src/ Plugin/ views/ display/ PathPluginBase.php - Validate that the plugin is correct and can be saved.
File
- core/
modules/ views/ src/ Plugin/ views/ display/ DisplayPluginBase.php, line 2399 - Contains \Drupal\views\Plugin\views\display\DisplayPluginBase.
Class
- DisplayPluginBase
- Base class for views display plugins.
Namespace
Drupal\views\Plugin\views\displayCode
public function validate() {
$errors = array();
// Make sure displays that use fields HAVE fields.
if ($this
->usesFields()) {
$fields = FALSE;
foreach ($this
->getHandlers('field') as $field) {
if (empty($field->options['exclude'])) {
$fields = TRUE;
}
}
if (!$fields) {
$errors[] = $this
->t('Display "@display" uses fields but there are none defined for it or all are excluded.', array(
'@display' => $this->display['display_title'],
));
}
}
// Validate the more link.
if ($this
->isMoreEnabled() && $this
->getOption('link_display') !== 'custom_url') {
$routed_display = $this
->getRoutedDisplay();
if (!$routed_display || !$routed_display
->isEnabled()) {
$errors[] = $this
->t('Display "@display" uses a "more" link but there are no displays it can link to. You need to specify a custom URL.', array(
'@display' => $this->display['display_title'],
));
}
}
if ($this
->hasPath() && !$this
->getOption('path')) {
$errors[] = $this
->t('Display "@display" uses a path but the path is undefined.', array(
'@display' => $this->display['display_title'],
));
}
// Validate style plugin.
$style = $this
->getPlugin('style');
if (empty($style)) {
$errors[] = $this
->t('Display "@display" has an invalid style plugin.', array(
'@display' => $this->display['display_title'],
));
}
else {
$result = $style
->validate();
if (!empty($result) && is_array($result)) {
$errors = array_merge($errors, $result);
}
}
// Validate query plugin.
$query = $this
->getPlugin('query');
$result = $query
->validate();
if (!empty($result) && is_array($result)) {
$errors = array_merge($errors, $result);
}
// Validate handlers.
foreach (ViewExecutable::getHandlerTypes() as $type => $info) {
foreach ($this
->getHandlers($type) as $handler) {
$result = $handler
->validate();
if (!empty($result) && is_array($result)) {
$errors = array_merge($errors, $result);
}
}
}
return $errors;
}