You are here

function chosen_requirements in Chosen 8.2

Same name and namespace in other branches
  1. 6 chosen.install \chosen_requirements()
  2. 7.3 chosen.install \chosen_requirements()
  3. 7 chosen.install \chosen_requirements()
  4. 7.2 chosen.install \chosen_requirements()
  5. 3.0.x chosen.install \chosen_requirements()

Implements hook_requirements().

File

./chosen.install, line 14
Installation and uninstallation functions.

Code

function chosen_requirements($phase) {
  $requirements = [];
  switch ($phase) {
    case 'runtime':
      module_load_include('module', 'chosen_lib');
      $chosen_path = _chosen_lib_get_chosen_path();
      if (!$chosen_path) {
        $url = Url::fromUri(CHOSEN_WEBSITE_URL);
        $link = Link::fromTextAndUrl(t('Chosen JavaScript file'), $url)
          ->toString();
        $requirements['chosen_js'] = [
          'title' => t('Chosen JavaScript file'),
          'value' => t('Not Installed'),
          'severity' => REQUIREMENT_ERROR,
          'description' => t('You need to <a href="@url">download</a> the @chosen and extract the entire contents of the archive into the %path directory in your Drupal installation directory.', [
            '@chosen' => $link,
            '%path' => 'libraries/chosen',
            '@url' => 'https://github.com/harvesthq/chosen/releases/latest',
          ]),
        ];
      }
      else {
        $requirements['chosen_js'] = [
          'title' => t('Chosen JavaScript file'),
          'severity' => REQUIREMENT_OK,
          'value' => t('Installed'),
        ];
      }
      break;
  }
  return $requirements;
}