You are here

public function EntityReferenceRevisions::validate in Entity Reference Revisions 8

Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase::validate().

Overrides DisplayPluginBase::validate

File

src/Plugin/views/display/EntityReferenceRevisions.php, line 159

Class

EntityReferenceRevisions
The plugin that handles an EntityReferenceRevisions display.

Namespace

Drupal\entity_reference_revisions\Plugin\views\display

Code

public function validate() {
  $errors = parent::validate();

  // Verify that search fields are set up.
  $style = $this
    ->getOption('style');
  if (!isset($style['options']['search_fields'])) {
    $errors[] = $this
      ->t('Display "@display" needs a selected search fields to work properly. See the settings for the Entity Reference Revisions list format.', array(
      '@display' => $this->display['display_title'],
    ));
  }
  else {

    // Verify that the search fields used actually exist.
    $fields = array_keys($this->handlers['field']);
    foreach ($style['options']['search_fields'] as $field_alias => $enabled) {
      if ($enabled && !in_array($field_alias, $fields)) {
        $errors[] = $this
          ->t('Display "@display" uses field %field as search field, but the field is no longer present. See the settings for the Entity Reference Revisions list format.', array(
          '@display' => $this->display['display_title'],
          '%field' => $field_alias,
        ));
      }
    }
  }
  return $errors;
}