colorbox.install 932 B

123456789101112131415161718192021222324252627
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the colorbox module.
  5. */
  6. /**
  7. * Implements hook_requirements().
  8. */
  9. function colorbox_requirements($phase) {
  10. if ($phase != 'runtime') {
  11. return array();
  12. }
  13. $library = \Drupal::service('library.discovery')->getLibraryByName('colorbox', 'colorbox');
  14. $library_exists = file_exists(DRUPAL_ROOT . '/' . $library['js'][0]['data']);
  15. return [
  16. 'colorbox_library_downloaded' => [
  17. 'title' => t('Colorbox library'),
  18. 'value' => $library_exists ? t('Installed') : t('Not installed'),
  19. 'description' => $library_exists ? '' : t('The Colorbox library needs to be <a href="@url">downloaded</a> and extracted into the /libraries/colorbox folder in your Drupal installation directory.', ['@url' => 'https://github.com/jackmoore/colorbox/archive/master.zip']),
  20. 'severity' => $library_exists ? REQUIREMENT_OK : REQUIREMENT_ERROR,
  21. ],
  22. ];
  23. }