feat: extend module platform with UI slots, runtime components, CLI tooling and {{userId}} search support
Completes the generic module platform that enables modules to contribute
UI elements, runtime JS components, and search resources without any
core hardcoding.
New generic UI slot types:
- topbar.right_item: module-contributed topbar buttons
- layout.body_end_template: module-contributed dialog/overlay templates
- layout.head_style: module-contributed global CSS
- runtime.component: declarative JS component registration with phase ordering
New infrastructure:
- ModuleAutoloader: PSR-4 autoloading for module-local PHP classes
- ModuleRuntimePageBuilder: symlinks module pages into runtime directory
- ModuleRuntimeAssetPublisher: publishes module CSS/JS to web/modules/
- ModulePermissionSynchronizer: syncs module permissions to DB
- CLI scripts: module-runtime-sync, module-build, module-migrate,
module-permissions-sync, module-assets-sync
- {{userId}} placeholder in SearchDataService for user-scoped search queries
- Component runtime with phased initialization (early/default/late)
- AppContainer.protectExistingBindings() to prevent module→core overwrites
- Architecture tests: ModuleStructureContractTest, CoreTemplateIsolationTest,
FrontendComponentRuntimeContractTest, AppContainerIsolationContractTest
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,16 +2,18 @@
|
||||
|
||||
namespace MintyPHP\Service\Auth;
|
||||
|
||||
use MintyPHP\App\AppContainer;
|
||||
use MintyPHP\App\Module\Contracts\SessionProvider;
|
||||
use MintyPHP\App\Module\ModuleRegistry;
|
||||
use MintyPHP\Http\SessionStoreInterface;
|
||||
use MintyPHP\Service\Bookmark\BookmarkService;
|
||||
use MintyPHP\Service\User\UserTenantContextService;
|
||||
|
||||
class AuthSessionTenantContextService
|
||||
{
|
||||
public function __construct(
|
||||
private readonly UserTenantContextService $userTenantContextService,
|
||||
private readonly BookmarkService $bookmarkService,
|
||||
private readonly SessionStoreInterface $sessionStore
|
||||
private readonly SessionStoreInterface $sessionStore,
|
||||
private readonly AppContainer $container
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -23,8 +25,6 @@ class AuthSessionTenantContextService
|
||||
|
||||
$availableTenants = $this->userTenantContextService->getAvailableTenants($userId);
|
||||
$this->sessionStore->set('available_tenants', $availableTenants);
|
||||
$this->sessionStore->set('available_departments_by_tenant', $this->userTenantContextService->getAvailableDepartmentsByTenant($userId));
|
||||
$this->sessionStore->set('user_bookmarks', $this->bookmarkService->listGroupedForUser($userId));
|
||||
|
||||
if (!$availableTenants) {
|
||||
$this->sessionStore->set('no_active_tenant', true);
|
||||
@@ -43,5 +43,45 @@ class AuthSessionTenantContextService
|
||||
if ($currentTenant) {
|
||||
$this->sessionStore->set('current_tenant', $currentTenant);
|
||||
}
|
||||
|
||||
$user = $this->sessionStore->get('user', []);
|
||||
$userRecord = is_array($user) ? $user : [];
|
||||
foreach ($this->moduleSessionProviders() as $provider) {
|
||||
$provider->populate($userRecord, $this->container);
|
||||
}
|
||||
}
|
||||
|
||||
public function clearModuleSessionData(): void
|
||||
{
|
||||
foreach ($this->moduleSessionProviders() as $provider) {
|
||||
$provider->clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<SessionProvider>
|
||||
*/
|
||||
private function moduleSessionProviders(): array
|
||||
{
|
||||
$providers = [];
|
||||
try {
|
||||
$registry = $this->container->get(ModuleRegistry::class);
|
||||
if (!$registry instanceof ModuleRegistry) {
|
||||
return [];
|
||||
}
|
||||
foreach ($registry->getSessionProviders() as $providerClass) {
|
||||
if (!class_exists($providerClass)) {
|
||||
continue;
|
||||
}
|
||||
$provider = new $providerClass();
|
||||
if ($provider instanceof SessionProvider) {
|
||||
$providers[] = $provider;
|
||||
}
|
||||
}
|
||||
} catch (\Throwable) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $providers;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user