You are here

function blazy_requirements in Blazy 8.2

Same name and namespace in other branches
  1. 8 blazy.install \blazy_requirements()
  2. 7 blazy.install \blazy_requirements()

Implements hook_requirements().

File

./blazy.install, line 11
Installation actions for Blazy.

Code

function blazy_requirements($phase) {
  $requirements = [];
  if ($phase === 'runtime') {
    $path = blazy_libraries_get_path('blazy') ?: \Drupal::root() . '/libraries/blazy';
    $exists = is_file($path . '/blazy.js');
    $requirements['blazy_library'] = [
      'title' => t('Blazy library'),
      'description' => $exists ? '' : t('The <a href=":url">Blazy library</a> should be installed at <strong>/libraries/blazy/blazy.js</strong>, or any path supported by libraries.module if installed. Check out file or folder permissions if troubled.', [
        ':url' => 'https://github.com/dinbror/blazy',
      ]),
      'severity' => $exists ? REQUIREMENT_OK : REQUIREMENT_ERROR,
      'value' => $exists ? t('Installed') : t('Not installed'),
    ];
  }
  if ($phase === 'update') {

    // If updating from Blazy 1.x to 2.x, Media module may not being installed
    // and as it is now a dependency we need to let the administrator know it
    // will be installed.
    if (!\Drupal::moduleHandler()
      ->moduleExists('media')) {
      $requirements['blazy_media'] = [
        'title' => t('Blazy requires Media core module'),
        'description' => t('Blazy now requires core Media module, which is currently not installed. By continuing the update the module will be installed.'),
        'severity' => REQUIREMENT_WARNING,
      ];
    }
  }
  return $requirements;
}