## Summary - consolidate internal platform naming from `Tenant` to `Environment` / `ManagedEnvironment` across models, controllers, services, and Filament resources - rename environment-scoped UI surfaces such as dashboards, chooser flows, navigation, and related widgets to match the updated environment-first domain language - align middleware, onboarding/review lifecycle services, jobs, and route/context controllers with the new environment-scoped architecture ## Validation - not rerun as part of this commit/push/PR request ## Notes - branch is 1 commit ahead of `platform-dev` - main commit: `refactor: consolidate internal tenant model naming` Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #355
67 lines
2.0 KiB
PHP
67 lines
2.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Support\OperationRunLinks;
|
|
use App\Support\Tenants\TenantPageCategory;
|
|
use App\Support\Workspaces\WorkspaceContext;
|
|
use Filament\Facades\Filament;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
final class ClearEnvironmentContextController
|
|
{
|
|
public function __invoke(Request $request): RedirectResponse
|
|
{
|
|
Filament::setTenant(null, true);
|
|
|
|
$workspaceContext = app(WorkspaceContext::class);
|
|
|
|
$workspaceContext->clearRememberedTenantContext($request);
|
|
|
|
$previousUrl = url()->previous();
|
|
|
|
$previousHost = parse_url((string) $previousUrl, PHP_URL_HOST);
|
|
$previousPath = (string) (parse_url((string) $previousUrl, PHP_URL_PATH) ?? '');
|
|
|
|
if ($previousHost !== null && $previousHost !== $request->getHost()) {
|
|
return redirect()->to(OperationRunLinks::index());
|
|
}
|
|
|
|
if ($this->isTenantScopedEvidencePath($previousPath)) {
|
|
return redirect()->route('admin.evidence.overview');
|
|
}
|
|
|
|
if (TenantPageCategory::fromPath($previousPath) === TenantPageCategory::TenantBound) {
|
|
$workspace = $workspaceContext->currentWorkspace($request);
|
|
|
|
if ($workspace !== null) {
|
|
return redirect()->route('admin.workspace.managed-environments.index', ['workspace' => $workspace]);
|
|
}
|
|
|
|
return redirect()->route('admin.home');
|
|
}
|
|
|
|
if ($previousPath === '' || $previousPath === '/admin/clear-environment-context') {
|
|
return redirect()->to(OperationRunLinks::index());
|
|
}
|
|
|
|
return redirect()->to((string) $previousUrl);
|
|
}
|
|
|
|
private function isTenantScopedEvidencePath(string $previousPath): bool
|
|
{
|
|
if ($previousPath === '/admin/evidence') {
|
|
return true;
|
|
}
|
|
|
|
if (! str_starts_with($previousPath, '/admin/evidence/')) {
|
|
return false;
|
|
}
|
|
|
|
return ! str_starts_with($previousPath, '/admin/evidence/overview');
|
|
}
|
|
}
|