function ckeditor_find_requirements in CKEditor Find/Replace 8
Implements hook_requirements().
File
- ./
ckeditor_find.install, line 11 - Install, update and uninstall functions for the ckeditor_find module.
Code
function ckeditor_find_requirements($phase) {
$requirements = [];
if ($phase == 'install' || $phase == 'runtime') {
$library_path = '/libraries/ckeditor/plugins/find';
// Is the library found in the root libraries path.
$library_found = file_exists(DRUPAL_ROOT . $library_path);
// If library is not found, then look in the current profile libraries path.
if (!$library_found) {
$profile_path = drupal_get_path('profile', \Drupal::installProfile());
// Is the library found in the current profile libraries path.
$library_found = file_exists(DRUPAL_ROOT . $profile_path . $library_path);
}
if ($library_found) {
$requirements['find'] = [
'title' => t('find'),
'value' => t('Plugin detected'),
'severity' => REQUIREMENT_OK,
];
}
else {
$requirements['find'] = [
'title' => t('CKEditor Find/Replace'),
'value' => t('CKEditor Find/Replace library missing'),
'severity' => REQUIREMENT_ERROR,
'description' => t('The CKEditor Find/Replace module requires downloading the JS plugin from ckeditor.com and placing it in %library_path. Check the README.md for more information. <a href=":plugin_url">Get the plugin here</a>.', [
':plugin_url' => 'https://ckeditor.com/addon/find',
'%library_path' => $library_path,
]),
];
}
}
return $requirements;
}