<?php

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

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

  $path = DRUPAL_ROOT . '/libraries/slick/slick/slick.min.js';

  if (function_exists('libraries_get_path')) {
    $library_path = libraries_get_path('slick') ?: libraries_get_path('slick-carousel');

    if ($library_path) {
      $path = $library_path . '/slick/slick.min.js';
    }
  }

  $exists = is_file($path);

  return [
    'slick_library' => [
      'title'       => t('Slick library'),
      'description' => $exists ? '' : t('The <a href=":url">Slick library</a> should be installed at <strong>/libraries/slick/slick/slick.min.js</strong>, or any path supported by libraries.module if installed.', [':url' => 'https://github.com/kenwheeler/slick/']),
      'severity'    => $exists ? REQUIREMENT_OK : REQUIREMENT_ERROR,
      'value'       => $exists ? t('Installed') : t('Not installed'),
    ],
  ];
}
