You are here

function js_injector_requirements in JS injector 7.2

Same name and namespace in other branches
  1. 7 js_injector.install \js_injector_requirements()

Implements hook_requirements().

We'll use this to prevent installation of the module if the file directory is not available and writable.

File

./js_injector.install, line 131
js_injector.install

Code

function js_injector_requirements($phase) {
  $requirements = array();
  if ($phase == 'runtime') {
    $requirements['js_injector_cache_dir'] = array(
      'title' => t('JS injector cache dir'),
      'severity' => REQUIREMENT_OK,
      'value' => t('Exists'),
    );
    if (!js_injector_prepare_directory()) {
      $requirements['js_injector_cache_dir']['description'] = t('The JS injector cache directory, %path could not be created 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' => file_uri_target(JS_INJECTOR_DIRECTORY_URI),
      ));
      $requirements['js_injector_cache_dir']['severity'] = REQUIREMENT_ERROR;
      $requirements['js_injector_cache_dir']['value'] = t('Unable to create');
    }
  }
  return $requirements;
}