refactor(kernel): unify HTTP and CLI application lifecycle

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-07-27 00:48:11 -04:00
parent 98826143a8
commit 65c1b5fb75
67 changed files with 2737 additions and 1070 deletions
+12 -12
View File
@@ -2,7 +2,7 @@
namespace KTXC\Service;
use KTXC\SessionTenant;
use KTXC\Context\TenantContextInterface;
use KTXC\Stores\UserRolesStore;
use Psr\Log\LoggerInterface;
@@ -12,7 +12,7 @@ use Psr\Log\LoggerInterface;
class UserRolesService
{
public function __construct(
private readonly SessionTenant $tenantIdentity,
private readonly TenantContextInterface $tenantContext,
private readonly UserRolesStore $roleStore,
private readonly LoggerInterface $logger
) {}
@@ -26,7 +26,7 @@ class UserRolesService
*/
public function listRoles(): array
{
return $this->roleStore->listRoles($this->tenantIdentity->identifier());
return $this->roleStore->listRoles($this->tenantContext->identifier());
}
/**
@@ -34,7 +34,7 @@ class UserRolesService
*/
public function getRole(string $rid): ?array
{
return $this->roleStore->fetchByRid($this->tenantIdentity->identifier(), $rid);
return $this->roleStore->fetchByRid($this->tenantContext->identifier(), $rid);
}
/**
@@ -45,11 +45,11 @@ class UserRolesService
$this->validateRoleData($roleData);
$this->logger->info('Creating role', [
'tenant' => $this->tenantIdentity->identifier(),
'tenant' => $this->tenantContext->identifier(),
'label' => $roleData['label'] ?? 'Unnamed'
]);
return $this->roleStore->createRole($this->tenantIdentity->identifier(), $roleData);
return $this->roleStore->createRole($this->tenantContext->identifier(), $roleData);
}
/**
@@ -70,11 +70,11 @@ class UserRolesService
$this->validateRoleData($updates, false);
$this->logger->info('Updating role', [
'tenant' => $this->tenantIdentity->identifier(),
'tenant' => $this->tenantContext->identifier(),
'rid' => $rid
]);
return $this->roleStore->updateRole($this->tenantIdentity->identifier(), $rid, $updates);
return $this->roleStore->updateRole($this->tenantContext->identifier(), $rid, $updates);
}
/**
@@ -93,17 +93,17 @@ class UserRolesService
}
// Check if role is assigned to users
$userCount = $this->roleStore->countUsersInRole($this->tenantIdentity->identifier(), $rid);
$userCount = $this->roleStore->countUsersInRole($this->tenantContext->identifier(), $rid);
if ($userCount > 0) {
throw new \InvalidArgumentException("Cannot delete role assigned to {$userCount} user(s)");
}
$this->logger->info('Deleting role', [
'tenant' => $this->tenantIdentity->identifier(),
'tenant' => $this->tenantContext->identifier(),
'rid' => $rid
]);
return $this->roleStore->deleteRole($this->tenantIdentity->identifier(), $rid);
return $this->roleStore->deleteRole($this->tenantContext->identifier(), $rid);
}
/**
@@ -111,7 +111,7 @@ class UserRolesService
*/
public function getRoleUserCount(string $rid): int
{
return $this->roleStore->countUsersInRole($this->tenantIdentity->identifier(), $rid);
return $this->roleStore->countUsersInRole($this->tenantContext->identifier(), $rid);
}
/**