You are here

public function DataFieldRow::render in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/rest/src/Plugin/views/row/DataFieldRow.php \Drupal\rest\Plugin\views\row\DataFieldRow::render()
  2. 9 core/modules/rest/src/Plugin/views/row/DataFieldRow.php \Drupal\rest\Plugin\views\row\DataFieldRow::render()

File

core/modules/rest/src/Plugin/views/row/DataFieldRow.php, line 136

Class

DataFieldRow
Plugin which displays fields as raw data.

Namespace

Drupal\rest\Plugin\views\row

Code

public function render($row) {
  $output = [];
  foreach ($this->view->field as $id => $field) {

    // If the raw output option has been set, just get the raw value.
    if (!empty($this->rawOutputOptions[$id])) {
      $value = $field
        ->getValue($row);
    }
    else {

      // Advanced render for token replacement.
      $markup = $field
        ->advancedRender($row);

      // Post render to support uncacheable fields.
      $field
        ->postRender($row, $markup);
      $value = $field->last_render;
    }

    // Omit excluded fields from the rendered output.
    if (empty($field->options['exclude'])) {
      $output[$this
        ->getFieldKeyAlias($id)] = $value;
    }
  }
  return $output;
}