Свойство | Тип | Описание | |
---|---|---|---|
$controllerMap | mapping from controller ID to controller configurations. Each name-value pair specifies the configuration of a single controller. A controller configuration can be either a string or an array. If the former, the string should be the fully qualified class name of the controller. If the latter, the array must contain a class element which specifies the controller's fully qualified class name, and the rest of the name-value pairs in the array are used to initialize the corresponding controller properties. For example, php [ 'account' => 'app\controllers\UserController', 'article' => [ 'class' => 'app\controllers\PostController', 'pageTitle' => 'something new', ], ] | ||
$controllerNamespace | the namespace that controller classes are in. This namespace will be used to load controller classes by prepending it to the controller class name. If not set, it will use the controllers sub-namespace under the namespace of this module. For example, if the namespace of this module is foo\bar, then the default controller namespace would be foo\bar\controllers. See also the guide section on autoloading to learn more about defining namespaces and how classes are loaded. | ||
$defaultRoute | 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]]. | ||
$id | an ID that uniquely identifies this module among other modules which have the same [[module|parent]]. | ||
$layout | the layout that should be applied for views within this module. This refers to a view name relative to [[layoutPath]]. If this is not set, it means the layout value of the [[module|parent module]] will be taken. If this is false, layout will be disabled within this module. | ||
$module | the parent module of this module. null if this module does not have a parent. | ||
$params | custom module parameters (name => value). |
Метод | Описание | |
---|---|---|
__construct ( string $id, |
Constructor. | |
afterAction ( |
This method is invoked right after an action within this module is executed. | |
beforeAction ( |
This method is invoked right before an action within this module is executed. | |
createController ( string $route ) : array | boolean | Creates a controller instance based on the given route. | |
createControllerByID ( string $id ) : |
Creates a controller based on the given controller ID. | |
getBasePath ( ) : string | Returns the root directory of the module. | |
getControllerPath ( ) : string | Returns the directory that contains the controller classes according to [[controllerNamespace]]. | |
getInstance ( ) : static | null | Returns the currently requested instance of this module class. | |
getLayoutPath ( ) : string | Returns the directory that contains layout view files for this module. | |
getModule ( string $id, boolean $load = true ) : |
Retrieves the child module of the specified ID. | |
getModules ( boolean $loadedOnly = false ) : array | Returns the sub-modules in this module. | |
getUniqueId ( ) : string | Returns an ID that uniquely identifies this module among all modules within the current application. | |
getVersion ( ) : string | Returns current module version. | |
getViewPath ( ) : string | Returns the directory that contains the view files for this module. | |
hasModule ( string $id ) : boolean | Checks whether the child module of the specified ID exists. | |
init ( ) | Initializes the module. | |
runAction ( string $route, array $params = [] ) : mixed | Runs a controller action specified by a route. | |
setAliases ( array $aliases ) | Defines path aliases. | |
setBasePath ( string $path ) | Sets the root directory of the module. | |
setInstance ( |
Sets the currently requested instance of this module class. | |
setLayoutPath ( string $path ) | Sets the directory that contains the layout files. | |
setModule ( string $id, |
Adds a sub-module to this module. | |
setModules ( array $modules ) | Registers sub-modules in the current module. | |
setVersion ( string | callable $version ) | Sets current module version. | |
setViewPath ( string $path ) | Sets the directory that contains the view files. |
Метод | Описание | |
---|---|---|
defaultVersion ( ) : string | Returns default module version. |
public __construct ( string $id, |
||
$id | string | the ID of this module. |
$parent | the parent module (if any). | |
$config | array | name-value pairs that will be used to initialize the object properties. |
public afterAction ( |
||
$action | the action just executed. | |
$result | mixed | the action return result. |
Результат | mixed | the processed action result. |
public beforeAction ( |
||
$action | the action to be executed. | |
Результат | boolean | whether the action should continue to be executed. |
public createControllerByID ( string $id ) : |
||
$id | string | the controller ID. |
Результат | the newly created controller instance, or `null` if the controller ID is invalid. |
protected defaultVersion ( ) : string | ||
Результат | string | the version of this module. |
public getBasePath ( ) : string | ||
Результат | string | the root directory of the module. |
public getControllerPath ( ) : string | ||
Результат | string | the directory that contains the controller classes. |
public static getInstance ( ) : static | null | ||
Результат | static | null | the currently requested instance of this module class, or `null` if the module class is not requested. |
public getLayoutPath ( ) : string | ||
Результат | string | the root directory of layout files. Defaults to "[[viewPath]]/layouts". |
public getModule ( string $id, boolean $load = true ) : |
||
$id | string | module ID (case-sensitive). To retrieve grand child modules, use ID path relative to this module (e.g. `admin/content`). |
$load | boolean | whether to load the module if it is not yet loaded. |
Результат | the module instance, `null` if the module does not exist. |
public getModules ( boolean $loadedOnly = false ) : array | ||
$loadedOnly | boolean | 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. |
Результат | array | the modules (indexed by their IDs). |
public getUniqueId ( ) : string | ||
Результат | string | the unique ID of the module. |
public getVersion ( ) : string | ||
Результат | string | the version of this module. |
public getViewPath ( ) : string | ||
Результат | string | the root directory of view files. Defaults to "[[basePath]]/views". |
public init ( ) |
public setAliases ( array $aliases ) | ||
$aliases | array | 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, ```php [ '@models' => '@app/models', // an existing alias '@backend' => __DIR__ . '/../backend', // a directory ] ``` |
public setBasePath ( string $path ) | ||
$path | string | the root directory of the module. This can be either a directory name or a path alias. |
public static setInstance ( |
||
$instance | the currently requested instance of this module class. If it is `null`, the instance of the calling class will be removed, if any. |
public setLayoutPath ( string $path ) | ||
$path | string | the root directory or path alias of layout files. |
public setModule ( string $id, |
||
$id | string | module ID. |
$module | the sub-module to be added to this module. This can be one of the following: - a [[Module]] object - a configuration array: when [[getModule()]] is called initially, the array will be used to instantiate the sub-module - `null`: the named sub-module will be removed from this module |
public setModules ( array $modules ) | ||
$modules | array | modules (id => module configuration or instances). |
public setVersion ( string | callable $version ) | ||
$version | string | callable | the version of this module. Version can be specified as a PHP callback, which can accept module instance as an argument and should return the actual version. For example: ```php function (Module $module) { //return string } ``` |
public setViewPath ( string $path ) | ||
$path | string | the root directory of view files. |
public $controllerMap |
public $controllerNamespace |
public $defaultRoute |
public $id |
public $layout |
public $module |