clear(); $tenant = $this->tenantService->fetchByDomain($domain); if ($tenant === null) { return false; } $this->domain = $domain; $this->tenant = $tenant; return true; } public function resolveIdentifier(string $identifier): bool { $this->clear(); $tenant = $this->tenantService->fetchById($identifier); if ($tenant === null) { return false; } $this->domain = $identifier; $this->tenant = $tenant; return true; } public function clear(): void { $this->tenant = null; $this->domain = null; } public function present(): bool { return $this->tenant !== null; } public function configured(): bool { return $this->present(); } public function enabled(): bool { return $this->tenant?->getEnabled() ?? false; } public function domain(): ?string { return $this->domain; } public function identifier(): ?string { return $this->tenant?->getIdentifier(); } public function requireIdentifier(): string { return $this->identifier() ?? throw new \LogicException('This operation requires a tenant context.'); } public function label(): ?string { return $this->tenant?->getLabel(); } public function configuration(): ?TenantConfiguration { return $this->tenant?->getConfiguration(); } public function settings(): array { return $this->tenant?->getSettings() ?? []; } public function identityProviders(): array { return $this->tenant?->getConfiguration()['identity']['providers'] ?? []; } public function identityProviderConfig(string $providerId): ?array { return $this->identityProviders()[$providerId] ?? null; } public function isIdentityProviderEnabled(string $providerId): bool { $config = $this->identityProviderConfig($providerId); return $config !== null && ($config['enabled'] ?? false); } }