PR CI / ledger (pull_request) Successful in 4s
PR CI / flow (pull_request) Successful in 4s
PR CI / test (stable) (pull_request) Successful in 45s
PR CI / ui (pull_request) Successful in 48s
PR CI / test (lowest) (pull_request) Successful in 50s
PR CI / security (pull_request) Successful in 54s
PR CI / pr-ci (pull_request) Successful in 2s
PR CI / release-automerge (pull_request) Successful in 3s
32 lines
996 B
PHP
32 lines
996 B
PHP
<?php
|
|
|
|
namespace IriksIT\Manager\Http\Middleware;
|
|
|
|
use Closure;
|
|
use Illuminate\Http\Request;
|
|
use IriksIT\Manager\Support\Shell;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
/**
|
|
* The screens are one page that asks the JSON routes for its data. A browser that opens a manager address gets that
|
|
* page; the page itself, and anything else that asks for JSON, gets the data. Downloads (route names `*.export`) and the
|
|
* built files are left alone.
|
|
*/
|
|
class ServeShell
|
|
{
|
|
public function handle(Request $request, Closure $next): Response
|
|
{
|
|
if (config('manager.ui') !== 'package' || ! $request->isMethodSafe() || $request->wantsJson() || $request->ajax()) {
|
|
return $next($request);
|
|
}
|
|
|
|
$name = (string) $request->route()?->getName();
|
|
|
|
if ($name === 'manager.assets' || str_ends_with($name, '.export')) {
|
|
return $next($request);
|
|
}
|
|
|
|
return response()->view('manager::shell', app(Shell::class)->data($request));
|
|
}
|
|
}
|