You are here

function forena_requirements in Forena Reports 8

Same name and namespace in other branches
  1. 7.5 forena.module \forena_requirements()
  2. 7.2 forena.install \forena_requirements()
  3. 7.4 forena.module \forena_requirements()

File

./forena.module, line 728

Code

function forena_requirements($phase) {
  $requirements = array();
  switch ($phase) {
    case 'runtime':
      $writeable = is_writable(\Drupal\forena\File\ReportFileSystem::instance()->dir);
      if (!$writeable) {
        $requirements['fornea_writable'] = array(
          'title' => 'Forena Report Directory',
          'value' => \Drupal\forena\File\ReportFileSystem::instance()->dir,
          'severity' => REQUIREMENT_ERROR,
          'description' => t('The directory must be writable by the web user in order to create custom reports. '),
        );
      }
      $req = array(
        'severity' => REQUIREMENT_INFO,
        'requirement',
      );
      $libraries = array(
        'dataTables',
        'mpdf',
        'prince',
        'SVGGraph',
      );
      foreach ($libraries as $lib) {
        $requirements['forena_' . $lib] = $req;
        $requirements['forena_' . $lib]['title'] = "Forena {$lib} support";
        $requirements['forena_' . $lib]['value'] = forena_library_file($lib) ? t('Enabled') : t('Not Enabled:');
        $requirements['forena_' . $lib]['severity'] = forena_library_file($lib) ? REQUIREMENT_OK : REQUIREMENT_INFO;
      }
      if (!\Drupal::moduleHandler()
        ->moduleExists('forena_pdf')) {
        unset($requirements['forena_prince']);
        unset($requirements['forena_mpdf']);
      }
      break;
  }
  return $requirements;
}