refactor: migrate to scoped execution contexts

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-07-27 00:50:43 -04:00
parent eb78c5149a
commit 26ee6e9c33
2 changed files with 16 additions and 16 deletions
+6 -6
View File
@@ -13,8 +13,8 @@ use InvalidArgumentException;
use KTXC\Http\Response\JsonResponse; use KTXC\Http\Response\JsonResponse;
use KTXC\Http\Response\Response; use KTXC\Http\Response\Response;
use KTXC\Http\Response\StreamedNdJsonResponse; use KTXC\Http\Response\StreamedNdJsonResponse;
use KTXC\SessionIdentity; use KTXC\Context\IdentityContextInterface;
use KTXC\SessionTenant; use KTXC\Context\TenantContextInterface;
use KTXF\Controller\ControllerAbstract; use KTXF\Controller\ControllerAbstract;
use KTXF\Json\JsonSerializable; use KTXF\Json\JsonSerializable;
use KTXF\Resource\Identifier\CollectionIdentifier; use KTXF\Resource\Identifier\CollectionIdentifier;
@@ -51,8 +51,8 @@ class DefaultController extends ControllerAbstract {
private const ERR_TARGET_ENTITY = 'Invalid parameter: target must be provider:service:collection:entity'; private const ERR_TARGET_ENTITY = 'Invalid parameter: target must be provider:service:collection:entity';
public function __construct( public function __construct(
private readonly SessionTenant $tenantIdentity, private readonly TenantContextInterface $tenantContext,
private readonly SessionIdentity $userIdentity, private readonly IdentityContextInterface $identityContext,
private readonly Manager $manager, private readonly Manager $manager,
private readonly LoggerInterface $logger private readonly LoggerInterface $logger
) {} ) {}
@@ -80,8 +80,8 @@ class DefaultController extends ControllerAbstract {
): Response { ): Response {
// authorize request // authorize request
$tenantId = $this->tenantIdentity->identifier(); $tenantId = $this->tenantContext->identifier();
$userId = $this->userIdentity->identifier(); $userId = $this->identityContext->identifier();
try { try {
+10 -10
View File
@@ -12,8 +12,8 @@ namespace KTXM\DocumentsManager\Controllers;
use KTXC\Http\Response\JsonResponse; use KTXC\Http\Response\JsonResponse;
use KTXC\Http\Response\Response; use KTXC\Http\Response\Response;
use KTXC\Http\Response\StreamedResponse; use KTXC\Http\Response\StreamedResponse;
use KTXC\SessionIdentity; use KTXC\Context\IdentityContextInterface;
use KTXC\SessionTenant; use KTXC\Context\TenantContextInterface;
use KTXF\Controller\ControllerAbstract; use KTXF\Controller\ControllerAbstract;
use KTXF\Documents\Collection\CollectionBaseInterface; use KTXF\Documents\Collection\CollectionBaseInterface;
use KTXF\Documents\Entity\EntityBaseInterface; use KTXF\Documents\Entity\EntityBaseInterface;
@@ -39,8 +39,8 @@ use Throwable;
class TransferController extends ControllerAbstract class TransferController extends ControllerAbstract
{ {
public function __construct( public function __construct(
private readonly SessionTenant $tenantIdentity, private readonly TenantContextInterface $tenantContext,
private readonly SessionIdentity $userIdentity, private readonly IdentityContextInterface $identityContext,
private readonly Manager $manager, private readonly Manager $manager,
private readonly LoggerInterface $logger private readonly LoggerInterface $logger
) {} ) {}
@@ -56,8 +56,8 @@ class TransferController extends ControllerAbstract
methods: ['GET'] methods: ['GET']
)] )]
public function downloadEntity(string $provider, string $service, string $collection, string $identifier): Response { public function downloadEntity(string $provider, string $service, string $collection, string $identifier): Response {
$tenantId = $this->tenantIdentity->identifier(); $tenantId = $this->tenantContext->identifier();
$userId = $this->userIdentity->identifier(); $userId = $this->identityContext->identifier();
try { try {
$target = new EntityIdentifier($provider, $service, $collection, $identifier); $target = new EntityIdentifier($provider, $service, $collection, $identifier);
@@ -135,8 +135,8 @@ class TransferController extends ControllerAbstract
methods: ['GET'] methods: ['GET']
)] )]
public function downloadArchive(string $provider, string $service, array $ids = [], ?string $collection = null, string $name = 'download'): Response { public function downloadArchive(string $provider, string $service, array $ids = [], ?string $collection = null, string $name = 'download'): Response {
$tenantId = $this->tenantIdentity->identifier(); $tenantId = $this->tenantContext->identifier();
$userId = $this->userIdentity->identifier(); $userId = $this->identityContext->identifier();
if (empty($ids)) { if (empty($ids)) {
return new JsonResponse([ return new JsonResponse([
@@ -221,8 +221,8 @@ class TransferController extends ControllerAbstract
methods: ['GET'] methods: ['GET']
)] )]
public function downloadCollection(string $provider, string $service, string $identifier): Response { public function downloadCollection(string $provider, string $service, string $identifier): Response {
$tenantId = $this->tenantIdentity->identifier(); $tenantId = $this->tenantContext->identifier();
$userId = $this->userIdentity->identifier(); $userId = $this->identityContext->identifier();
try { try {
// Fetch collection metadata // Fetch collection metadata