1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | use Exception; |
||
6 | use SimpleSAML\Assert\Assert; |
||
7 | use SimpleSAML\Configuration; |
||
8 | use SimpleSAML\Module\consent\Store; |
||
9 | |||
10 | use function is_callable; |
||
11 | |||
12 | /** |
||
13 | * @param array &$hookinfo hookinfo |
||
14 | */ |
||
15 | function consentSimpleAdmin_hook_sanitycheck(array &$hookinfo): void |
||
16 | { |
||
17 | Assert::keyExists($hookinfo, 'errors'); |
||
18 | Assert::keyExists($hookinfo, 'info'); |
||
19 | |||
20 | try { |
||
21 | $consentconfig = Configuration::getConfig('module_consentSimpleAdmin.php'); |
||
22 | |||
23 | // Parse consent config |
||
24 | $consent_storage = Store::parseStoreConfig($consentconfig->getValue('store')); |
||
25 | |||
26 | if (!is_callable([$consent_storage, 'selftest'])) { |
||
27 | // Doesn't support a selftest |
||
28 | return; |
||
29 | } |
||
30 | $testres = $consent_storage->selftest(); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
31 | if ($testres) { |
||
32 | $hookinfo['info'][] = '[consentSimpleAdmin] Consent Storage selftest OK.'; |
||
33 | } else { |
||
34 | $hookinfo['errors'][] = '[consentSimpleAdmin] Consent Storage selftest failed.'; |
||
35 | } |
||
36 | } catch (Exception $e) { |
||
37 | $hookinfo['errors'][] = '[consentSimpleAdmin] Error connecting to storage: ' . $e->getMessage(); |
||
38 | } |
||
39 | } |
||
40 |