You are here

protected function Record::populateRow in Views OAI-PMH 8

Return a formatted row value in array with all values as cartesian product of rows

Parameters

ResultRow $row:

Return value

array

1 call to Record::populateRow()
Record::getResultRows in src/Plugin/views/style/Record.php
Get result that view expose as cartesian product removing duplicates tuples

File

src/Plugin/views/style/Record.php, line 421

Class

Record
Plugin annotation @ViewsStyle( id = "views_oai_pmh_record", title = @Translation("OAI-PMH"), help = @Translation("Displays rows in OAI-PMH records."), display_types = {"oai_pmh"} )

Namespace

Drupal\views_oai_pmh\Plugin\views\style

Code

protected function populateRow($row_id, ResultRow $row) : array {
  $output = [];
  foreach ($this->view->field as $id => $field) {
    try {
      $value = $this->view->style_plugin
        ->getField($row_id, $id);
      if ($field->option['hide_empty'] && empty($value)) {
        continue;
      }
      if (isset($field->option['type']) && $field->options['type'] == "datetime_default") {
        $value = \Drupal::service('date.formatter')
          ->format(strtotime($value), $field->options['settings']['format_type']);
      }
    } catch (\TypeError $e) {

      // If relations are NULL's.
      $value = false;
    } catch (\InvalidArgumentException $e) {

      // If an invalid value was passed to format()
      $value = false;
    }
    if (($alias = $this
      ->getFieldKeyAlias($id)) && $value) {
      if (array_key_exists($alias, $output)) {
        $output[$alias] = $this
          ->convert($output[$alias], $value);
      }
      else {
        $output[$alias] = $value;
      }
    }
  }
  return $output;
}