function lazy_requirements in Lazy-load 8
Same name and namespace in other branches
- 8.3 lazy.install \lazy_requirements()
- 8.2 lazy.install \lazy_requirements()
- 7 lazy.install \lazy_requirements()
Implements hook_requirements().
File
- ./
lazy.install, line 11 - Install, update, and uninstall functions for the Lazy-load module.
Code
function lazy_requirements($phase) {
$requirements = [];
if ($phase == 'runtime') {
$library = Drupal::service('library.discovery')
->getLibraryByName('lazy', 'lazy-blazy');
$has_blazy = FALSE;
if ($library['js']) {
foreach ($library['js'] as $js) {
if ($js['type'] == 'file') {
if (file_exists(DRUPAL_ROOT . '/' . $js['data'])) {
$has_blazy = TRUE;
}
}
}
}
$requirements['blazy'] = [
'title' => t('bLazy library'),
];
$requirements['blazy']['value'] = $has_blazy ? t('Enabled') : t('Not found');
$requirements['blazy']['severity'] = $has_blazy ? REQUIREMENT_OK : REQUIREMENT_WARNING;
if (!$has_blazy) {
$requirements['blazy']['description'] = t('Lazy-load modules requires the bLazy library. See README.md file for instructions.');
}
}
return $requirements;
}