You are here

function varbase_heroslider_media_requirements in Media Hero Slider 8.7

Same name and namespace in other branches
  1. 8.4 varbase_heroslider_media.install \varbase_heroslider_media_requirements()
  2. 8.5 varbase_heroslider_media.install \varbase_heroslider_media_requirements()
  3. 8.6 varbase_heroslider_media.install \varbase_heroslider_media_requirements()
  4. 9.0.x varbase_heroslider_media.install \varbase_heroslider_media_requirements()

Implements hook_requirements().

File

./varbase_heroslider_media.install, line 55
Install, update and uninstall functions for the varbase hero slider media.

Code

function varbase_heroslider_media_requirements($phase) {
  $requirements = [];
  $path = DRUPAL_ROOT . '/libraries/slick/slick/slick.min.js';

  // Is the library found in the root libraries path.
  $library_found = file_exists($path);

  // If library is not found, then look in the current profile libraries path.
  if (!$library_found) {
    $profile_path = drupal_get_path('profile', \Drupal::installProfile());
    $profile_path .= '/libraries/slick/slick/slick.min.js';

    // Is the library found in the current profile libraries path.
    $library_found = file_exists($profile_path);
  }
  if (!$library_found) {
    $requirements['slick_library'] = [
      'title' => t('Slick library missing'),
      'description' => t('Media Hero Slider requires the slick.min.js library.
        Download it (https://github.com/kenwheeler/slick) and place it in the
        libraries folder (/libraries)'),
      'severity' => REQUIREMENT_ERROR,
    ];
  }
  return $requirements;
}