You are here

function blazy_requirements in Blazy 7

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

Implements hook_requirements().

File

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

Code

function blazy_requirements($phase) {
  $requirements = [];

  // Ensure translations do not break at install time.
  $t = get_t();

  // Must also prevent any class from being initiated as .module file is loaded
  // even during install phase.
  if ($phase == 'install') {
    $exists = _blazy_can_install();
    $requirements['blazy_autoloader'] = [
      'title' => $t('Blazy autoloader'),
      'description' => $exists ? '' : $t('The Blazy module requires one of autoloader modules: <a href="@url1">registry_autoload</a>, <a href="@url2">psr0</a>, <a href="@url3">autoload</a>, <a href="@url4">xautoload</a>.', [
        '@url1' => 'https://www.drupal.org/project/registry_autoload',
        '@url2' => 'https://www.drupal.org/project/psr0',
        '@url3' => 'https://www.drupal.org/project/autoload',
        '@url4' => 'https://www.drupal.org/project/xautoload',
      ]),
      'severity' => $exists ? REQUIREMENT_OK : REQUIREMENT_ERROR,
      'value' => $exists ? $t('installed') : $t('not installed'),
    ];
  }
  elseif ($phase == 'runtime') {
    $exists = function_exists('libraries_get_path') && is_file(libraries_get_path('blazy') . '/blazy.min.js');
    $requirements['blazy_library'] = [
      'title' => $t('Blazy library'),
      'description' => $exists ? '' : $t('The <a href="@url">Blazy library</a> should be installed at <strong>/sites/.../libraries/blazy/blazy.min.js</strong>, or any path supported by libraries.module. 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'),
    ];
  }
  return $requirements;
}