function OpmlFields::render

Same name in other branches
  1. 8.9.x core/modules/views/src/Plugin/views/row/OpmlFields.php \Drupal\views\Plugin\views\row\OpmlFields::render()
  2. 10 core/modules/views/src/Plugin/views/row/OpmlFields.php \Drupal\views\Plugin\views\row\OpmlFields::render()
  3. 11.x core/modules/views/src/Plugin/views/row/OpmlFields.php \Drupal\views\Plugin\views\row\OpmlFields::render()

Overrides RowPluginBase::render

File

core/modules/views/src/Plugin/views/row/OpmlFields.php, line 172

Class

OpmlFields
Renders an OPML item based on fields.

Namespace

Drupal\views\Plugin\views\row

Code

public function render($row) {
    // Create the OPML item array.
    $item = [];
    $row_index = $this->view->row_index;
    $item['text'] = $this->getField($row_index, $this->options['text_field']);
    $item['created'] = $this->getField($row_index, $this->options['created_field']);
    if ($this->options['type_field']) {
        $item['type'] = $this->options['type_field'];
        if ($item['type'] == 'rss') {
            $item['description'] = $this->getField($row_index, $this->options['description_field']);
            $item['language'] = $this->getField($row_index, $this->options['language_field']);
            $item['xmlUrl'] = $this->getField($row_index, $this->options['xml_url_field']);
            $item['htmlUrl'] = $this->getField($row_index, $this->options['html_url_field']);
        }
        else {
            $item['url'] = $this->getField($row_index, $this->options['url_field']);
        }
    }
    // Remove empty attributes.
    $item = array_filter($item);
    $build = [
        '#theme' => $this->themeFunctions(),
        '#view' => $this->view,
        '#options' => $this->options,
        '#row' => $item,
        '#field_alias' => $this->field_alias ?? '',
    ];
    return $build;
}

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