/
Module.php
79 lines (67 loc) · 2.39 KB
/
Module.php
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
namespace amnah\yii2\debug;
use Yii;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\web\View;
class Module extends \yii\debug\Module
{
/**
* {@inheritdoc}
*/
public $controllerNamespace = 'amnah\yii2\debug\controllers';
/**
* {@inheritdoc}
*/
public $historySize = 100;
/**
* @var string Current request separator. This will appear in the dropdown to separate
* the current and old requests
*/
public $currentRequestSeparator = " ----- Current Request Above ----- ";
/**
* @var bool Include assets (toolbar.css and toolbar.js) into html. If you prefer,
* you can copy those files into the web folder and include them directly
*/
public $includeAssets = true;
/**
* Override renderToolbar() function so we can use our own assets
* {@inheritdoc}
*/
public function renderToolbar($event = null)
{
if (!$this->checkAccess() || Yii::$app->getRequest()->getIsAjax()) {
return;
}
$baseDebugUrl = Url::toRoute(['/' . $this->id . '/default/toolbar']);
$baseDebugUrl = Html::encode($baseDebugUrl);
$currentTag = $this->logTarget->tag;
echo "<div id='yii-debug-toolbar' data-url='$baseDebugUrl' style='display:none' class='yii-debug-toolbar-bottom'></div>";
echo "<script type='text/javascript'>window.yii2debugBaseDebugUrl = '$baseDebugUrl';window.yii2debugCurrentTag = '$currentTag';</script>";
if ($this->includeAssets) {
/* @var $view View */
$view = isset($event->sender) ? $event->sender : new View();
echo '<style>' . $view->renderPhpFile(__DIR__ . '/assets/toolbar.css') . '</style>';
echo '<style>' . $view->renderPhpFile(__DIR__ . '/assets/toolbar-custom.css') . '</style>';
echo '<script>' . $view->renderPhpFile(__DIR__ . '/assets/toolbar.js') . '</script>';
}
}
/**
* {@inheritdoc}
*/
public function bootstrap($app)
{
parent::bootstrap($app);
// override the log target with ours
$this->logTarget = $app->getLog()->targets['debug'] = new LogTarget($this);
}
/**
* {@inheritdoc}
*/
public function corePanels()
{
$panels = parent::corePanels();
$panels['profiling'] = ['class' => 'amnah\yii2\debug\panels\ProfilingPanel'];
return $panels;
}
}