You are here

protected function FormatRowToXml::buildValues in Views OAI-PMH 8

Compose end values

Parameters

$value:

Return value

array

1 call to FormatRowToXml::buildValues()
FormatRowToXml::transform in src/Service/FormatRowToXml.php
Transform views rows data to array composer for xml for this view row

File

src/Service/FormatRowToXml.php, line 28

Class

FormatRowToXml

Namespace

Drupal\views_oai_pmh\Service

Code

protected function buildValues($value) {
  $output = [];
  if (is_array($value)) {
    $i = 0;
    $eval_output = false;
    foreach ($value as $items) {
      if (is_array($items)) {
        if (count($items) === 1) {
          $end = $items[0];
        }
        else {
          $end = $items;
          $j = $i;
          foreach ($items as $item) {
            $output[" {$j}"] = [
              '#' => $item,
            ];
            $j++;
          }
          $eval_output = true;
        }
      }
      else {
        $end = $items;
      }
      if (!$eval_output) {
        $output[" {$i}"] = [
          '#' => $end,
        ];
      }
      $i++;
    }
  }
  else {
    $output['#'] = $value;
  }
  return $output;
}