function Rss::render

Same name in this branch
  1. 11.x core/modules/node/src/Plugin/views/row/Rss.php \Drupal\node\Plugin\views\row\Rss::render()
  2. 11.x core/modules/comment/src/Plugin/views/row/Rss.php \Drupal\comment\Plugin\views\row\Rss::render()
Same name and namespace in other branches
  1. 9 core/modules/node/src/Plugin/views/row/Rss.php \Drupal\node\Plugin\views\row\Rss::render()
  2. 9 core/modules/views/src/Plugin/views/style/Rss.php \Drupal\views\Plugin\views\style\Rss::render()
  3. 9 core/modules/aggregator/src/Plugin/views/row/Rss.php \Drupal\aggregator\Plugin\views\row\Rss::render()
  4. 9 core/modules/comment/src/Plugin/views/row/Rss.php \Drupal\comment\Plugin\views\row\Rss::render()
  5. 8.9.x core/modules/node/src/Plugin/views/row/Rss.php \Drupal\node\Plugin\views\row\Rss::render()
  6. 8.9.x core/modules/views/src/Plugin/views/style/Rss.php \Drupal\views\Plugin\views\style\Rss::render()
  7. 8.9.x core/modules/aggregator/src/Plugin/views/row/Rss.php \Drupal\aggregator\Plugin\views\row\Rss::render()
  8. 8.9.x core/modules/comment/src/Plugin/views/row/Rss.php \Drupal\comment\Plugin\views\row\Rss::render()
  9. 10 core/modules/node/src/Plugin/views/row/Rss.php \Drupal\node\Plugin\views\row\Rss::render()
  10. 10 core/modules/views/src/Plugin/views/style/Rss.php \Drupal\views\Plugin\views\style\Rss::render()
  11. 10 core/modules/comment/src/Plugin/views/row/Rss.php \Drupal\comment\Plugin\views\row\Rss::render()

Overrides StylePluginBase::render

File

core/modules/views/src/Plugin/views/style/Rss.php, line 111

Class

Rss
Default style plugin to render an RSS feed.

Namespace

Drupal\views\Plugin\views\style

Code

public function render() {
    $rows = [];
    // This will be filled in by the row plugin and is used later on in the
    // theming output.
    $this->namespaces = [
        'xmlns:dc' => 'http://purl.org/dc/elements/1.1/',
    ];
    // Fetch any additional elements for the channel and merge in their
    // namespaces.
    $this->channel_elements = $this->getChannelElements();
    foreach ($this->channel_elements as $element) {
        if (isset($element['namespace'])) {
            $this->namespaces = array_merge($this->namespaces, $element['namespace']);
        }
    }
    foreach ($this->view->result as $row_index => $row) {
        $this->view->row_index = $row_index;
        $rows[] = $this->view->rowPlugin
            ->render($row);
    }
    $build = [
        '#theme' => $this->themeFunctions(),
        '#view' => $this->view,
        '#options' => $this->options,
        '#rows' => $rows,
        '#attached' => [
            'http_header' => [
                [
                    'Content-Type',
                    'application/rss+xml; charset=utf-8',
                ],
            ],
        ],
    ];
    unset($this->view->row_index);
    return $build;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.