-
Notifications
You must be signed in to change notification settings - Fork 691
Expand file tree
/
Copy pathDumpPanel.php
More file actions
79 lines (72 loc) · 1.89 KB
/
DumpPanel.php
File metadata and controls
79 lines (72 loc) · 1.89 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
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
/**
* @link https://craftcms.com/
* @copyright Copyright (c) Pixel & Tonic, Inc.
* @license https://craftcms.github.io/license/
*/
namespace craft\debug;
use Craft;
use yii\debug\Module as DebugModule;
use yii\debug\Panel;
use yii\web\NotFoundHttpException;
/**
* Debugger panel that collects and displays dumped variables.
*
* @author Pixel & Tonic, Inc. <support@pixelandtonic.com>
* @since 4.4.0
*/
class DumpPanel extends Panel
{
/**
* Displays a variable, if the Dump panel is active
*
* @param mixed $var The variable to be dumped.
* @param string $file The source file or template name
* @param int $line The line number
*/
public static function dump(mixed $var, string $file, int $line): void
{
$debugModule = Craft::$app->getModule('debug');
if (
$debugModule instanceof DebugModule &&
isset($debugModule->panels['dump']) &&
$debugModule->panels['dump'] instanceof DumpPanel
) {
$dump = Craft::dump($var, return: true);
$debugModule->panels['dump']->data[] = [$file, $line, $dump];
}
}
/**
* @inheritdoc
*/
public function getName(): string
{
return 'Dumps';
}
/**
* @inheritdoc
*/
public function getSummary(): string
{
return Craft::$app->getView()->render('@app/views/debug/dump/summary', [
'panel' => $this,
]);
}
/**
* @inheritdoc
* @throws NotFoundHttpException if a `trace` parameter is in the query string, but its value isn’t a valid deprecation warning’s ID
*/
public function getDetail(): string
{
return Craft::$app->getView()->render('@app/views/debug/dump/detail', [
'panel' => $this,
]);
}
/**
* @inheritdoc
*/
public function save()
{
return $this->data ?? [];
}
}