mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-13 04:38:03 +08:00
yiichina
This commit is contained in:
@@ -364,7 +364,11 @@ 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
|
||||
<<<<<<< HEAD
|
||||
* be one of the followings:
|
||||
=======
|
||||
* be one of the following:
|
||||
>>>>>>> yiichina/master
|
||||
*
|
||||
* - a [[Module]] object
|
||||
* - a configuration array: when [[getModule()]] is called initially, the array
|
||||
@@ -565,7 +569,12 @@ class Module extends ServiceLocator
|
||||
}
|
||||
|
||||
if (is_subclass_of($className, 'yii\base\Controller')) {
|
||||
<<<<<<< HEAD
|
||||
return Yii::createObject($className, [$id, $this]);
|
||||
=======
|
||||
$controller = Yii::createObject($className, [$id, $this]);
|
||||
return get_class($controller) === $className ? $controller : null;
|
||||
>>>>>>> yiichina/master
|
||||
} elseif (YII_DEBUG) {
|
||||
throw new InvalidConfigException("Controller class must extend from \\yii\\base\\Controller.");
|
||||
} else {
|
||||
@@ -579,17 +588,33 @@ 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.
|
||||
*
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
* 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.
|
||||
*
|
||||
>>>>>>> yiichina/master
|
||||
* If you override this method, your code should look like the following:
|
||||
*
|
||||
* ```php
|
||||
* public function beforeAction($action)
|
||||
* {
|
||||
<<<<<<< HEAD
|
||||
* if (parent::beforeAction($action)) {
|
||||
* // your custom code here
|
||||
* return true; // or false if needed
|
||||
* } else {
|
||||
* return false;
|
||||
* }
|
||||
=======
|
||||
* if (!parent::beforeAction($action)) {
|
||||
* return false;
|
||||
* }
|
||||
*
|
||||
* // your custom code here
|
||||
*
|
||||
* return true; // or false to not run the action
|
||||
>>>>>>> yiichina/master
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user