function sidr_requirements in Sidr: Accessible Mobile Menus 8.3
Same name and namespace in other branches
- 8 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 <a href=":download-url">Sidr library</a> needs to be installed at %destination. See the module\'s <a href=":readme-url">README</a> for more instructions.', [
':download-url' => 'https://github.com/artberri/sidr/archive/v2.2.1.zip',
'%destination' => DRUPAL_ROOT . '/libraries/sidr',
':readme-url' => 'https://git.drupalcode.org/project/sidr#installation',
]),
'severity' => $library_exists ? REQUIREMENT_OK : REQUIREMENT_ERROR,
],
];
}