You are here

function bxslider_requirements in BxSlider 8

Same name and namespace in other branches
  1. 7 bxslider.install \bxslider_requirements()

Implements hook_requirements().

File

./bxslider.install, line 11
Install, update and uninstall functions for the bxslider module.

Code

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