mirror of
https://github.com/yiisoft/yii2.git
synced 2026-03-06 23:39:02 +01:00
@@ -89,10 +89,10 @@ class Module extends ServiceLocator
|
||||
public $controllerNamespace;
|
||||
/**
|
||||
* @return string the default route of this module. Defaults to 'default'.
|
||||
* The route may consist of child module ID, controller ID, and/or action ID.
|
||||
* For example, `help`, `post/create`, `admin/post/create`.
|
||||
* If action ID is not given, it will take the default value as specified in
|
||||
* [[Controller::defaultAction]].
|
||||
* The route may consist of child module ID, controller ID, and/or action ID.
|
||||
* For example, `help`, `post/create`, `admin/post/create`.
|
||||
* If action ID is not given, it will take the default value as specified in
|
||||
* [[Controller::defaultAction]].
|
||||
*/
|
||||
public $defaultRoute = 'default';
|
||||
/**
|
||||
@@ -115,9 +115,9 @@ class Module extends ServiceLocator
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param string $id the ID of this module
|
||||
* @param string $id the ID of this module
|
||||
* @param Module $parent the parent module (if any)
|
||||
* @param array $config name-value pairs that will be used to initialize the object properties
|
||||
* @param array $config name-value pairs that will be used to initialize the object properties
|
||||
*/
|
||||
public function __construct($id, $parent = null, $config = [])
|
||||
{
|
||||
@@ -173,7 +173,7 @@ class Module extends ServiceLocator
|
||||
/**
|
||||
* Sets the root directory of the module.
|
||||
* This method can only be invoked at the beginning of the constructor.
|
||||
* @param string $path the root directory of the module. This can be either a directory name or a path alias.
|
||||
* @param string $path the root directory of the module. This can be either a directory name or a path alias.
|
||||
* @throws InvalidParamException if the directory does not exist.
|
||||
*/
|
||||
public function setBasePath($path)
|
||||
@@ -191,7 +191,7 @@ class Module extends ServiceLocator
|
||||
* Returns the directory that contains the controller classes according to [[controllerNamespace]].
|
||||
* Note that in order for this method to return a value, you must define
|
||||
* an alias for the root namespace of [[controllerNamespace]].
|
||||
* @return string the directory that contains the controller classes.
|
||||
* @return string the directory that contains the controller classes.
|
||||
* @throws InvalidParamException if there is no alias defined for the root namespace of [[controllerNamespace]].
|
||||
*/
|
||||
public function getControllerPath()
|
||||
@@ -214,7 +214,7 @@ class Module extends ServiceLocator
|
||||
|
||||
/**
|
||||
* Sets the directory that contains the view files.
|
||||
* @param string $path the root directory of view files.
|
||||
* @param string $path the root directory of view files.
|
||||
* @throws InvalidParamException if the directory is invalid
|
||||
*/
|
||||
public function setViewPath($path)
|
||||
@@ -237,7 +237,7 @@ class Module extends ServiceLocator
|
||||
|
||||
/**
|
||||
* Sets the directory that contains the layout files.
|
||||
* @param string $path the root directory of layout files.
|
||||
* @param string $path the root directory of layout files.
|
||||
* @throws InvalidParamException if the directory is invalid
|
||||
*/
|
||||
public function setLayoutPath($path)
|
||||
@@ -253,8 +253,8 @@ class Module extends ServiceLocator
|
||||
* (must start with '@') and the array values are the corresponding paths or aliases.
|
||||
* See [[setAliases()]] for an example.
|
||||
* @param array $aliases list of path aliases to be defined. The array keys are alias names
|
||||
* (must start with '@') and the array values are the corresponding paths or aliases.
|
||||
* For example,
|
||||
* (must start with '@') and the array values are the corresponding paths or aliases.
|
||||
* For example,
|
||||
*
|
||||
* ~~~
|
||||
* [
|
||||
@@ -273,9 +273,9 @@ class Module extends ServiceLocator
|
||||
/**
|
||||
* Checks whether the child module of the specified ID exists.
|
||||
* This method supports checking the existence of both child and grand child modules.
|
||||
* @param string $id module ID. For grand child modules, use ID path relative to this module (e.g. `admin/content`).
|
||||
* @param string $id module ID. For grand child modules, use ID path relative to this module (e.g. `admin/content`).
|
||||
* @return boolean whether the named module exists. Both loaded and unloaded modules
|
||||
* are considered.
|
||||
* are considered.
|
||||
*/
|
||||
public function hasModule($id)
|
||||
{
|
||||
@@ -292,9 +292,9 @@ class Module extends ServiceLocator
|
||||
/**
|
||||
* Retrieves the child module of the specified ID.
|
||||
* This method supports retrieving both child modules and grand child modules.
|
||||
* @param string $id module ID (case-sensitive). To retrieve grand child modules,
|
||||
* use ID path relative to this module (e.g. `admin/content`).
|
||||
* @param boolean $load whether to load the module if it is not yet loaded.
|
||||
* @param string $id module ID (case-sensitive). To retrieve grand child modules,
|
||||
* use ID path relative to this module (e.g. `admin/content`).
|
||||
* @param boolean $load whether to load the module if it is not yet loaded.
|
||||
* @return Module|null the module instance, null if the module does not exist.
|
||||
* @see hasModule()
|
||||
*/
|
||||
@@ -325,9 +325,9 @@ class Module extends ServiceLocator
|
||||
|
||||
/**
|
||||
* Adds a sub-module to this module.
|
||||
* @param string $id module ID
|
||||
* @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 followings:
|
||||
*
|
||||
* - a [[Module]] object
|
||||
* - a configuration array: when [[getModule()]] is called initially, the array
|
||||
@@ -345,10 +345,10 @@ class Module extends ServiceLocator
|
||||
|
||||
/**
|
||||
* Returns the sub-modules in this module.
|
||||
* @param boolean $loadedOnly whether to return the loaded sub-modules only. If this is set false,
|
||||
* then all sub-modules registered in this module will be returned, whether they are loaded or not.
|
||||
* Loaded modules will be returned as objects, while unloaded modules as configuration arrays.
|
||||
* @return array the modules (indexed by their IDs)
|
||||
* @param boolean $loadedOnly whether to return the loaded sub-modules only. If this is set false,
|
||||
* then all sub-modules registered in this module will be returned, whether they are loaded or not.
|
||||
* Loaded modules will be returned as objects, while unloaded modules as configuration arrays.
|
||||
* @return array the modules (indexed by their IDs)
|
||||
*/
|
||||
public function getModules($loadedOnly = false)
|
||||
{
|
||||
@@ -419,9 +419,9 @@ class Module extends ServiceLocator
|
||||
* This method parses the specified route and creates the corresponding child module(s), controller and action
|
||||
* instances. It then calls [[Controller::runAction()]] to run the action with the given parameters.
|
||||
* If the route is empty, the method will use [[defaultRoute]].
|
||||
* @param string $route the route that specifies the action.
|
||||
* @param array $params the parameters to be passed to the action
|
||||
* @return mixed the result of the action.
|
||||
* @param string $route the route that specifies the action.
|
||||
* @param array $params the parameters to be passed to the action
|
||||
* @return mixed the result of the action.
|
||||
* @throws InvalidRouteException if the requested route cannot be resolved into an action successfully
|
||||
*/
|
||||
public function runAction($route, $params = [])
|
||||
@@ -459,9 +459,9 @@ class Module extends ServiceLocator
|
||||
* If any of the above steps resolves into a controller, it is returned together with the rest
|
||||
* part of the route which will be treated as the action ID. Otherwise, false will be returned.
|
||||
*
|
||||
* @param string $route the route consisting of module, controller and action IDs.
|
||||
* @return array|boolean If the controller is created successfully, it will be returned together
|
||||
* with the requested action ID. Otherwise false will be returned.
|
||||
* @param string $route the route consisting of module, controller and action IDs.
|
||||
* @return array|boolean If the controller is created successfully, it will be returned together
|
||||
* with the requested action ID. Otherwise false will be returned.
|
||||
* @throws InvalidConfigException if the controller class and its file do not match.
|
||||
*/
|
||||
public function createController($route)
|
||||
@@ -516,10 +516,10 @@ class Module extends ServiceLocator
|
||||
*
|
||||
* Note that this method does not check [[modules]] or [[controllerMap]].
|
||||
*
|
||||
* @param string $id the controller ID
|
||||
* @return Controller the newly created controller instance, or null if the controller ID is invalid.
|
||||
* @param string $id the controller ID
|
||||
* @return Controller the newly created controller instance, or null if the controller ID is invalid.
|
||||
* @throws InvalidConfigException if the controller class and its file name do not match.
|
||||
* This exception is only thrown when in debug mode.
|
||||
* This exception is only thrown when in debug mode.
|
||||
*/
|
||||
public function createControllerByID($id)
|
||||
{
|
||||
@@ -555,7 +555,7 @@ class Module extends ServiceLocator
|
||||
* This method is invoked right before an action of this module is to be executed (after all possible filters.)
|
||||
* You may override this method to do last-minute preparation for the action.
|
||||
* Make sure you call the parent implementation so that the relevant event is triggered.
|
||||
* @param Action $action the action to be executed.
|
||||
* @param Action $action the action to be executed.
|
||||
* @return boolean whether the action should continue to be executed.
|
||||
*/
|
||||
public function beforeAction($action)
|
||||
@@ -568,9 +568,9 @@ class Module extends ServiceLocator
|
||||
* You may override this method to do some postprocessing for the action.
|
||||
* Make sure you call the parent implementation so that the relevant event is triggered.
|
||||
* Also make sure you return the action result, whether it is processed or not.
|
||||
* @param Action $action the action just executed.
|
||||
* @param mixed $result the action return result.
|
||||
* @return mixed the processed action result.
|
||||
* @param Action $action the action just executed.
|
||||
* @param mixed $result the action return result.
|
||||
* @return mixed the processed action result.
|
||||
*/
|
||||
public function afterAction($action, $result)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user