Same name in other branches
- 7.x-1.4 fitvids.install \fitvids_requirements()
- 7.x-1.x fitvids.install \fitvids_requirements()
- 8.x-1.x fitvids.install \fitvids_requirements()
If the plugin doesn't exist, show a warning on the status page
File
-
./
fitvids.install, line 12
Code
function fitvids_requirements($phase) {
$requirements = [];
// Check if plugin exists
if ($phase == 'install') {
$path = DRUPAL_ROOT . '/libraries/fitvids/jquery.fitvids.js';
$installed = file_exists($path);
if (!$installed) {
// just a message will do here...
// returning a $requirements array seems to crash drupal...
\Drupal::messenger()->addWarning(t('The FitVids.js jQuery plugin is missing. <a href="https://raw.github.com/davatron5000/FitVids.js/master/jquery.fitvids.js" rel="external">Download the plugin</a> and copy it to /libraries/fitvids/jquery.fitvids.js'));
}
}
else {
if ($phase == 'runtime') {
$path = DRUPAL_ROOT . '/libraries/fitvids/jquery.fitvids.js';
$installed = file_exists($path);
if (!$installed) {
$requirements['fitvids'] = [
'title' => t('FitVids.js jQuery plugin'),
'value' => t('Missing'),
'description' => t('<a href=":url" rel="external">Download the plugin</a> and copy it to :library', [
':url' => FITVIDS_PLUGIN_URL,
':library' => FITVIDS_LIBRARY_PATH,
]),
'severity' => REQUIREMENT_WARNING,
];
}
else {
$requirements['fitvids'] = [
'title' => t('FitVids.js jQuery plugin'),
'value' => t('Installed'),
'severity' => REQUIREMENT_OK,
];
}
}
}
return $requirements;
}