Toolbar.php 815 Bytes
Newer Older
Qiang Xue committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
<?php
/**
 * @link http://www.yiiframework.com/
 * @copyright Copyright (c) 2008 Yii Software LLC
 * @license http://www.yiiframework.com/license/
 */

namespace yii\debug;

use Yii;
use yii\base\Widget;
use yii\helpers\Html;

/**
 * @author Qiang Xue <qiang.xue@gmail.com>
 * @since 2.0
 */
class Toolbar extends Widget
{
Qiang Xue committed
20
	public $debugAction = 'debug/default/toolbar';
Qiang Xue committed
21 22 23

	public function run()
	{
Qiang Xue committed
24
		if (Yii::$app->hasModule('debug')) {
Qiang Xue committed
25 26 27 28
			$id = 'yii-debug-toolbar';
			$url = Yii::$app->getUrlManager()->createUrl($this->debugAction, array(
				'tag' => Yii::getLogger()->tag,
			));
29 30 31
			$view = $this->getView();
			$view->registerJs("yii.debug.load('$id', '$url');");
			$view->registerAssetBundle('yii/debug');
Qiang Xue committed
32 33 34 35 36 37 38
			echo Html::tag('div', '', array(
				'id' => $id,
				'style' => 'display: none',
			));
		}
	}
}