You are here

jquery_minicolors.install in jQuery minicolors 8

File

jquery_minicolors.install
View source
<?php

/**
 * @file
 * Contains jquery_minicolors.install.
 */
use Drupal\Core\Link;
use Drupal\Core\Url;

/**
 * Implements hook_requirements().
 */
function jquery_minicolors_requirements($phase) {
  $requirements = [];
  if ($phase == 'runtime') {
    $requirements['jquery_minicolors']['title'] = t('jQuery Minicolors Library');

    // Verify library files are present.
    if (file_exists(DRUPAL_ROOT . '/libraries/jquery-minicolors/jquery.minicolors.min.js') && file_exists(DRUPAL_ROOT . '/libraries/jquery-minicolors/jquery.minicolors.css')) {
      $requirements['jquery_minicolors']['value'] = t('Installed');
      $requirements['jquery_minicolors']['severity'] = REQUIREMENT_OK;
    }
    else {
      $url = Url::fromUri('https://github.com/claviska/jquery-minicolors/tree/2.2.4');
      $link = Link::fromTextAndUrl('jQuery Minicolors Library', $url);
      $requirements['jquery_minicolors']['value'] = t('Not Installed');
      $requirements['jquery_minicolors']['severity'] = REQUIREMENT_ERROR;
      $requirements['jquery_minicolors']['description'] = t('Please download the @link and install it in the folder DRUPAL_ROOT/libraries/jquery-minicolors. The complete path must be /libraries/jquery-minicolors/jquery.minicolors.min.js. The css file jquery.minicolors.css must be present too in the folder.', [
        '@link' => $link
          ->toString(),
      ]);
    }
  }
  return $requirements;
}

Functions