Same name in other branches
- 5.0.x advagg.install \advagg_requirements()
- 6.0.x advagg.install \advagg_requirements()
- 7.x-1.x advagg.install \advagg_requirements()
- 7.x-2.x advagg.install \advagg_requirements()
- 8.x-2.x advagg.install \advagg_requirements()
- 8.x-4.x advagg.install \advagg_requirements()
Implements hook_requirements().
Fichier
-
./
advagg.install, line 58
Code
function advagg_requirements($phase) {
$requirements = [];
// Ensure translations don't break at install time.
$t = 't';
// Always check these, independent of the current phase.
$function_list = [
'rename',
];
// Check each function to make sure it exists.
foreach ($function_list as $function_name) {
if (!function_exists($function_name)) {
$requirements['advagg_function_' . $function_name] = [
'title' => $t('Adv CSS/JS Agg - Function Disabled'),
'value' => $phase === 'install' ? FALSE : $function_name,
'severity' => REQUIREMENT_ERROR,
'description' => $t('<a href="!url">%name()</a> is disabled on this server. Please contact your hosting provider or server administrator and see if they can re-enable this function for you.', [
'!url' => 'http://php.net/' . str_replace('_', '-', $function_name),
'%name' => $function_name,
]),
];
}
}
// If not at runtime, return here.
if ($phase !== 'runtime') {
return $requirements;
}
$config = \Drupal::config('advagg.settings');
if (!$config->get('skip_enabled_preprocess_check')) {
// Make sure variables are set correctly.
if (!$config->get('enabled')) {
$requirements['advagg_not_on'] = [
'title' => $t('Adv CSS/JS Agg - Enabled'),
'severity' => REQUIREMENT_WARNING,
'value' => $t('Advanced CSS/JS aggregation is disabled.'),
'description' => $t('Go to the Advanced CSS/JS aggregation <a href="@settings">settings page</a> and enable it.', [
'@settings' => Url::fromRoute('advagg.settings')->toString(),
]),
];
}
}
$description = '';
if (!$config->get('enabled')) {
$description .= ' ' . $t('Advanced CSS/JS aggregation is disabled. Go to the Advanced CSS/JS aggregation <a href="@settings">settings page</a> and enable it.', [
'@settings' => Url::fromRoute('advagg.settings')->toString(),
]);
}
if ($config->get('cache_level') === 0) {
$description .= ' ' . $t('Currently running in development mode.');
}
$requirements['advagg_ok'] = [
'title' => $t('Adv CSS/JS Agg'),
'severity' => REQUIREMENT_OK,
'value' => $t('OK'),
'description' => $t('Advanced CSS/JS Aggregator should be working correctly.') . ' ' . $description,
];
return $requirements;
}