<?php

/**
 * @file
 * Installation actions for Blazy.
 */

/**
 * Implements hook_requirements().
 */
function blazy_requirements($phase) {
  if ($phase != 'runtime') {
    return [];
  }

  $path = blazy_libraries_get_path('blazy') ?: \Drupal::root() . '/libraries/blazy';
  $exists = is_file($path . '/blazy.js');

  return [
    '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'),
    ],
  ];
}
