This commit is contained in:
╃巡洋艦㊣
2015-07-30 09:52:33 +08:00
parent 5d806e6f22
commit 586684b050
1278 changed files with 44775 additions and 30019 deletions

View File

@@ -364,7 +364,7 @@ class Module extends ServiceLocator
* Adds a sub-module to this module.
* @param string $id module ID
* @param Module|array|null $module the sub-module to be added to this module. This can
* be one of the followings:
* be one of the following:
*
* - a [[Module]] object
* - a configuration array: when [[getModule()]] is called initially, the array
@@ -565,7 +565,8 @@ class Module extends ServiceLocator
}
if (is_subclass_of($className, 'yii\base\Controller')) {
return Yii::createObject($className, [$id, $this]);
$controller = Yii::createObject($className, [$id, $this]);
return get_class($controller) === $className ? $controller : null;
} elseif (YII_DEBUG) {
throw new InvalidConfigException("Controller class must extend from \\yii\\base\\Controller.");
} else {
@@ -579,17 +580,21 @@ class Module extends ServiceLocator
* The method will trigger the [[EVENT_BEFORE_ACTION]] event. The return value of the method
* will determine whether the action should continue to run.
*
* In case the action should not run, the request should be handled inside of the `beforeAction` code
* by either providing the necessary output or redirecting the request. Otherwise the response will be empty.
*
* If you override this method, your code should look like the following:
*
* ```php
* public function beforeAction($action)
* {
* if (parent::beforeAction($action)) {
* // your custom code here
* return true; // or false if needed
* } else {
* if (!parent::beforeAction($action)) {
* return false;
* }
*
* // your custom code here
*
* return true; // or false to not run the action
* }
* ```
*