You are here

public function Report::extractDefinitions in Forena Reports 8

Helper

Parameters

$nodes:

string $key_attribute:

string $value_key:

Return value

array key value pairs of defining attributes.

1 call to Report::extractDefinitions()
Report::setReport in src/Report.php
Sets the report.

File

src/Report.php, line 783
Basic report provider. Controls the rendering of the report.

Class

Report

Namespace

Drupal\forena

Code

public function extractDefinitions($nodes, $key_attribute = 'id', $value_key = '') {
  $definitions = [];

  /** @var \SimpleXMLElement $node */
  foreach ($nodes as $node) {
    $id = (string) $node[$key_attribute];
    $definition = [];
    foreach ($node
      ->attributes() as $key => $value) {
      if ($key != $key_attribute) {
        $definition[$key] = (string) $value;
      }
    }
    if ($value_key) {
      $definition[$value_key] = (string) $node;
    }
    $definitions[$id] = $definition;
  }
  return $definitions;
}