major update

This commit is contained in:
2026-03-04 15:56:58 +01:00
parent 16759a2732
commit 8f4dd5840d
478 changed files with 24313 additions and 8201 deletions

View File

@@ -3,11 +3,16 @@
namespace MintyPHP\Support\Search;
use MintyPHP\Service\User\UserAvatarService;
use MintyPHP\Service\User\UserServicesFactory;
class SearchItemMapperProvider
{
private static ?UserAvatarService $userAvatarService = null;
/** @var (callable(): UserAvatarService)|null */
private static $userAvatarServiceResolver = null;
public static function configure(callable $userAvatarServiceResolver): void
{
self::$userAvatarServiceResolver = $userAvatarServiceResolver;
}
public static function mapPreviewItem(string $key, array $data, string $query): ?array
{
@@ -59,6 +64,15 @@ class SearchItemMapperProvider
$label = $requestId;
}
$url = lurl('admin/api-audit/view/' . ($data['id'] ?? '')) . '?search=' . urlencode($query);
} elseif ($key === 'system-audit') {
$eventType = trim((string) ($data['event_type'] ?? ''));
$outcome = strtolower(trim((string) ($data['outcome'] ?? '')));
$requestId = trim((string) ($data['request_id'] ?? ''));
$label = $eventType !== '' ? $eventType : $requestId;
if ($outcome !== '') {
$label = trim($label . ' — ' . $outcome);
}
$url = lurl('admin/system-audit/view/' . ($data['id'] ?? '')) . '?search=' . urlencode($query);
} elseif ($key === 'pages') {
$label = (string) ($data['slug'] ?? '');
$url = lurl('page/' . $label) . '?search=' . urlencode($query);
@@ -90,7 +104,8 @@ class SearchItemMapperProvider
$description = (string) ($data['email'] ?? '');
$uuid = (string) ($data['uuid'] ?? '');
$url = lurl('address-book/view/' . $uuid);
if ($uuid !== '' && self::userAvatarService()->hasAvatar($uuid)) {
$userAvatarService = self::userAvatarService();
if ($uuid !== '' && $userAvatarService->hasAvatar($uuid)) {
$image = lurl('admin/users/avatar-file') . '?uuid=' . urlencode($uuid) . '&size=64';
}
} elseif ($key === 'permissions') {
@@ -128,6 +143,13 @@ class SearchItemMapperProvider
}
$description = trim(($statusCode > 0 ? (string) $statusCode : '') . ($requestId !== '' ? ' — ' . $requestId : ''));
$url = lurl('admin/api-audit/view/' . ($data['id'] ?? ''));
} elseif ($key === 'system-audit') {
$eventType = trim((string) ($data['event_type'] ?? ''));
$outcome = strtolower(trim((string) ($data['outcome'] ?? '')));
$requestId = trim((string) ($data['request_id'] ?? ''));
$title = $eventType !== '' ? $eventType : $requestId;
$description = trim(($outcome !== '' ? strtoupper($outcome) : '') . ($requestId !== '' ? ' — ' . $requestId : ''));
$url = lurl('admin/system-audit/view/' . ($data['id'] ?? ''));
} else {
$title = (string) ($data['description'] ?? '');
$description = $label;
@@ -150,11 +172,16 @@ class SearchItemMapperProvider
private static function userAvatarService(): UserAvatarService
{
if (self::$userAvatarService instanceof UserAvatarService) {
return self::$userAvatarService;
if (!is_callable(self::$userAvatarServiceResolver)) {
throw new \RuntimeException('SearchItemMapperProvider is not configured for dependency: ' . UserAvatarService::class);
}
self::$userAvatarService = (new UserServicesFactory())->createUserAvatarService();
return self::$userAvatarService;
$service = (self::$userAvatarServiceResolver)();
if (!$service instanceof UserAvatarService) {
throw new \RuntimeException('SearchItemMapperProvider resolver returned invalid dependency: ' . UserAvatarService::class);
}
return $service;
}
}