refactor: migrate to scoped execution contexts

Signed-off-by: Sebastian <krupinski01@gmail.com>
This commit is contained in:
2026-07-27 00:50:43 -04:00
parent 9d48710d02
commit 3a68d03114
6 changed files with 60 additions and 60 deletions
+10 -10
View File
@@ -4,8 +4,8 @@ declare(strict_types=1);
namespace KTXM\ServiceDav\Backends;
use KTXC\SessionIdentity;
use KTXC\SessionTenant;
use KTXC\Context\IdentityContextInterface;
use KTXC\Context\TenantContextInterface;
use KTXM\ServiceDav\DavProperties;
use Sabre\DAVACL\PrincipalBackend\BackendInterface;
@@ -17,8 +17,8 @@ class PrincipalBackend implements BackendInterface
public const PRINCIPAL_PREFIX = 'principals';
public function __construct(
private readonly SessionIdentity $identity,
private readonly SessionTenant $tenant,
private readonly IdentityContextInterface $identityContext,
private readonly TenantContextInterface $tenantContext,
) {}
// -------------------------------------------------------------------------
@@ -27,7 +27,7 @@ class PrincipalBackend implements BackendInterface
public function getPrincipalsByPrefix($prefixPath): array
{
if ($prefixPath !== self::PRINCIPAL_PREFIX || $this->identity->identity() === null) {
if ($prefixPath !== self::PRINCIPAL_PREFIX || $this->identityContext->identity() === null) {
return [];
}
@@ -36,11 +36,11 @@ class PrincipalBackend implements BackendInterface
public function getPrincipalByPath($path): ?array
{
if ($this->identity->identity() === null) {
if ($this->identityContext->identity() === null) {
return null;
}
$expected = self::PRINCIPAL_PREFIX . '/' . $this->identity->identifier();
$expected = self::PRINCIPAL_PREFIX . '/' . $this->identityContext->identifier();
if ($path !== $expected) {
return null;
}
@@ -84,9 +84,9 @@ class PrincipalBackend implements BackendInterface
private function buildPrincipal(): array
{
$userId = $this->identity->identifier();
$label = $this->identity->label() ?? $userId;
$email = $this->identity->mailAddress() ?? '';
$userId = $this->identityContext->identifier();
$label = $this->identityContext->label() ?? $userId;
$email = $this->identityContext->mailAddress() ?? '';
return [
DavProperties::URI => self::PRINCIPAL_PREFIX . '/' . $userId,