Commit ef1a6d20 by Qiang Xue

When an ID is found to be in both `Application::controllerMap` and…

When an ID is found to be in both `Application::controllerMap` and `Application::modules`, the former will take precedence
parent aeb8dd56
...@@ -262,6 +262,7 @@ Yii Framework 2 Change Log ...@@ -262,6 +262,7 @@ Yii Framework 2 Change Log
- Chg: Use `limit(null)` instead of `limit(-1)` in migration controller to be compatible to more backends (cebe) - Chg: Use `limit(null)` instead of `limit(-1)` in migration controller to be compatible to more backends (cebe)
- Chg: `yii\web\Request::cookieValidationKey` must be explicitly specified for each application that wants to use cookie validation (qiangxue) - Chg: `yii\web\Request::cookieValidationKey` must be explicitly specified for each application that wants to use cookie validation (qiangxue)
- Chg: Added `yii\composer\Installer::postCreateProject()` and modified the syntax of calling installer methods in composer.json (qiangxue) - Chg: Added `yii\composer\Installer::postCreateProject()` and modified the syntax of calling installer methods in composer.json (qiangxue)
- Chg: When an ID is found to be in both `Application::controllerMap` and `Application::modules`, the former will take precedence (qiangxue)
- New #3911: Added `yii\behaviors\SluggableBehavior` that fills the specified model attribute with the transliterated and adjusted version to use in URLs (creocoder) - New #3911: Added `yii\behaviors\SluggableBehavior` that fills the specified model attribute with the transliterated and adjusted version to use in URLs (creocoder)
- New #4193: Added `yii\filters\Cors` CORS filter to allow Cross Origin Resource Sharing (pgaultier) - New #4193: Added `yii\filters\Cors` CORS filter to allow Cross Origin Resource Sharing (pgaultier)
- New: Added `yii\base\InvalidValueException` (qiangxue) - New: Added `yii\base\InvalidValueException` (qiangxue)
......
...@@ -511,15 +511,14 @@ class Module extends ServiceLocator ...@@ -511,15 +511,14 @@ class Module extends ServiceLocator
} }
// module and controller map take precedence // module and controller map take precedence
$module = $this->getModule($id);
if ($module !== null) {
return $module->createController($route);
}
if (isset($this->controllerMap[$id])) { if (isset($this->controllerMap[$id])) {
$controller = Yii::createObject($this->controllerMap[$id], [$id, $this]); $controller = Yii::createObject($this->controllerMap[$id], [$id, $this]);
return [$controller, $route]; return [$controller, $route];
} }
$module = $this->getModule($id);
if ($module !== null) {
return $module->createController($route);
}
if (($pos = strrpos($route, '/')) !== false) { if (($pos = strrpos($route, '/')) !== false) {
$id .= '/' . substr($route, 0, $pos); $id .= '/' . substr($route, 0, $pos);
......
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