You are here

public function DataFile::__construct in Forena Reports 7.5

Constructor Sets the initial reort directory

Overrides FileBase::__construct

File

src/File/DataFile.php, line 11

Class

DataFile

Namespace

Drupal\forena\File

Code

public function __construct() {

  // Load default directory from configuration.
  $report_path = variable_get('forena_query_data_path', '');
  if (!$report_path) {
    $report_path = drupal_realpath('private://data');
    if ($report_path) {
      if (!file_exists($report_path)) {
        @mkdir($report_path);
      }
    }
    if (!$report_path) {
      $report_path = conf_path() . '/data';
    }
  }

  // Add directories for data  repos.
  $default_directory = rtrim($report_path, '/');
  $repositories = \Frx::DataManager()->repositories;
  $directories = array();
  foreach ($repositories as $k => $repos) {
    $directories[$k] = $repos['path'];
  }
  foreach ($directories as $dir) {
    $this->includes[$k] = rtrim($dir, '/');
  }

  // Parent constructor.
  parent::__construct($default_directory, $directories, array(
    'sql',
    'xml',
    'inc',
  ));
}