function tcpdf_requirements in TCPDF 7
Same name and namespace in other branches
- 8 tcpdf.install \tcpdf_requirements()
Use requirements to ensure that the TCPDF cache directory can be created.
File
- ./
tcpdf.install, line 11 - Installs and check the requirements of TCPDF module.
Code
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;
}