diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 4faefa6ee5..70a5a5742e 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -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: `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: 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 #4193: Added `yii\filters\Cors` CORS filter to allow Cross Origin Resource Sharing (pgaultier) - New: Added `yii\base\InvalidValueException` (qiangxue) diff --git a/framework/base/Module.php b/framework/base/Module.php index cef423e8d1..873a564641 100644 --- a/framework/base/Module.php +++ b/framework/base/Module.php @@ -511,15 +511,14 @@ class Module extends ServiceLocator } // module and controller map take precedence + if (isset($this->controllerMap[$id])) { + $controller = Yii::createObject($this->controllerMap[$id], [$id, $this]); + return [$controller, $route]; + } $module = $this->getModule($id); if ($module !== null) { return $module->createController($route); } - if (isset($this->controllerMap[$id])) { - $controller = Yii::createObject($this->controllerMap[$id], [$id, $this]); - - return [$controller, $route]; - } if (($pos = strrpos($route, '/')) !== false) { $id .= '/' . substr($route, 0, $pos);