You are here

function gridstack_requirements in GridStack 8

Same name and namespace in other branches
  1. 8.2 gridstack.install \gridstack_requirements()

Implements hook_requirements().

File

./gridstack.install, line 14
Installation actions for GridStack.

Code

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