You are here

public function OpmlFields::validate in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Plugin/views/row/OpmlFields.php \Drupal\views\Plugin\views\row\OpmlFields::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

File

core/modules/views/src/Plugin/views/row/OpmlFields.php, line 154
Contains \Drupal\views\Plugin\views\row\OpmlFields.

Class

OpmlFields
Renders an OPML item based on fields.

Namespace

Drupal\views\Plugin\views\row

Code

public function validate() {
  $errors = parent::validate();
  if (empty($this->options['text_field'])) {
    $errors[] = $this
      ->t('Row style plugin requires specifying which views field to use for OPML text attribute.');
  }
  if (!empty($this->options['type_field'])) {
    if ($this->options['type_field'] == 'rss') {
      if (empty($this->options['xml_url_field'])) {
        $errors[] = $this
          ->t('Row style plugin requires specifying which views field to use for XML URL attribute.');
      }
    }
    elseif (in_array($this->options['type_field'], array(
      'link',
      'include',
    ))) {
      if (empty($this->options['url_field'])) {
        $errors[] = $this
          ->t('Row style plugin requires specifying which views field to use for URL attribute.');
      }
    }
  }
  return $errors;
}