-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstractDetector.php
More file actions
53 lines (45 loc) · 1.35 KB
/
Copy pathAbstractDetector.php
File metadata and controls
53 lines (45 loc) · 1.35 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
declare(strict_types=1);
/*
* This file is part of the "typo3_login_warning" TYPO3 CMS extension.
*
* (c) 2025-2026 Konrad Michalik <km@move-elevator.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace MoveElevator\Typo3LoginWarning\Detector;
use function in_array;
/**
* AbstractDetector.
*
* @author Konrad Michalik <km@move-elevator.de>
* @license GPL-2.0-or-later
*/
abstract class AbstractDetector implements DetectorInterface
{
/**
* @var array<string, mixed>
*/
protected array $additionalData = [];
/**
* @param array<string, mixed> $userArray
* @param array<string, mixed> $configuration
*/
final public function shouldDetectForUser(array $userArray, array $configuration = []): bool
{
$affectedUsers = $configuration['affectedUsers'] ?? 'all';
return match ($affectedUsers) {
'admins' => (bool) ($userArray['admin'] ?? false),
'maintainers' => in_array((int) ($userArray['uid'] ?? 0), $GLOBALS['TYPO3_CONF_VARS']['SYS']['systemMaintainers'] ?? [], true),
default => true, // 'all'
};
}
/**
* @return array<string, mixed>
*/
final public function getAdditionalData(): array
{
return $this->additionalData;
}
}