function amp_requirements in Accelerated Mobile Pages (AMP) 8
Same name and namespace in other branches
- 8.3 amp.install \amp_requirements()
- 8.2 amp.install \amp_requirements()
- 7 amp.install \amp_requirements()
Implements hook_requirements().
File
- ./
amp.install, line 9
Code
function amp_requirements($phase) {
$requirements = [];
if (!class_exists('\\Lullabot\\AMP\\AMP')) {
$requirements['amp_library'] = [
'title' => t('AMP'),
'value' => t('Not available'),
'description' => t('The AMP module requires the PHP <a href="@library">AMP library</a>.', [
'@library' => 'https://github.com/Lullabot/amp-library',
]),
'severity' => REQUIREMENT_ERROR,
];
}
if ($phase == 'runtime') {
$module_handler = \Drupal::service('module_handler');
if (!$module_handler
->moduleExists('token')) {
$requirements['amp_token'] = [
'title' => t('Token module required for AMP'),
'value' => t('Not installed'),
'description' => t('The AMP module requires the <a href="@module">Token</a> module as a dependency. Please download and install Token to prevent errors with AMP.', [
'@module' => 'https://www.drupal.org/project/token',
]),
'severity' => REQUIREMENT_ERROR,
];
}
$theme_handler = \Drupal::service('theme_handler');
if (!$theme_handler
->themeExists('amptheme')) {
$requirements['amptheme'] = [
'title' => t('AMP Base Theme'),
'value' => t('Not installed'),
'description' => t('The AMP module requires the <a href="@theme">AMP Base Theme</a> to be installed.', [
'@theme' => 'https://www.drupal.org/project/amptheme',
]),
'severity' => REQUIREMENT_ERROR,
];
}
}
return $requirements;
}