function sidr_requirements in Sidr: Accessible Mobile Menus 8
Same name and namespace in other branches
- 8.3 sidr.install \sidr_requirements()
- 8.2 sidr.install \sidr_requirements()
Implements hook_requirements().
File
- ./
sidr.install, line 11 - Install and uninstall hooks for the sidr module.
Code
function sidr_requirements($phase) {
if ($phase != 'runtime') {
return [];
}
// Sidr libraries must be installed.
$library = \Drupal::service('library.discovery')
->getLibraryByName('sidr', 'sidr');
$library_exists = file_exists(DRUPAL_ROOT . '/' . $library['js'][0]['data']);
return [
'sidr_library_downloaded' => [
'title' => t('Sidr library'),
'value' => $library_exists ? t('Installed') : t('Not installed'),
'description' => $library_exists ? '' : t('The Sidr library needs to be downloaded. See the README file in the module for instructions.'),
'severity' => $library_exists ? REQUIREMENT_OK : REQUIREMENT_ERROR,
],
];
}