Action
About 1 min
Action
Abstract controller action class.
This controller handles actions and responses using views
Properties
view
public ViewRenderer $view
methods
protected array $methods
Methods
__construct
public __construct(?string $name): void
Parameters
Parameter | Type | Description |
---|---|---|
$name | string |
initialize
Initializes the controller action with the given request.
public initialize(Request $request): ?Response
This method checks if the request is an instance of HTTP, is not an XMLHttpRequest, the application is not null, the response type is 'html', and the application configuration has a 'layout' setting. If all these conditions are met, it sets the view layout to the specified layout in the application configuration.
Parameters
Parameter | Type | Description |
---|---|---|
$request | Request | the request object to initialize the action with |
registerMethod
Registers a new method with the given name and callback.
public registerMethod(string $name, callable $callback): bool
Parameters
Parameter | Type | Description |
---|---|---|
$name | string | the name of the method to register |
$callback | callable | the callback function to associate with the method |
runAction
Executes the specified action and returns the response.
public runAction(string $actionName, array $actionArgs = [], bool $namedActionArgs = false): Response
Parameters
Parameter | Type | Description |
---|---|---|
$actionName | string | the name of the action to execute |
$actionArgs | array | the arguments to pass to the action |
$namedActionArgs | bool | whether the action arguments are named |
view
Loads a view.
protected view(string $view, array $data = []): void
Parameters
Parameter | Type | Description |
---|---|---|
$view | string | the name of the view to load |
$data | array | the data to pass to the view |
layout
Sets the layout view for the current controller.
protected layout(string $view): void
This method sets the layout view that will be used to render the response.
Parameters
Parameter | Type | Description |
---|---|---|
$view | string | the name of the layout view to be used |
Generated by Hazaar API Doc Generator