forked from discoverygarden/dgi_fixity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dgi_fixity.install
34 lines (32 loc) · 994 Bytes
/
dgi_fixity.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
/**
* @file
* Install hook implementations.
*/
/**
* 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' => \t('Fixity'),
'value' => $failed ? \t('Error') : ($out_to_date ? \t('Out of date') : \t('Up to date')),
'description' => \Drupal::service('renderer')->render($elements),
'severity' => $failed ? REQUIREMENT_ERROR : ($out_to_date ? REQUIREMENT_WARNING : REQUIREMENT_OK),
];
}
return $requirements;
}