You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.1 KiB
37 lines
1.1 KiB
3 years ago
|
<?php
|
||
|
|
||
|
/**
|
||
|
* @file
|
||
|
* Install hook implementations.
|
||
|
*/
|
||
|
|
||
|
use Drupal\Core\StringTranslation\TranslatableMarkup;
|
||
|
|
||
|
/**
|
||
|
* Implements hook_requirements().
|
||
|
*/
|
||
|
function dgi_fixity_requirements($phase) {
|
||
|
$requirements = [];
|
||
|
if ($phase == 'runtime') {
|
||
|
/** @var \Drupal\dgi_fixity\FixityCheckServiceInterface $fixity */
|
||
|
$fixity = \Drupal::service('dgi_fixity.fixity_check');
|
||
|
$stats = $fixity->stats();
|
||
|
$elements = [];
|
||
|
foreach ($fixity->summary($stats) as $summary) {
|
||
|
$elements[] = [
|
||
|
'#markup' => $summary,
|
||
|
'#suffix' => '<br/>',
|
||
|
];
|
||
|
}
|
||
|
$failed = $stats['failed'] > 0;
|
||
|
$out_to_date = $stats['periodic']['expired'] > 0;
|
||
|
$requirements['dgi_fixity'] = [
|
||
|
'title' => new TranslatableMarkup('Fixity'),
|
||
|
'value' => $failed ? new TranslatableMarkup('Error') : ($out_to_date ? new TranslatableMarkup('Out of date') : new TranslatableMarkup('Up to date')),
|
||
|
'description' => \Drupal::service('renderer')->render($elements),
|
||
|
'severity' => $failed ? REQUIREMENT_ERROR : ($out_to_date ? REQUIREMENT_WARNING : REQUIREMENT_OK),
|
||
|
];
|
||
|
}
|
||
|
return $requirements;
|
||
|
}
|