feat: module architecture improvements — session keys, dependency graph, event dispatcher, deactivation hooks
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>
This commit is contained in:
@@ -15,6 +15,7 @@ use MintyPHP\Service\Access\PermissionService;
|
||||
final class AddressBookAuthorizationPolicy implements AuthorizationPolicyInterface
|
||||
{
|
||||
public const ABILITY_VIEW = 'addressbook.view';
|
||||
public const PERMISSION_KEY = 'address_book.view';
|
||||
|
||||
public function __construct(
|
||||
private readonly PermissionService $permissionService
|
||||
@@ -33,7 +34,7 @@ final class AddressBookAuthorizationPolicy implements AuthorizationPolicyInterfa
|
||||
return AuthorizationDecision::deny(403, 'forbidden');
|
||||
}
|
||||
|
||||
if (!$this->permissionService->userHas($actorUserId, PermissionService::ADDRESS_BOOK_VIEW)) {
|
||||
if (!$this->permissionService->userHas($actorUserId, self::PERMISSION_KEY)) {
|
||||
return AuthorizationDecision::deny(403, 'forbidden');
|
||||
}
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ final class AddressBookLayoutProvider implements LayoutContextProvider
|
||||
'activeDepartments' => appNormalizePositiveIntList($query['departments'] ?? ''),
|
||||
'activeRoles' => appNormalizePositiveIntList($query['roles'] ?? ''),
|
||||
'activeCustomFilters' => self::normalizeCustomFilterQuery($query),
|
||||
'peopleGroups' => is_array($session['available_departments_by_tenant'] ?? null)
|
||||
? $session['available_departments_by_tenant']
|
||||
'peopleGroups' => is_array($session['module.addressbook.departments_by_tenant'] ?? null)
|
||||
? $session['module.addressbook.departments_by_tenant']
|
||||
: [],
|
||||
],
|
||||
];
|
||||
|
||||
@@ -17,7 +17,7 @@ final class AddressBookSessionProvider implements SessionProvider
|
||||
{
|
||||
$userId = (int) ($user['id'] ?? 0);
|
||||
if ($userId <= 0) {
|
||||
unset($_SESSION['available_departments_by_tenant']);
|
||||
unset($_SESSION['module.addressbook.departments_by_tenant']);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -28,13 +28,13 @@ final class AddressBookSessionProvider implements SessionProvider
|
||||
}
|
||||
|
||||
$sessionStore->set(
|
||||
'available_departments_by_tenant',
|
||||
'module.addressbook.departments_by_tenant',
|
||||
$tenantContext->getAvailableDepartmentsByTenant($userId)
|
||||
);
|
||||
}
|
||||
|
||||
public function clear(): void
|
||||
{
|
||||
unset($_SESSION['available_departments_by_tenant']);
|
||||
unset($_SESSION['module.addressbook.departments_by_tenant']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user