You are here

function tcpdf_requirements in TCPDF 8

Same name and namespace in other branches
  1. 7 tcpdf.install \tcpdf_requirements()

Implements hook_requirements().

File

./tcpdf.install, line 11
Contains requirements for the TCPDF module.

Code

function tcpdf_requirements($phase) {
  $requirements = array();
  if ($phase == 'runtime') {
    $tcpdf_file_dir = 'temporary://tcpdf/cache';
    $problematic_uris = array();
    $cache_dir = $tcpdf_file_dir . 'cache';
    if (!file_prepare_directory($cache_dir, FILE_CREATE_DIRECTORY)) {
      $problematic_uris['cachedir'] = $cache_dir;
    }
    else {
      $requirements['tcpdf_cachedir'] = array(
        'title' => t('TCPDF cache directory'),
        'severity' => REQUIREMENT_OK,
        'value' => t('Exists'),
      );
    }
    foreach ($problematic_uris as $uri) {
      $requirements['tcpdf_cache']['description'] = t('The TCPDF cache directory, %path could not be created or modified due to a misconfigured files directory. Please ensure that the files directory is correctly configured and that the webserver has permission to create directories.', array(
        '%path' => $uri,
      ));
      $requirements['tcpdf_cache']['severity'] = REQUIREMENT_ERROR;
      $requirements['tcpdf_cache']['value'] = t('Unable to create');
    }
    $requirements["tcpdf_available"] = array(
      'title' => t('TCPDF library'),
      'value' => class_exists('TCPDF') ? t('Available') : t('Not available'),
      'severity' => class_exists('TCPDF') ? REQUIREMENT_OK : REQUIREMENT_ERROR,
    );
  }
  return $requirements;
}