You are here

public function ReportFileSystem::extractMetaData in Forena Reports 8

Should load cache data based on that.

Overrides FileInterface::extractMetaData

See also

FrxFile::buildCache()

File

src/File/ReportFileSystem.php, line 240

Class

ReportFileSystem

Namespace

Drupal\forena\File

Code

public function extractMetaData(&$object) {
  switch ($object->ext) {
    case 'frx':
      $r_xml = file_get_contents($object->file);
      $r = $this
        ->createReport($r_xml);

      // Save language info
      $lang = 'en';
      if ($this
        ->localeEnabled()) {
        @(list($tlang, $tname) = explode('/', $object->basename, 2));
        if (array_key_exists($tlang, locale_translatable_language_list())) {
          $lang = $tlang;
        }
      }

      // Get the security caches from the reports
      $cache = [];
      if ($r->rpt_xml) {
        $cache['title'] = $r->title;
        $cache['language'] = $lang;
        $cache['category'] = $r->category;
        $cache['hidden'] = @$r->options['hidden'];
        $cache['access'] = $r->access;
      }
      $object->metaData = $cache;
      if ($r) {
        $r
          ->__destruct();
      }
      unset($r);
      break;
    case 'skin.yml':
      $object->metaData = Skin::parseYml(file_get_contents($object->file));
      break;
  }
}