Commit 9f4ccb62 by Qiang Xue

Added status code display to debugger toolbar.

parent da81f8da
...@@ -33,10 +33,10 @@ class ProfilingPanel extends Panel ...@@ -33,10 +33,10 @@ class ProfilingPanel extends Panel
return <<<EOD return <<<EOD
<div class="yii-debug-toolbar-block"> <div class="yii-debug-toolbar-block">
<a href="$url" title="total processing time">Time: <span class="label">$time</span></a> <a href="$url" title="Total processing time">Time: <span class="label">$time</span></a>
</div> </div>
<div class="yii-debug-toolbar-block"> <div class="yii-debug-toolbar-block">
<a href="$url" title="peak memory consumption">Memory: <span class="label">$memory</span></a> <a href="$url" title="Peak memory consumption">Memory: <span class="label">$memory</span></a>
</div> </div>
EOD; EOD;
} }
......
...@@ -12,6 +12,7 @@ use yii\base\InlineAction; ...@@ -12,6 +12,7 @@ use yii\base\InlineAction;
use yii\bootstrap\Tabs; use yii\bootstrap\Tabs;
use yii\debug\Panel; use yii\debug\Panel;
use yii\helpers\Html; use yii\helpers\Html;
use yii\web\Response;
/** /**
* Debugger panel that collects and displays request data. * Debugger panel that collects and displays request data.
...@@ -29,9 +30,24 @@ class RequestPanel extends Panel ...@@ -29,9 +30,24 @@ class RequestPanel extends Panel
public function getSummary() public function getSummary()
{ {
$url = $this->getUrl(); $url = $this->getUrl();
$statusCode = $this->data['statusCode'];
if ($statusCode === null) {
$statusCode = 200;
}
if ($statusCode >= 200 && $statusCode < 300) {
$class = 'label-success';
} elseif ($statusCode >= 100 && $statusCode < 200) {
$class = 'label-info';
} else {
$class = 'label-important';
}
$statusText = Html::encode(isset(Response::$httpStatuses[$statusCode]) ? Response::$httpStatuses[$statusCode] : '');
return <<<EOD return <<<EOD
<div class="yii-debug-toolbar-block"> <div class="yii-debug-toolbar-block">
<a href="$url" title="Status code: $statusCode $statusText"><span class="label $class">$statusCode</span></a>
</div>
<div class="yii-debug-toolbar-block">
<a href="$url">Action: <span class="label">{$this->data['action']}</span></a> <a href="$url">Action: <span class="label">{$this->data['action']}</span></a>
</div> </div>
EOD; EOD;
...@@ -113,6 +129,7 @@ EOD; ...@@ -113,6 +129,7 @@ EOD;
$session = Yii::$app->getComponent('session', false); $session = Yii::$app->getComponent('session', false);
return array( return array(
'flashes' => $session ? $session->getAllFlashes() : array(), 'flashes' => $session ? $session->getAllFlashes() : array(),
'statusCode' => Yii::$app->getResponse()->getStatusCode(),
'requestHeaders' => $requestHeaders, 'requestHeaders' => $requestHeaders,
'responseHeaders' => $responseHeaders, 'responseHeaders' => $responseHeaders,
'route' => Yii::$app->requestedAction ? Yii::$app->requestedAction->getUniqueId() : Yii::$app->requestedRoute, 'route' => Yii::$app->requestedAction ? Yii::$app->requestedAction->getUniqueId() : Yii::$app->requestedRoute,
......
...@@ -258,7 +258,6 @@ class Response extends \yii\base\Response ...@@ -258,7 +258,6 @@ class Response extends \yii\base\Response
$this->sendHeaders(); $this->sendHeaders();
$this->sendContent(); $this->sendContent();
$this->trigger(self::EVENT_AFTER_SEND, new ResponseEvent($this)); $this->trigger(self::EVENT_AFTER_SEND, new ResponseEvent($this));
$this->clear();
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment