65c1b5fb75
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
44 lines
998 B
PHP
44 lines
998 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace KTXC\Application\Execution;
|
|
|
|
use KTXC\Context\IdentityContext;
|
|
use KTXC\Context\TenantContext;
|
|
|
|
final class ExecutionScope
|
|
{
|
|
private bool $terminated = false;
|
|
|
|
public function __construct(
|
|
public readonly ExecutionDescriptor $descriptor,
|
|
public readonly ExecutionContext $context,
|
|
private readonly TenantContext $tenantContext,
|
|
private readonly IdentityContext $identityContext,
|
|
) {
|
|
$this->tenantContext->clear();
|
|
$this->identityContext->clear();
|
|
}
|
|
|
|
public function markTerminated(): void
|
|
{
|
|
if ($this->terminated) {
|
|
throw new \LogicException('The execution scope has already been terminated.');
|
|
}
|
|
|
|
$this->terminated = true;
|
|
}
|
|
|
|
public function terminated(): bool
|
|
{
|
|
return $this->terminated;
|
|
}
|
|
|
|
public function dispose(): void
|
|
{
|
|
$this->identityContext->clear();
|
|
$this->tenantContext->clear();
|
|
}
|
|
}
|