Commit e26a9ff4 by Qiang Xue

...

parent 1c375b90
...@@ -363,9 +363,6 @@ class Application extends Module ...@@ -363,9 +363,6 @@ class Application extends Module
'securityManager' => array( 'securityManager' => array(
'class' => 'yii\base\SecurityManager', 'class' => 'yii\base\SecurityManager',
), ),
'translator' => array(
'class' => 'yii\i18n\Translator',
),
)); ));
} }
......
...@@ -32,11 +32,28 @@ class Application extends \yii\base\Application ...@@ -32,11 +32,28 @@ class Application extends \yii\base\Application
*/ */
public function processRequest() public function processRequest()
{ {
$route = isset($_GET['r']) ? $_GET['r'] : ''; $route = $this->getUrlManager()->parseUrl($this->getRequest());
return $this->runAction($route, $_GET); return $this->runAction($route, $_GET);
} }
/** /**
* Returns the request component.
* @return Request the request component
*/
public function getRequest()
{
return $this->getComponent('request');
}
/**
* @return UrlManager
*/
public function getUrlManager()
{
return $this->getComponent('urlManager');
}
/**
* Registers the core application components. * Registers the core application components.
* @see setComponents * @see setComponents
*/ */
...@@ -50,6 +67,9 @@ class Application extends \yii\base\Application ...@@ -50,6 +67,9 @@ class Application extends \yii\base\Application
'response' => array( 'response' => array(
'class' => 'yii\web\Response', 'class' => 'yii\web\Response',
), ),
'urlManager' => array(
'class' => 'yii\web\UrlManager',
),
)); ));
} }
} }
<?php
/**
* UrlManager class file
*
* @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\web;
use \yii\base\Component;
/**
* UrlManager manages the URLs of Yii applications.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class UrlManager extends Component
{
public $routeVar = 'r';
/**
* Initializes the application component.
*/
public function init()
{
parent::init();
$this->processRules();
}
/**
* Processes the URL rules.
*/
protected function processRules()
{
}
/**
* Parses the user request.
* @param HttpRequest $request the request application component
* @return string the route (controllerID/actionID) and perhaps GET parameters in path format.
*/
public function parseUrl($request)
{
if(isset($_GET[$this->routeVar]))
return $_GET[$this->routeVar];
else
return '';
}
}
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