function toc_js_requirements in Toc.js 2.0.x
Same name and namespace in other branches
- 8 toc_js.install \toc_js_requirements()
Implements hook_requirements().
File
- ./
toc_js.install, line 11 - Contains toc_js.install.
Code
function toc_js_requirements($phase) {
$requirements = [];
if ($phase != 'runtime') {
return $requirements;
}
// @todo: simplified when [#3093289] lands to keep dist folder only.
$library_path = '/libraries/toc/toc.min.js';
$library_exists = file_exists(DRUPAL_ROOT . $library_path) ? TRUE : FALSE;
if (!$library_exists) {
$library_path = '/libraries/toc/dist/toc.min.js';
$library_exists = file_exists(DRUPAL_ROOT . $library_path) ? TRUE : FALSE;
}
$requirements['toc_js_library_downloaded'] = [
'title' => t('TOC.js library'),
'value' => $library_exists ? t('Installed (found in %path)', [
'%path' => $library_path,
]) : t('Not installed'),
'description' => $library_exists ? '' : t('The TOC.js library needs to be <a href="@url">downloaded</a> and extracted into the /libraries/toc folder in your Drupal installation directory. The complete path to the library must be <b>/libraries/toc/toc.min.js</b>.', [
'@url' => 'https://github.com/jgallen23/toc/tree/greenkeeper/update-all',
]),
'severity' => $library_exists ? REQUIREMENT_OK : REQUIREMENT_ERROR,
];
return $requirements;
}