You are here

lazy.install in Lazy-load 8

Same filename and directory in other branches
  1. 8.3 lazy.install
  2. 8.2 lazy.install
  3. 7 lazy.install

Install, update, and uninstall functions for the Lazy-load module.

File

lazy.install
View 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

Namesort descending Description
lazy_requirements Implements hook_requirements().