Свойство | Тип | Описание | |
---|---|---|---|
$action | the action that is currently being executed. This property will be set by Controller::run when it is called by Application to run an action. | ||
$defaultAction | the ID of the action that is used when the action ID is not specified in the request. Defaults to 'index'. | ||
$id | the ID of this controller. | ||
$layout | the name of the layout to be applied to this controller's views. This property mainly affects the behavior of Controller::render. Defaults to null, meaning the actual layout value should inherit that from [[module]]'s layout value. If false, no layout will be applied. | ||
$module | the module that this controller belongs to. |
Метод | Описание | |
---|---|---|
__construct ( string $id, |
||
actions ( ) | Declares external actions for the controller. | |
afterAction ( |
This method is invoked right after an action is executed. | |
beforeAction ( |
This method is invoked right before an action is executed. | |
bindActionParams ( |
Binds the parameters to the action. | |
createAction ( string $id ) : |
Creates an action based on the given action ID. | |
findLayoutFile ( |
Finds the applicable layout file. | |
getModules ( ) : |
Returns all ancestor modules of this controller. | |
getRoute ( ) : string | Returns the route of the current request. | |
getUniqueId ( ) : string | Returns the unique ID of the controller. | |
getView ( ) : |
Returns the view object that can be used to render views or view files. | |
getViewPath ( ) : string | Returns the directory containing view files for this controller. | |
render ( string $view, array $params = [] ) : string | Renders a view and applies layout if available. | |
renderContent ( string $content ) : string | Renders a static string by applying a layout. | |
renderFile ( string $file, array $params = [] ) : string | Renders a view file. | |
renderPartial ( string $view, array $params = [] ) : string | Renders a view without applying layout. | |
run ( string $route, array $params = [] ) : mixed | Runs a request specified in terms of a route. | |
runAction ( string $id, array $params = [] ) : mixed | Runs an action within this controller with the specified action ID and parameters. | |
setView ( |
Sets the view object to be used by this controller. | |
setViewPath ( string $path ) | Sets the directory that contains the view files. |
public __construct ( string $id, |
||
$id | string | the ID of this controller. |
$module | the module that this controller belongs to. | |
$config | array | name-value pairs that will be used to initialize the object properties. |
public actions ( ) |
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 run. |
public bindActionParams ( |
||
$action | the action to be bound with parameters. | |
$params | array | the parameters to be bound to the action. |
Результат | array | the valid parameters that the action can run with. |
public createAction ( string $id ) : |
||
$id | string | the action ID. |
Результат | the newly created action instance. Null if the ID doesn't resolve into any action. |
public findLayoutFile ( |
||
$view | the view object to render the layout file. | |
Результат | string | boolean | the layout file path, or false if layout is not needed. Please refer to [[render()]] on how to specify this parameter. |
public getModules ( ) : |
||
Результат | all ancestor modules that this controller is located within. |
public getUniqueId ( ) : string | ||
Результат | string | the controller ID that is prefixed with the module ID (if any). |
public getView ( ) : |
||
Результат | the view object that can be used to render views or view files. |
public getViewPath ( ) : string | ||
Результат | string | the directory containing the view files for this controller. |
public renderContent ( string $content ) : string | ||
$content | string | the static string being rendered |
Результат | string | the rendering result of the layout with the given static string as the `$content` variable. If the layout is disabled, the string will be returned back. |
public setView ( |
||
$view | the view object that can be used to render views or view files. |
public setViewPath ( string $path ) | ||
$path | string | the root directory of view files. |
public $action |
public $defaultAction |
public $layout |