TenantAtlas/apps/platform/app/Support/Navigation/NavigationScope.php
ahmido b159dacd36 feat: clean up legacy tenant environment context (#372)
## Summary
- remove legacy tenant-scoped routing and middleware paths in favor of the current environment/workspace context flow
- update Filament pages and resources to use the cleaned-up admin surface and environment filter context
- add the related spec 317 artifacts and targeted tests for environment filter state and legacy context cleanup

## Testing
- not run as part of this commit/push/PR workflow

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #372
2026-05-16 18:25:36 +00:00

55 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Support\Navigation;
use Illuminate\Http\Request;
final class NavigationScope
{
public static function isWorkspaceSurface(?Request $request = null): bool
{
return ! self::isEnvironmentSurface($request);
}
public static function isEnvironmentSurface(?Request $request = null): bool
{
return in_array(self::pageCategory($request), [
AdminSurfaceScope::EnvironmentBound,
AdminSurfaceScope::EnvironmentScopedEvidence,
], true);
}
public static function shouldRegisterEnvironmentNavigation(?Request $request = null): bool
{
return self::isEnvironmentSurface($request);
}
public static function pageCategory(?Request $request = null): AdminSurfaceScope
{
return AdminSurfaceScope::fromPath(self::effectivePath($request));
}
private static function effectivePath(?Request $request = null): string
{
$request ??= request();
$path = '/'.ltrim((string) $request->path(), '/');
if (! self::isLivewireUpdatePath($path)) {
return $path;
}
$refererPath = parse_url((string) $request->headers->get('referer', ''), PHP_URL_PATH);
return is_string($refererPath) && $refererPath !== ''
? '/'.ltrim($refererPath, '/')
: $path;
}
private static function isLivewireUpdatePath(string $path): bool
{
return preg_match('#^/livewire(?:-[^/]+)?/update$#', $path) === 1;
}
}