function flexslider_requirements in Flex Slider 8.2
Same name and namespace in other branches
- 7.2 flexslider.install \flexslider_requirements()
- 7 flexslider.install \flexslider_requirements()
Implements hook_requirements().
File
- ./
flexslider.install, line 26 - Installation actions for FlexSlider.
Code
function flexslider_requirements($phase) {
$requirements = [];
// Check to see if the flexslider library is available.
if ($phase == 'runtime') {
// @todo Remove this conditional once 8.9 is the minimum supported core
// version.
if (\Drupal::hasService('library.libraries_directory_file_finder')) {
/** @var \Drupal\Core\Asset\LibrariesDirectoryFileFinder $library_file_finder */
$library_file_finder = \Drupal::service('library.libraries_directory_file_finder');
$found = (bool) $library_file_finder
->find('flexslider/jquery.flexslider-min.js');
}
else {
$path = DRUPAL_ROOT . '/libraries/flexslider/jquery.flexslider-min.js';
if (\Drupal::moduleHandler()
->moduleExists('libraries')) {
$path = libraries_get_path('flexslider') . '/jquery.flexslider-min.js';
}
$found = file_exists($path);
// Find the library in the profiles path if not found.
if (!$found) {
$path = drupal_get_path('profile', \Drupal::installProfile());
$path .= '/libraries/flexslider/jquery.flexslider-min.js';
$found = file_exists($path);
}
}
if (!$found) {
$requirements['flexslider'] = [
'title' => t('FlexSlider'),
'description' => t('FlexSlider library not found. Please consult the README.md for installation instructions.'),
'severity' => REQUIREMENT_ERROR,
];
}
}
return $requirements;
}