Свойство | Тип | Описание | |
---|---|---|---|
$request | object | $this->request->controller or $this->request->action. | |
$response | object | Contains an instance of the Response object which aggregates the headers and body content to be written back to the client (browser) when the result of the request is rendered. |
Свойство | Тип | Описание | |
---|---|---|---|
$_autoConfig | array | Auto configuration properties. | |
$_classes | array | Lists Controller's class dependencies. For details on extending or replacing a class, please refer to that class's API. | |
$_render | array | - The 'type' key is the content type that will be rendered by default, unless another is
explicitly specified (defaults to 'html').
- The 'data' key contains an associative array of variables to be sent to the view,
including any variables created in set(), or if an action returns any variables (as an
associative array).
- When an action is invoked, it will by default attempt to render a response, set the
'auto' key to false to prevent this behavior.
- If you manually call render() within an action, the 'hasRendered' key stores this
state, so that responses are not rendered multiple times, either manually or automatically.
- The 'layout' key specifies the name of the layout to be used (defaults to 'default').
Typically, layout files are looked up as
|
Метод | Описание | |
---|---|---|
__construct ( array $config = [] ) : void | Constructor. | |
__invoke ( object $request, array $dispatchParams, array $options = [] ) : object | Called by the Dispatcher class to invoke an action. | |
redirect ( mixed $url, array $options = [] ) : object | Creates a redirect response by calling render() and providing a 'location' parameter. | |
render ( array $options = [] ) : object | Uses results (typically coming from a controller action) to generate content and headers for a Response object. | |
set ( array $data = [] ) : void | This method is used to pass along any data from the controller to the view and layout |
Метод | Описание | |
---|---|---|
_init ( ) : void | Populates the $response property with a new instance of the Response class passing it configuration, and sets some rendering options, depending on the incoming request. |
public __construct ( array $config = [] ) : void | ||
$config | array | Available configuration options are: - `'request'` _object|null_: Either a request object or `null`. - `'response'` _array_: Options for constructing the response object. - `'render'` _array_: Rendering control options. - `'classes'` _array_ |
Результат | void |
public __invoke ( object $request, array $dispatchParams, array $options = [] ) : object | ||
$request | object | The request object with URL and HTTP info for dispatching this action. |
$dispatchParams | array | The array of parameters that will be passed to the action. |
$options | array | The dispatch options for this action. |
Результат | object | Returns the response object associated with this controller. |
public redirect ( mixed $url, array $options = [] ) : object | ||
$url | mixed | The location to redirect to, provided as a string relative to the root of the application, a fully-qualified URL, or an array of routing parameters to be resolved to a URL. Post-processed by `Router::match()`. |
$options | array | Options when performing the redirect. Available options include: - `'status'` _integer_: The HTTP status code associated with the redirect. Defaults to `302`. - `'head'` _boolean_: Determines whether only headers are returned with the response. Defaults to `true`, in which case only headers and no body are returned. Set to `false` to render a body as well. - `'exit'` _boolean_: Exit immediately after rendering. Defaults to `false`. Because `redirect()` does not exit by default, you should always prefix calls with a `return` statement, so that the action is always immediately exited. |
Результат | object | Returns the instance of the `Response` object associated with this controller. |
public render ( array $options = [] ) : object | ||
$options | array | An array of options, as follows: - `'data'`: An associative array of variables to be assigned to the template. These are merged on top of any variables set in `Controller::set()`. - `'head'`: If true, only renders the headers of the response, not the body. Defaults to `false`. - `'template'`: The name of a template, which usually matches the name of the action. By default, this template is looked for in the views directory of the current controller, i.e. given a `PostsController` object, if template is set to `'view'`, the template path would be `views/posts/view.html.php`. Defaults to the name of the action being rendered. The options specified here are merged with the values in the `Controller::$_render` property. You may refer to it for other options accepted by this method. |
Результат | object | Returns the `Response` object associated with this `Controller` instance. |
protected array $_autoConfig | ||
Результат | array |
protected array $_classes | ||
Результат | array |
protected array $_render | ||
Результат | array |
public object $request | ||
Результат | object |
public object $response | ||
Результат | object |