mirror of
https://github.com/yiisoft/yii2.git
synced 2026-03-24 07:57:10 +01:00
debug toolbar WIP
This commit is contained in:
@@ -18,19 +18,28 @@ use yii\helpers\Html;
|
||||
class Module extends \yii\base\Module
|
||||
{
|
||||
public $controllerNamespace = 'yii\debug\controllers';
|
||||
public $panels;
|
||||
/**
|
||||
* @var array|Panel[]
|
||||
*/
|
||||
public $panels = array();
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
Yii::$app->log->targets['debug'] = new LogTarget;
|
||||
|
||||
foreach (array_merge($this->corePanels(), $this->panels) as $id => $config) {
|
||||
$config['id'] = $id;
|
||||
$this->panels[$id] = Yii::createObject($config);
|
||||
}
|
||||
|
||||
Yii::$app->getLog()->targets['debug'] = new LogTarget($this);
|
||||
Yii::$app->getView()->on(View::EVENT_END_BODY, array($this, 'renderToolbar'));
|
||||
}
|
||||
|
||||
public function beforeAction($action)
|
||||
{
|
||||
Yii::$app->getView()->off(View::EVENT_END_BODY, array($this, 'renderToolbar'));
|
||||
unset(Yii::$app->log->targets['debug']);
|
||||
unset(Yii::$app->getLog()->targets['debug']);
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
@@ -49,4 +58,19 @@ class Module extends \yii\base\Module
|
||||
'style' => 'display: none',
|
||||
));
|
||||
}
|
||||
|
||||
protected function corePanels()
|
||||
{
|
||||
return array(
|
||||
'config' => array(
|
||||
'class' => 'yii\debug\panels\ConfigPanel',
|
||||
),
|
||||
'request' => array(
|
||||
'class' => 'yii\debug\panels\RequestPanel',
|
||||
),
|
||||
'log' => array(
|
||||
'class' => 'yii\debug\panels\LogPanel',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user