You are here

function bootstrap_languages_requirements in Bootstrap Languages 8

Same name and namespace in other branches
  1. 7 bootstrap_languages.install \bootstrap_languages_requirements()

Implements hook_requirements().

File

./bootstrap_languages.install, line 11
Install, update and uninstall functions for the Bootstrap Languages module.

Code

function bootstrap_languages_requirements($phase) {
  if ($phase != 'runtime') {
    return [];
  }
  $library = \Drupal::service('library.discovery')
    ->getLibraryByName('bootstrap_languages', 'bootstrap-languages');
  $library_exists = file_exists(DRUPAL_ROOT . '/' . $library['css'][0]['data']);
  return [
    'bootstrap_languages_library_downloaded' => [
      'title' => t('Bootstrap Languages library'),
      'value' => $library_exists ? t('Installed') : t('Not installed'),
      'description' => $library_exists ? '' : t('The Bootstrap Languages library needs to be <a href="@url">downloaded</a> and extracted into the /libraries/bootstrap-languages folder in your Drupal installation directory.', [
        '@url' => 'https://github.com/usrz/bootstrap-languages/archive/master.zip',
      ]),
      'severity' => $library_exists ? REQUIREMENT_OK : REQUIREMENT_ERROR,
    ],
  ];
}