You are here

function superfish_requirements in Superfish 8

Same name and namespace in other branches
  1. 6 superfish.install \superfish_requirements()
  2. 7 superfish.install \superfish_requirements()

Implements hook_requirements().

File

./superfish.install, line 25
Install, update and uninstall functions for the Superfish module.

Code

function superfish_requirements($phase) {
  $requirements = [];
  if ($phase == 'runtime') {
    $requirements['superfish']['title'] = t('Superfish library');
    if (superfish_library_check()) {

      // Check the uploaded Superfish library version.
      $version = superfish_library_version();
      if (is_null($version)) {
        $requirements['superfish']['value'] = t('Inaccessible');
        $requirements['superfish']['severity'] = REQUIREMENT_ERROR;
        $requirements['superfish']['description'] = t('Cannot access the Superfish library directory; perhaps because its permissions and/or ownership are not set up correctly.');
      }
      else {
        $version = (int) $version;
        if (!$version || !is_numeric($version)) {
          $requirements['superfish']['value'] = t('Unknown version');
          $requirements['superfish']['severity'] = REQUIREMENT_ERROR;
          $requirements['superfish']['description'] = t('Cannot determine the version of your Superfish library.');
        }
        elseif (version_compare($version, 2, '<')) {
          $requirements['superfish']['value'] = t('Not supported');
          $requirements['superfish']['severity'] = REQUIREMENT_ERROR;
          $requirements['superfish']['description'] = t('The Superfish library requires an update. You can find the update instructions on :url.', [
            ':url' => 'https://www.drupal.org/project/superfish',
          ]);
        }
        else {
          $requirements['superfish']['value'] = t('Installed; at @location', [
            '@location' => superfish_library_path(),
          ]);
          $requirements['superfish']['severity'] = REQUIREMENT_OK;
        }
      }
    }
    else {
      $requirements['superfish']['value'] = t('Not installed');
      $requirements['superfish']['severity'] = REQUIREMENT_ERROR;
      $requirements['superfish']['description'] = t('Please download the Superfish library from :url.', [
        ':url' => 'https://www.drupal.org/project/superfish',
      ]);
    }
  }
  return $requirements;
}