View source
<?php
use Drupal\Component\Utility\Unicode;
const PHOTOSWIPE_MIN_PLUGIN_VERSION = '4.0.0';
function photoswipe_requirements($phase) {
$requirements = [];
if (\Drupal::moduleHandler()
->moduleExists('libraries')) {
if ($phase == 'runtime') {
$library = libraries_detect('photoswipe');
$error_type = isset($library['error']) ? Unicode::ucfirst($library['error']) : '';
$error_message = isset($library['error message']) ? $library['error message'] : '';
if (empty($library['installed'])) {
$requirements['photoswipe_plugin'] = [
'title' => t('Photoswipe plugin'),
'value' => t('@e: At least @a', [
'@e' => $error_type,
'@a' => PHOTOSWIPE_MIN_PLUGIN_VERSION,
]),
'severity' => REQUIREMENT_ERROR,
'description' => t('@error You need to download the <a href=":url">Photoswipe plugin</a>, extract the archive and place the photoswipe directory in the %path directory on your server.', [
'@error' => $error_message,
':url' => $library['download url'],
'%path' => 'libraries',
]),
];
}
elseif (version_compare($library['version'], PHOTOSWIPE_MIN_PLUGIN_VERSION, '>=')) {
$requirements['photoswipe_plugin'] = [
'title' => t('Photoswipe plugin'),
'severity' => REQUIREMENT_OK,
'value' => $library['version'],
];
}
else {
$requirements['photoswipe_plugin'] = [
'title' => t('Photoswipe plugin'),
'value' => t('At least @a', [
'@a' => PHOTOSWIPE_MIN_PLUGIN_VERSION,
]),
'severity' => REQUIREMENT_ERROR,
'description' => t('You need to download a later version of the <a href=":url">Photoswipe plugin</a> and replace the old version located in the %path directory on your server.', [
':url' => $library['download url'],
'%path' => $library['library path'],
]),
];
}
}
}
return $requirements;
}
function photoswipe_update_7001() {
}