diff --git a/core/lib/Service/TenantService.php b/core/lib/Service/TenantService.php index f8d9a3e..57b0311 100644 --- a/core/lib/Service/TenantService.php +++ b/core/lib/Service/TenantService.php @@ -16,4 +16,9 @@ class TenantService return $this->store->fetchByDomain($domain); } + public function fetchById(string $identifier): ?TenantObject + { + return $this->store->fetch($identifier); + } + } diff --git a/core/lib/SessionTenant.php b/core/lib/SessionTenant.php index 7400c0e..9a3244f 100644 --- a/core/lib/SessionTenant.php +++ b/core/lib/SessionTenant.php @@ -37,6 +37,26 @@ class SessionTenant } } + /** + * Configure the tenant by its identifier (for console / CLI usage). + */ + public function configureById(string $identifier): void + { + if ($this->configured) { + return; + } + $tenant = $this->tenantService->fetchById($identifier); + if ($tenant) { + $this->domain = $identifier; + $this->tenant = $tenant; + $this->configured = true; + } else { + $this->domain = null; + $this->tenant = null; + $this->configured = false; + } + } + /** * Is the tenant configured */