This repository was archived by the owner on Apr 9, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathInjectDebugbar.php
More file actions
62 lines (54 loc) · 1.9 KB
/
Copy pathInjectDebugbar.php
File metadata and controls
62 lines (54 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php namespace RainLab\Debugbar\Middleware;
use Error;
use Config;
use Request;
use Closure;
use Exception;
use BackendAuth;
use Symfony\Component\Debug\Exception\FatalThrowableError;
use Barryvdh\Debugbar\Middleware\InjectDebugbar as BaseMiddleware;
class InjectDebugbar extends BaseMiddleware
{
/**
* Handle an incoming request.
*
* @param Request $request
* @param Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!$this->debugbar->isEnabled() || $this->inExceptArray($request)) {
return $next($request);
}
$this->debugbar->boot();
try {
/** @var \Illuminate\Http\Response $response */
$response = $next($request);
}
catch (Exception $e) {
$response = $this->handleException($request, $e);
}
catch (Error $error) {
$e = new FatalThrowableError($error);
$response = $this->handleException($request, $e);
}
$user = BackendAuth::getUser();
if ((!$user || !$user->hasAccess('rainlab.debugbar.access_stored_requests')) &&
!Config::get('rainlab.debugbar::store_all_requests', false)) {
// Disable stored requests
// Note: this will completely disable storing requests from any users
// without the required permission. If that functionality is desired again
// in the future then we can look at overriding the OpenHandler controller
$this->debugbar->setStorage(null);
}
// Modify the response to add the Debugbar if allowed
if (
($user && $user->hasAccess('rainlab.debugbar.access_debugbar')) ||
Config::get('rainlab.debugbar::allow_public_access', false)
) {
$this->debugbar->modifyResponse($request, $response);
}
return $response;
}
}