Add a module kernel (ModuleManifest, ModuleRegistry) that allows modules to contribute routes, UI slots, search providers, layout context, session lifecycle, and permissions. Modules are activated via config/modules.php or APP_ENABLED_MODULES env variable. Conflicts (duplicate routes, permissions, slot keys) cause a fail-fast with a clear error message. Extract the address book from hardcoded Core integration points into the first module (modules/addressbook/). The module provides: - Aside icon-bar tab + People panel via UI slot system - Global search resource via AddressBookSearchProvider - Layout context data via AddressBookLayoutProvider - Session lifecycle via AddressBookSessionProvider Core cleanup removes address-book hardcodings from SearchSqlResourceProvider, SearchUiMetaProvider, SearchItemMapperProvider, appBuildLayoutNavContext(), and the aside templates. Permissions (ADDRESS_BOOK_VIEW) and business logic (AddressBookService) remain in Core as they gate general user visibility. Includes 38 new tests (894 total), PHPStan level 5 clean, and architecture tests verifying zero hardcoded address-book references in search/templates. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
68 lines
2.0 KiB
PHP
68 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace MintyPHP\Support\Search;
|
|
|
|
class SearchUiMetaProvider
|
|
{
|
|
private const ICONS = [
|
|
'users' => 'bi-person-badge',
|
|
'tenants' => 'bi-buildings',
|
|
'departments' => 'bi-diagram-3',
|
|
'roles' => 'bi-people',
|
|
'permissions' => 'bi-shield-lock',
|
|
'scheduled-jobs' => 'bi-calendar-check',
|
|
'pages' => 'bi-file-text',
|
|
'mail-log' => 'bi-envelope-paper',
|
|
'api-audit' => 'bi-shield-check',
|
|
'system-audit' => 'bi-journal-lock',
|
|
'docs' => 'bi-journal-text',
|
|
];
|
|
|
|
private const LIST_URL_KEYS = [
|
|
'users',
|
|
'tenants',
|
|
'departments',
|
|
'roles',
|
|
'permissions',
|
|
'scheduled-jobs',
|
|
'pages',
|
|
'mail-log',
|
|
'api-audit',
|
|
'system-audit',
|
|
];
|
|
|
|
public static function iconForKey(string $key): string
|
|
{
|
|
return self::ICONS[$key] ?? 'bi-search';
|
|
}
|
|
|
|
public static function listUrl(string $key, string $query): string
|
|
{
|
|
$encoded = urlencode($query);
|
|
|
|
return match ($key) {
|
|
'users' => lurl('admin/users') . '?search=' . $encoded,
|
|
'tenants' => lurl('admin/tenants') . '?search=' . $encoded,
|
|
'departments' => lurl('admin/departments') . '?search=' . $encoded,
|
|
'roles' => lurl('admin/roles') . '?search=' . $encoded,
|
|
'permissions' => lurl('admin/permissions') . '?search=' . $encoded,
|
|
'scheduled-jobs' => lurl('admin/scheduled-jobs') . '?search=' . $encoded,
|
|
'pages' => lurl(''),
|
|
'mail-log' => lurl('admin/mail-log') . '?search=' . $encoded,
|
|
'api-audit' => lurl('admin/api-audit') . '?search=' . $encoded,
|
|
'system-audit' => lurl('admin/system-audit') . '?search=' . $encoded,
|
|
default => lurl(''),
|
|
};
|
|
}
|
|
|
|
public static function hasIconForKey(string $key): bool
|
|
{
|
|
return array_key_exists($key, self::ICONS);
|
|
}
|
|
|
|
public static function hasListUrlForKey(string $key): bool
|
|
{
|
|
return in_array($key, self::LIST_URL_KEYS, true);
|
|
}
|
|
}
|