You are here

tcpdf.install in TCPDF 7

Same filename and directory in other branches
  1. 8 tcpdf.install

Installs and check the requirements of TCPDF module.

File

tcpdf.install
View source
<?php

/**
 * @file
 * Installs and check the requirements of TCPDF module.
 */

/**
 * Use requirements to ensure that the TCPDF cache directory can be
 * created.
 */
function tcpdf_requirements($phase) {
  $t = get_t();
  $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');
    }
    $library = libraries_detect('tcpdf');
    $version = !empty($library['version']) ? $library['version'] : FALSE;
    $requirements["tcpdf_version"] = array(
      'title' => $t('TCPDF library version'),
      'value' => $version ?: $t('Not available'),
      'severity' => $version ? REQUIREMENT_OK : REQUIREMENT_ERROR,
    );
  }
  return $requirements;
}

Functions

Namesort descending Description
tcpdf_requirements Use requirements to ensure that the TCPDF cache directory can be created.