function token_requirements in Token 8
Same name and namespace in other branches
- 5 token.install \token_requirements()
- 6 token.install \token_requirements()
- 7 token.install \token_requirements()
Implements hook_requirements().
File
- ./
token.install, line 11 - Install, update and uninstall functions for the token module.
Code
function token_requirements($phase = 'runtime') {
$requirements = [];
if ($phase == 'runtime') {
// Check for various token definition problems.
$token_problems = token_get_token_problems();
// Format and display each token problem.
foreach ($token_problems as $problem_key => $problem) {
if (!empty($problem['problems'])) {
$problems = array_unique($problem['problems']);
$build = [
'#theme' => 'item_list',
'#items' => $problems,
];
$requirements['token-' . $problem_key] = [
'title' => $problem['label'],
'value' => \Drupal::service('renderer')
->renderPlain($build),
'severity' => $problem['severity'],
];
}
}
}
return $requirements;
}