You are here

function podcast_preprocess_views_view_rss in Podcast (using Views) 8

Implements hook_preprocess_HOOK().

File

./podcast.module, line 31
Primary module hooks for the podcast module.

Code

function podcast_preprocess_views_view_rss(&$variables) {
  $view = $variables['view'];

  /** @var \Drupal\views\Plugin\views\style\StylePluginBase $style */
  $style = $view->style_plugin;
  if (!$style instanceof Rss) {
    return;
  }
  unset($variables['title']);
  unset($variables['description']);
  unset($variables['link']);
  $variables['podcast_elements'] = [];
  $podcast_elements = is_array($style->podcast_elements) ? $style->podcast_elements : [];
  foreach (Element::children($podcast_elements) as $k) {
    $element = $podcast_elements[$k];
    if (isset($element['attributes']) && is_array($element['attributes'])) {
      $element['attributes'] = new Attribute($element['attributes']);
    }
    if (!empty($element['key'])) {
      if (empty($element['value']) && !empty($element['values'])) {
        podcast_process_nested_channel_element($element);
      }
      $variables['podcast_elements'][] = $element;
    }
  }
}