You are here

public function Report::getField in Forena Reports 8

Same name and namespace in other branches
  1. 7.5 src/Report.php \Drupal\forena\Report::getField()

File

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

Class

Report

Namespace

Drupal\forena

Code

public function getField($id) {
  $field = array_fill_keys(array(
    'default',
    'link',
    'add-query',
    'class',
    'rel',
    'format',
    'format-string',
    'target',
    'calc',
    'context',
  ), '');
  if ($this->fields) {
    $path = 'frx:field[@id="' . $id . '"]';
    $formatters = $this->fields
      ->xpath($path);
    if ($formatters) {
      $formatter = $formatters[0];

      //@TODO: Replace the default extraction with something that will get sub elements of the string
      $field['default'] = (string) $formatter;
      $field['link'] = (string) $formatter['link'];
      $field['add-query'] = (string) $formatter['add-query'];
      $field['class'] = (string) $formatter['class'];
      $field['rel'] = (string) $formatter['rel'];
      $field['format'] = (string) $formatter['format'];
      $field['format-string'] = (string) $formatter['format-string'];
      $field['target'] = (string) $formatter['target'];
      $field['calc'] = (string) $formatter['calc'];
    }
  }
  return $field;
}