-
Notifications
You must be signed in to change notification settings - Fork 566
Expand file tree
/
Copy pathRequestPanel.php
More file actions
66 lines (61 loc) · 2.23 KB
/
RequestPanel.php
File metadata and controls
66 lines (61 loc) · 2.23 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
63
64
65
66
<?php
declare(strict_types=1);
/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @license https://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace DebugKit\Panel;
use Cake\Core\Configure;
use Cake\Error\Debugger;
use Cake\Event\EventInterface;
use DebugKit\DebugPanel;
use Exception;
/**
* Provides debug information on the Current request params.
*/
class RequestPanel extends DebugPanel
{
/**
* Data collection callback.
*
* @param \Cake\Event\EventInterface $event The shutdown event.
* @return void
*/
public function shutdown(EventInterface $event): void
{
/** @var \Cake\Controller\Controller $controller */
$controller = $event->getSubject();
$request = $controller->getRequest();
$maxDepth = Configure::read('DebugKit.maxDepth', 5);
$attributes = [];
foreach ($request->getAttributes() as $attr => $value) {
try {
serialize($value);
} catch (Exception $e) {
$value = "Could not serialize `{$attr}`. It failed with {$e->getMessage()}";
}
$attributes[$attr] = Debugger::exportVarAsNodes($value, $maxDepth);
}
$this->_data = [
'params' => $request->getAttribute('params'),
'attributes' => $attributes,
'query' => Debugger::exportVarAsNodes($request->getQueryParams(), $maxDepth),
'data' => Debugger::exportVarAsNodes($request->getData(), $maxDepth),
'cookie' => Debugger::exportVarAsNodes($request->getCookieParams(), $maxDepth),
'get' => Debugger::exportVarAsNodes($_GET, $maxDepth),
'matchedRoute' => $request->getParam('_matchedRoute'),
'headers' => [
'response' => headers_sent($file, $line),
'file' => $file,
'line' => $line,
],
];
}
}