You are here

class DataFileSystem in Forena Reports 8

Hierarchy

Expanded class hierarchy of DataFileSystem

8 files declare their use of DataFileSystem
DataManager.php in src/DataManager.php
DataManager.inc Enter description here ... @author davidmetzler
DriverBase.php in src/FrxPlugin/Driver/DriverBase.php
Class that defines default methods for access control in an DriverBase
FrxDrupal.php in src/FrxPlugin/Driver/FrxDrupal.php
Provides data blocks for native drupal connections using the default drupal connections.
FrxFiles.php in src/FrxPlugin/Driver/FrxFiles.php
File class for loading raw xml files as Sample data This class is used as a reference implementation of a data engine, but is also used to provide sample data files and reports. @author metzlerd
FrxMSSQL.php in src/FrxPlugin/Driver/FrxMSSQL.php
Oracle specific driver that takes advantage of oracles native XML support

... See full list

File

src/File/DataFileSystem.php, line 5

Namespace

Drupal\forena\File
View source
class DataFileSystem extends FileSystemBase {
  public $source = '';
  public $dmSvc;

  /**
   * @param $source
   *   Machine name of Data Source
   * @param $path
   *   Path to sql files for reports.
   * @param DataManager $dataManager
   *   Data Manager object used to get data
   */
  public function __construct($source, $path, DataManager $dataManager) {
    parent::__construct();
    $this->cacheKey = $this->cacheKey . ':' . $source;

    // Load default directory from configuration.
    $this->dmSvc = $dataManager;
    $this->source = $source;
    $data_path = AppService::instance()
      ->dataDirectory();
    $this->source = $source;
    $this->dir = rtrim($data_path, '/');
    $this->includes[] = $path;
  }

  /**
   * List all data blocks a sure has access to.
   *
   * @return array
   *   Array of data blocks.
   */
  public function userBlocks($search = '*') {
    $blocks = array();
    $this
      ->validateAllCache();
    $sql = $this
      ->getCache('sql');
    $inc = $this
      ->getCache('inc');
    $xml = $this
      ->getCache('xml');
    $data = array_merge($xml, $sql, $inc);
    if ($data) {
      foreach ($data as $base_name => $obj) {
        if ($search == '*' || drupal_match_path($base_name, $search)) {
          if ($obj->cache) {
            $r = $this->dmSvc
              ->repository($obj->cache['provider']);
            if ($r && $r
              ->access($obj->cache['access'])) {
              $blocks[$base_name] = $obj;
            }
          }
        }
      }
    }
    uksort($blocks, '\\Drupal\\forena\\File\\DataFile::blockCompare');
    return $blocks;
  }

  /**
   * Sort compare function for sorting data by category then title.
   * @param string $a
   * @param string $b
   * @return number
   */
  public static function blockCompare($a, $b) {
    $c = strnatcasecmp($a, $b);
    return $c;
  }

  /**
   * @param $object
   * @return array
   * Extract data from an SQL file.
   */
  public function parseSQLFile($object) {
    $file = file_get_contents($object->file);
    $src = $this->dmSvc
      ->parseSQL($file);
    $metaData = [
      'provider' => $this->source,
      'name' => $this->source . '/' . $this->base_name,
      'access' => @$src['access'],
      'options' => @$src['options'],
    ];
    return $metaData;
  }

  /**
   * Should load cache data based on that.
   * @see FrxFile::buildCache()
   */
  public function extractMetaData(&$object) {
    switch ($object->ext) {
      case 'sql':
        $object->metaData = $this
          ->parseSQLFile($object);
        break;
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DataFileSystem::$dmSvc public property
DataFileSystem::$source public property
DataFileSystem::blockCompare public static function Sort compare function for sorting data by category then title.
DataFileSystem::extractMetaData public function Should load cache data based on that. Overrides FileInterface::extractMetaData
DataFileSystem::parseSQLFile public function
DataFileSystem::userBlocks public function List all data blocks a sure has access to.
DataFileSystem::__construct public function Overrides FileSystemBase::__construct
FileSystemBase::$cache public property
FileSystemBase::$cacheKey public property
FileSystemBase::$dir public property
FileSystemBase::$includes public property
FileSystemBase::$name_index public property
FileSystemBase::$needSave public property
FileSystemBase::$needScan public property
FileSystemBase::$type_index public property
FileSystemBase::$validated public property
FileSystemBase::$write_dir public property
FileSystemBase::allMetadataForExt protected function Get all metadata for files of a specific extension.
FileSystemBase::CACHE_KEY constant 1
FileSystemBase::contents public function Return the contents of a file located in the report directory Overrides FileInterface::contents
FileSystemBase::delete public function Delete a file from the directory. Overrides FileInterface::delete 1
FileSystemBase::deleteMissingEntries private function
FileSystemBase::directory public function Return the directory portion of a report filename.
FileSystemBase::exists public function Return whether the file exists. Overrides FileInterface::exists
FileSystemBase::getDirectoryState public function 1
FileSystemBase::getMetaData public function Returns the cache entry based on a filename. Overrides FileInterface::getMetaData
FileSystemBase::includeExists public function Determine if the file exists in the include path.
FileSystemBase::isCustom public function Determine whether the file is a cusomt implmentation. Overrides FileInterface::isCustom
FileSystemBase::isOverriden public function Test whether file is overriding code provided files. Overrides FileInterface::isOverriden
FileSystemBase::isWritable public function Return an indicator as to whether the file is savable. New files can be saved if the directory is writabel. Overrides FileInterface::isWritable
FileSystemBase::path public function Return the full path to the filename
FileSystemBase::pathinfo public function Retrieve path info
FileSystemBase::revert public function Revert an individual report
FileSystemBase::save public function Save a file into the report directory. Overrides FileInterface::save 1
FileSystemBase::scan public function
FileSystemBase::scanDirectory private function Recursive function which scans the directory and loads the base indexes.
FileSystemBase::scanInclude protected function Parse a drectory
FileSystemBase::setDirectoryState public function 1
FileSystemBase::setFilesToDelete private function
FileSystemBase::verifyDirectory function