|
@@ -1,6 +1,7 @@
|
|
|
<?php
|
|
|
|
|
|
namespace Qii\Base;
|
|
|
+use \Qii\Config;
|
|
|
|
|
|
abstract class Request
|
|
|
{
|
|
@@ -44,7 +45,7 @@ abstract class Request
|
|
|
foreach ($_GET AS $key => $val) {
|
|
|
$this->setParam($key, $val);
|
|
|
}
|
|
|
- $rewriteRule = \Qii::getInstance()->appConfigure(\Qii\Config\Consts::APP_SITE_METHOD);
|
|
|
+ $rewriteRule = \Qii::getInstance()->appConfigure(Consts::APP_SITE_METHOD);
|
|
|
$this->url = new \Qii\Request\Url($rewriteRule);
|
|
|
$this->host = IS_CLI ? '' : $_SERVER['HTTP_HOST'];
|
|
|
$params = (array)$this->url->getParams();
|
|
@@ -85,7 +86,7 @@ abstract class Request
|
|
|
*/
|
|
|
public function defaultController()
|
|
|
{
|
|
|
- return \Qii\Config\Register::get(\Qii\Config\Consts::APP_DEFAULT_CONTROLLER, 'index');
|
|
|
+ return Register::get(Consts::APP_DEFAULT_CONTROLLER, 'index');
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -93,7 +94,7 @@ abstract class Request
|
|
|
*/
|
|
|
public function defaultAction()
|
|
|
{
|
|
|
- return \Qii\Config\Register::get(\Qii\Config\Consts::APP_DEFAULT_ACTION, 'index');
|
|
|
+ return Register::get(Consts::APP_DEFAULT_ACTION, 'index');
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -226,7 +227,7 @@ abstract class Request
|
|
|
*
|
|
|
* @param mixed $name
|
|
|
* @param mixed $value
|
|
|
- * @return boolean | Qii_Request_Abstract
|
|
|
+ * @return boolean | Request
|
|
|
*/
|
|
|
public function setParam($name, $value = null)
|
|
|
{
|
|
@@ -261,7 +262,7 @@ abstract class Request
|
|
|
* setParams
|
|
|
*
|
|
|
* @param array
|
|
|
- * @return boolean | Qii_Request_Abstract
|
|
|
+ * @return boolean | Request
|
|
|
*/
|
|
|
public function setParams($params)
|
|
|
{
|
|
@@ -287,11 +288,11 @@ abstract class Request
|
|
|
* setException
|
|
|
*
|
|
|
* @param Exception $exception
|
|
|
- * @return boolean | Qii_Request_Abstract
|
|
|
+ * @return boolean | Request
|
|
|
*/
|
|
|
public function setException($exception)
|
|
|
{
|
|
|
- if (is_object($exception)
|
|
|
+ if (!empty($exception)
|
|
|
&& ($exception instanceof Exception)
|
|
|
) {
|
|
|
$this->_exception = $exception;
|
|
@@ -308,7 +309,7 @@ abstract class Request
|
|
|
*/
|
|
|
public function getException()
|
|
|
{
|
|
|
- if (is_object($this->_exception)
|
|
|
+ if (!empty($this->_exception)
|
|
|
&& ($this->_exception instanceof Exception)
|
|
|
) {
|
|
|
return $this->_exception;
|
|
@@ -354,7 +355,7 @@ abstract class Request
|
|
|
* setModuleName
|
|
|
*
|
|
|
* @param string $name
|
|
|
- * @return boolean | Qii_Request_Abstract
|
|
|
+ * @return boolean | Request
|
|
|
*/
|
|
|
public function setModuleName($name)
|
|
|
{
|
|
@@ -370,7 +371,7 @@ abstract class Request
|
|
|
* setControllerName
|
|
|
*
|
|
|
* @param string $name
|
|
|
- * @return boolean | Qii_Request_Abstract
|
|
|
+ * @return Request
|
|
|
*/
|
|
|
public function setControllerName($name)
|
|
|
{
|
|
@@ -386,7 +387,7 @@ abstract class Request
|
|
|
* setActionName
|
|
|
*
|
|
|
* @param string $name
|
|
|
- * @return boolean | Qii_Request_Abstract
|
|
|
+ * @return boolean | Request
|
|
|
*/
|
|
|
public function setActionName($name)
|
|
|
{
|
|
@@ -424,7 +425,7 @@ abstract class Request
|
|
|
* setBaseUri
|
|
|
*
|
|
|
* @param string $baseUri
|
|
|
- * @return boolean | Qii_Request_Abstract
|
|
|
+ * @return boolean | Request
|
|
|
*/
|
|
|
public function setBaseUri($baseUri)
|
|
|
{
|
|
@@ -450,7 +451,7 @@ abstract class Request
|
|
|
* setRequestUri
|
|
|
*
|
|
|
* @param string $uri
|
|
|
- * @return boolean | Qii_Request_Abstract
|
|
|
+ * @return boolean | Request
|
|
|
*/
|
|
|
public function setRequestUri($uri)
|
|
|
{
|
|
@@ -487,7 +488,7 @@ abstract class Request
|
|
|
* setDispatched
|
|
|
*
|
|
|
* @param boolean $flag
|
|
|
- * @return boolean | Qii_Request_Abstract
|
|
|
+ * @return boolean | Request
|
|
|
*/
|
|
|
public function setDispatched($flag = true)
|
|
|
{
|
|
@@ -501,9 +502,9 @@ abstract class Request
|
|
|
/**
|
|
|
* 设置dispatcher
|
|
|
*
|
|
|
- * @param Qii_Controller_Dispatcher $dispatcher
|
|
|
+ * @param Dispatcher $dispatcher
|
|
|
*/
|
|
|
- public function setDispatcher(\Qii\Base\Dispatcher $dispatcher)
|
|
|
+ public function setDispatcher(Dispatcher $dispatcher)
|
|
|
{
|
|
|
$this->dispatcher = $dispatcher;
|
|
|
}
|
|
@@ -523,7 +524,7 @@ abstract class Request
|
|
|
* setRouted
|
|
|
*
|
|
|
* @param boolean $flag
|
|
|
- * @return boolean | Qii_Request_Abstract
|
|
|
+ * @return boolean | Request
|
|
|
*/
|
|
|
public function setRouted($flag = true)
|
|
|
{
|
|
@@ -571,7 +572,7 @@ abstract class Request
|
|
|
return true;
|
|
|
} elseif ($requestUri && is_string($requestUri)) {
|
|
|
$scriptFileName = $this->getServer('SCRIPT_FILENAME');
|
|
|
-
|
|
|
+ $basename = "";
|
|
|
do {
|
|
|
if ($scriptFileName && is_string($scriptFileName)) {
|
|
|
$fileName = basename($scriptFileName, \Qii::getInstance()->appConfigure('ext', '.php'));
|