Commit a6961f34 by Alexander Makarov

patched controller and action creation

parent debba898
...@@ -211,15 +211,16 @@ class Application extends Module ...@@ -211,15 +211,16 @@ class Application extends Module
*/ */
public function runController($route, $params = array()) public function runController($route, $params = array())
{ {
$result = $this->createController($route); list($controller, $action) = explode('/', $route);
if ($result === false) {
$controllerObject = $this->createController($controller, $this);
if ($controllerObject === false) {
throw new InvalidRequestException(\Yii::t('yii', 'Unable to resolve the request.')); throw new InvalidRequestException(\Yii::t('yii', 'Unable to resolve the request.'));
} }
/** @var $controller Controller */
list($controller, $action) = $result;
$priorController = $this->controller; $priorController = $this->controller;
$this->controller = $controller; $this->controller = $controllerObject;
$status = $controller->run($action, $params); $status = $controllerObject->run($action, $params);
$this->controller = $priorController; $this->controller = $priorController;
return $status; return $status;
} }
......
...@@ -142,8 +142,9 @@ class Controller extends Component ...@@ -142,8 +142,9 @@ class Controller extends Component
if ($actionID === '') { if ($actionID === '') {
$actionID = $this->defaultAction; $actionID = $this->defaultAction;
} }
if (isset($this->actionMap[$actionID])) { $actions = $this->actions();
return \Yii::createObject($this->actionMap[$actionID], $actionID, $this); if (isset($actions[$actionID])) {
return \Yii::createObject($actions[$actionID], $actionID, $this);
} elseif (method_exists($this, 'action' . $actionID)) { } elseif (method_exists($this, 'action' . $actionID)) {
return new InlineAction($actionID, $this); return new InlineAction($actionID, $this);
} else { } else {
......
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