lazy.install in Lazy-load 8
Same filename and directory in other branches
Install, update, and uninstall functions for the Lazy-load module.
File
lazy.installView source
<?php
/**
* @file
* Install, update, and uninstall functions for the Lazy-load module.
*/
/**
* Implements hook_requirements().
*/
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;
}
Functions
Name | Description |
---|---|
lazy_requirements | Implements hook_requirements(). |