You are here

function bynder_select2_requirements in Bynder 8

Same name and namespace in other branches
  1. 8.3 modules/bynder_select2/bynder_select2.install \bynder_select2_requirements()
  2. 8.2 modules/bynder_select2/bynder_select2.install \bynder_select2_requirements()
  3. 4.0.x modules/bynder_select2/bynder_select2.install \bynder_select2_requirements()

Implements hook_requirements().

File

modules/bynder_select2/bynder_select2.install, line 6

Code

function bynder_select2_requirements($phase) {
  if ($phase != 'runtime') {
    return [];
  }
  if (function_exists('libraries_get_path')) {
    $path = libraries_get_path('select2') . '/dist/js/select2.full.min.js';
  }
  else {
    $path = DRUPAL_ROOT . '/libraries/select2/dist/js/select2.full.min.js';
  }
  $exists = is_file($path);
  return [
    'bynder_select2_library' => [
      'title' => t('Bynder select2 library'),
      'description' => $exists ? '' : t('The <a href=":url">Select2 library</a> should be installed at <strong>/libraries/select2</strong>, or any path supported by libraries.module if installed.', [
        ':url' => 'https://select2.github.io/',
      ]),
      'severity' => $exists ? REQUIREMENT_OK : REQUIREMENT_ERROR,
      'value' => $exists ? t('Installed') : t('Not installed'),
    ],
  ];
}