mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 06:15:19 +08:00
Added status code display to debugger toolbar.
This commit is contained in:
@ -33,10 +33,10 @@ class ProfilingPanel extends Panel
|
||||
|
||||
return <<<EOD
|
||||
<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 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>
|
||||
EOD;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ use yii\base\InlineAction;
|
||||
use yii\bootstrap\Tabs;
|
||||
use yii\debug\Panel;
|
||||
use yii\helpers\Html;
|
||||
use yii\web\Response;
|
||||
|
||||
/**
|
||||
* Debugger panel that collects and displays request data.
|
||||
@ -29,8 +30,23 @@ class RequestPanel extends Panel
|
||||
public function getSummary()
|
||||
{
|
||||
$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
|
||||
<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>
|
||||
</div>
|
||||
@ -113,6 +129,7 @@ EOD;
|
||||
$session = Yii::$app->getComponent('session', false);
|
||||
return array(
|
||||
'flashes' => $session ? $session->getAllFlashes() : array(),
|
||||
'statusCode' => Yii::$app->getResponse()->getStatusCode(),
|
||||
'requestHeaders' => $requestHeaders,
|
||||
'responseHeaders' => $responseHeaders,
|
||||
'route' => Yii::$app->requestedAction ? Yii::$app->requestedAction->getUniqueId() : Yii::$app->requestedRoute,
|
||||
|
@ -258,7 +258,6 @@ class Response extends \yii\base\Response
|
||||
$this->sendHeaders();
|
||||
$this->sendContent();
|
||||
$this->trigger(self::EVENT_AFTER_SEND, new ResponseEvent($this));
|
||||
$this->clear();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user