Six targeted improvements to the modular monolith platform: 1. Fix AddressBook session key prefix to follow module.<id>.* convention 2. Move ADDRESS_BOOK_VIEW permission constant from core PermissionService into module 3. Add declarative JSON schema for module manifests (.agents/contracts/) 4. Add `requires` field with missing-dependency and circular-dependency detection 5. Add lightweight fire-and-forget event dispatcher (user.created/deleted/login/logout) 6. Add module deactivation hook interface and CLI script (bin/module-deactivate.php) Includes 15 new architecture/unit tests covering all new functionality. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
41 lines
1.2 KiB
PHP
41 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace MintyPHP\Module\AddressBook\Providers;
|
|
|
|
use MintyPHP\App\AppContainer;
|
|
use MintyPHP\App\Module\Contracts\SessionProvider;
|
|
use MintyPHP\Http\SessionStoreInterface;
|
|
use MintyPHP\Service\User\UserTenantContextService;
|
|
|
|
/**
|
|
* Populates session with department-by-tenant hierarchy data used by the
|
|
* address book aside panel.
|
|
*/
|
|
final class AddressBookSessionProvider implements SessionProvider
|
|
{
|
|
public function populate(array $user, AppContainer $container): void
|
|
{
|
|
$userId = (int) ($user['id'] ?? 0);
|
|
if ($userId <= 0) {
|
|
unset($_SESSION['module.addressbook.departments_by_tenant']);
|
|
return;
|
|
}
|
|
|
|
$tenantContext = $container->get(UserTenantContextService::class);
|
|
$sessionStore = $container->get(SessionStoreInterface::class);
|
|
if (!$tenantContext instanceof UserTenantContextService || !$sessionStore instanceof SessionStoreInterface) {
|
|
return;
|
|
}
|
|
|
|
$sessionStore->set(
|
|
'module.addressbook.departments_by_tenant',
|
|
$tenantContext->getAvailableDepartmentsByTenant($userId)
|
|
);
|
|
}
|
|
|
|
public function clear(): void
|
|
{
|
|
unset($_SESSION['module.addressbook.departments_by_tenant']);
|
|
}
|
|
}
|