You are here

function toc_js_requirements in Toc.js 8

Same name and namespace in other branches
  1. 2.0.x 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) {
  if ($phase != 'runtime') {
    return [];
  }
  $requirements = [];
  $library_path = '/libraries/toc/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') : 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;
}