Browse Source

moved HttpException to web.

tags/2.0.0-beta
Qiang Xue 12 years ago
parent
commit
ad218c6719
  1. 1
      framework/yii/base/Application.php
  2. 1
      framework/yii/base/ErrorHandler.php
  3. 4
      framework/yii/views/errorHandler/main.php
  4. 2
      framework/yii/web/AccessControl.php
  5. 2
      framework/yii/web/Application.php
  6. 2
      framework/yii/web/Controller.php
  7. 10
      framework/yii/web/HttpException.php
  8. 2
      framework/yii/web/Request.php
  9. 2
      framework/yii/web/Response.php
  10. 2
      framework/yii/web/User.php
  11. 4
      framework/yii/web/VerbFilter.php
  12. 2
      tests/unit/framework/web/ResponseTest.php

1
framework/yii/base/Application.php

@ -8,6 +8,7 @@
namespace yii\base;
use Yii;
use yii\web\HttpException;
/**
* Application is the base class for all application classes.

1
framework/yii/base/ErrorHandler.php

@ -8,6 +8,7 @@
namespace yii\base;
use Yii;
use yii\web\HttpException;
/**
* ErrorHandler handles uncaught PHP errors and exceptions.

4
framework/yii/views/errorHandler/main.php

@ -14,7 +14,7 @@ $context = $this->context;
<meta charset="utf-8"/>
<title><?php
if ($exception instanceof \yii\base\HttpException) {
if ($exception instanceof \yii\web\HttpException) {
echo (int) $exception->statusCode . ' ' . $context->htmlEncode($exception->getName());
} elseif ($exception instanceof \yii\base\Exception) {
echo $context->htmlEncode($exception->getName() . ' – ' . get_class($exception));
@ -362,7 +362,7 @@ pre .diff .change{
<?php else: ?>
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAA6CAIAAACPssguAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyBpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLj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BDoXiJ04jNm1CAVsDT8Zj7ijyAViJQ6zHPV6Z3s7kNfQrcylqlCVpuZ42IeHgbMpdJM4QD2auFc+mxE+m0JUHQfSqHd2Fsg7mMxxWjxwNiX43yBzNT9+9GSZj6I2NsKZH5e5Y9+hSODQ79+vfvjgP0K8SRzSvCw9jgvxJBe/fpmaln/yBAe3WXYcOHYuRmdTCFctmsah4zBjhtdo+D08BGHVhs1zd9Q/MgKIDcJjCwzyefv+/dRdG86/zItzvri+7knS3ZLefPgQPX7sMxSUy+W8ly+NtbW7Ir2+tjaoVHL5fDqdFgFENpstlMtQ/bdlOc3pJZLpjX6x6G1t/ff0KegdH1v96yV7EEk7nU6r1bJtm+PrVPx9FyFQd7FYBMa+sLAwBODnMgirAAM+p/EqLDcuJAiwbaCsgU+fsf8vwADjle3ME1OGEwAAAABJRU5ErkJggg==" alt="Attention"/>
<h1><?php
if ($exception instanceof \yii\base\HttpException) {
if ($exception instanceof \yii\web\HttpException) {
echo '<span>' . $context->createHttpStatusLink($exception->statusCode, $context->htmlEncode($exception->getName())) . '</span>';
echo ' &ndash; ' . $context->addTypeLinks(get_class($exception));
} elseif ($exception instanceof \yii\base\Exception) {

2
framework/yii/web/AccessControl.php

@ -10,7 +10,7 @@ namespace yii\web;
use Yii;
use yii\base\Action;
use yii\base\ActionFilter;
use yii\base\HttpException;
use yii\web\HttpException;
/**
* AccessControl provides simple access control based on a set of rules.

2
framework/yii/web/Application.php

@ -8,7 +8,7 @@
namespace yii\web;
use Yii;
use yii\base\HttpException;
use yii\web\HttpException;
use yii\base\InvalidRouteException;
/**

2
framework/yii/web/Controller.php

@ -8,7 +8,7 @@
namespace yii\web;
use Yii;
use yii\base\HttpException;
use yii\web\HttpException;
use yii\base\InlineAction;
/**

10
framework/yii/base/HttpException.php → framework/yii/web/HttpException.php

@ -5,7 +5,10 @@
* @license http://www.yiiframework.com/license/
*/
namespace yii\base;
namespace yii\web;
use yii\base\UserException;
use yii\web\Response;
/**
* HttpException represents an exception caused by an improper request of the end-user.
@ -42,9 +45,8 @@ class HttpException extends UserException
*/
public function getName()
{
// use absolute namespaced class here because PHP will generate a mysterious error otherwise
if (isset(\yii\web\Response::$httpStatuses[$this->statusCode])) {
return \yii\web\Response::$httpStatuses[$this->statusCode];
if (isset(Response::$httpStatuses[$this->statusCode])) {
return Response::$httpStatuses[$this->statusCode];
} else {
return 'Error';
}

2
framework/yii/web/Request.php

@ -8,7 +8,7 @@
namespace yii\web;
use Yii;
use yii\base\HttpException;
use yii\web\HttpException;
use yii\base\InvalidConfigException;
use yii\helpers\SecurityHelper;

2
framework/yii/web/Response.php

@ -8,7 +8,7 @@
namespace yii\web;
use Yii;
use yii\base\HttpException;
use yii\web\HttpException;
use yii\base\InvalidParamException;
use yii\helpers\FileHelper;
use yii\helpers\Html;

2
framework/yii/web/User.php

@ -9,7 +9,7 @@ namespace yii\web;
use Yii;
use yii\base\Component;
use yii\base\HttpException;
use yii\web\HttpException;
use yii\base\InvalidConfigException;
/**

4
framework/yii/web/VerbFilter.php

@ -10,7 +10,7 @@ namespace yii\web;
use Yii;
use yii\base\ActionEvent;
use yii\base\Behavior;
use yii\base\HttpException;
use yii\web\HttpException;
/**
* VerbFilter is an action filter that filters by HTTP request methods.
@ -70,7 +70,7 @@ class VerbFilter extends Behavior
/**
* @param ActionEvent $event
* @return boolean
* @throws \yii\base\HttpException when the request method is not allowed.
* @throws HttpException when the request method is not allowed.
*/
public function beforeAction($event)
{

2
tests/unit/framework/web/ResponseTest.php

@ -76,7 +76,7 @@ class ResponseTest extends \yiiunit\TestCase
*/
public function testSendFileWrongRanges($rangeHeader)
{
$this->setExpectedException('yii\base\HttpException');
$this->setExpectedException('yii\web\HttpException');
$dataFile = \Yii::getAlias('@yiiunit/data/web/data.txt');
$_SERVER['HTTP_RANGE'] = 'bytes=' . $rangeHeader;

Loading…
Cancel
Save