You are here

public function RssFields::validate in Views RSS 8.2

Same name in this branch
  1. 8.2 src/Plugin/views/style/RssFields.php \Drupal\views_rss\Plugin\views\style\RssFields::validate()
  2. 8.2 src/Plugin/views/row/RssFields.php \Drupal\views_rss\Plugin\views\row\RssFields::validate()
Same name and namespace in other branches
  1. 8.3 src/Plugin/views/row/RssFields.php \Drupal\views_rss\Plugin\views\row\RssFields::validate()

Validates whether views_rss_core module exists or not.

Overrides PluginBase::validate

File

src/Plugin/views/row/RssFields.php, line 134

Class

RssFields
Renders an RSS item based on fields.

Namespace

Drupal\views_rss\Plugin\views\row

Code

public function validate() {
  $errors = parent::validate();
  if (!\Drupal::moduleHandler()
    ->moduleExists('views_rss_core')) {
    $errors[] = $this
      ->t('You have to enable <em>Views RSS: Core Elements</em> module to have access to basic feed elements.');
  }
  else {

    // An item MUST contain either a title or description.
    // All other elements are optional according to RSS specification.
    if (empty($this->options['item']['core']['views_rss_core']['title']) && empty($this->options['item']['core']['views_rss_core']['description'])) {
      $errors[] = $this
        ->t('You have to configure either <em>title</em> or <em>description</em> core element.');
    }
  }
  return $errors;
}