Newer
Older
<?php
/**
* @file
* Install, update and uninstall functions for the colorbox module.
*/
use Drupal\Core\Url;
/**
* Implements hook_install().
*/
function colorbox_install() {
drupal_set_message(t('Thanks for installing Colorbox'));
drupal_set_message(t('You may configure Colorbox by visiting <a href="@url_settings">@url_settings</a>', [
'@url_settings' => '/admin/config/media/colorbox',
]));
}
/**
* Implements hook_requirements().
*/
Fredrik Jonsson
committed
function colorbox_requirements($phase) {
Fredrik Jonsson
committed
if ($phase != 'runtime') {
Fredrik Jonsson
committed
}
Fredrik Jonsson
committed
$library = \Drupal::service('library.discovery')->getLibraryByName('colorbox', 'colorbox');
$library_exists = file_exists(DRUPAL_ROOT . '/' . $library['js'][0]['data']);
Fredrik Jonsson
committed
Fredrik Jonsson
committed
return [
'colorbox_library_downloaded' => [
'title' => t('Colorbox library'),
'value' => $library_exists ? t('Installed') : t('Not installed'),
'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']),
'severity' => $library_exists ? REQUIREMENT_OK : REQUIREMENT_ERROR,
],
];