You are here

public function ReportReplacer::replaceNested in Forena Reports 8

Replaces nested array data.

Parameters

$data: The array containing values to replace.

$raw: TRUE implies no formatting of data.

1 call to ReportReplacer::replaceNested()
ReportReplacer::format in src/Token/ReportReplacer.php

File

src/Token/ReportReplacer.php, line 43

Class

ReportReplacer

Namespace

Drupal\forena\Token

Code

public function replaceNested(&$data, $raw = TRUE) {
  if (is_array($data)) {
    $values = $data;
    foreach ($values as $k => $value) {

      // Replace key data
      $key = $k;
      if (strpos($k, '{') !== FALSE) {
        $key = $this
          ->replace($key);
        unset($data[$k]);
        $data[$key] = $value;
      }

      // Replace value data.
      if (is_array($value)) {
        $this
          ->replaceNested($data[$key], $raw);
      }
      else {
        $data[$key] = $this
          ->replace($value, $raw);
      }
    }
  }
  else {
    $data = $this
      ->replace($data, $raw);
  }
}