Aplus Framework Docs

Home extends Controller
in package

Class Home.

Table of Contents

$loadModels  : bool
Set true to load models in properties.
$request  : Request
The matched route Request.
$response  : Response
The matched route Response.
__call()  : mixed
__construct()  : mixed
Controller constructor.
index()  : string
Renders the application homepage.
afterAction()  : mixed
Runs just after the class action method and before the destructor.
beforeAction()  : mixed
Runs just before the class action method and after the constructor.
prepareModels()  : static
Initialize models in properties.
render()  : string
Render a view.
validate()  : array<string, string>
Validate data.

Properties

$request

The matched route Request.

protected Request $request

$response

The matched route Response.

protected Response $response

Methods

__call()

public __call(string $method, array<int, mixed> $arguments) : mixed
Parameters
$method : string
$arguments : array<int, mixed>
Return values
mixed

__construct()

Controller constructor.

public __construct(Request $request, Response $response) : mixed
Parameters
$request : Request
$response : Response
Return values
mixed

index()

Renders the application homepage.

public index() : string
Return values
string

afterAction()

Runs just after the class action method and before the destructor.

protected afterAction(string $method, array<int, string> $arguments, bool $ran, mixed $result) : mixed

Used to finalize settings, filter output data, acts as a middleware between the action method and the final response.

Parameters
$method : string

The action method name

$arguments : array<int, string>

The action method arguments

$ran : bool

Indicates if the class action method was executed, true if it was not intercepted by the beforeAction method

$result : mixed

The returned value directly from beforeAction or from the class action method, if it was executed

Tags
see
RouteActions::beforeAction()
Return values
mixed

beforeAction()

Runs just before the class action method and after the constructor.

protected beforeAction(string $method, array<int, string> $arguments) : mixed

Used to prepare settings, filter input data, acts as a middleware between the routing and the class action method.

Parameters
$method : string

The action method name

$arguments : array<int, string>

The action method arguments

Return values
mixed

Returns a response (any value, except null) to prevent the route action execution or null to continue the process and call the action method

prepareModels()

Initialize models in properties.

protected prepareModels() : static
Tags
since
4
Return values
static

render()

Render a view.

protected render(string $view[, array<string, mixed> $variables = [] ][, string $instance = 'default' ]) : string
Parameters
$view : string

The view file

$variables : array<string, mixed> = []

The variables passed to the view

$instance : string = 'default'

The View service instance name

Return values
string

The rendered view contents

validate()

Validate data.

protected validate(array<string, mixed> $data, array<string, string[]|string> $rules[, array<string, string> $labels = [] ][, array<string, array<string, string>> $messages = [] ][, string $instance = 'default' ]) : array<string, string>
Parameters
$data : array<string, mixed>

The data to be validated

$rules : array<string, string[]|string>

An associative array with field as keys and values as rules

$labels : array<string, string> = []

An associative array with fields as keys and label as values

$messages : array<string, array<string, string>> = []

A multi-dimensional array with field names as keys and values as arrays where the keys are rule names and values are the custom error message strings

$instance : string = 'default'

The Validation service instance name

Return values
array<string, string>

An empty array if validation pass or an associative array with field names as keys and error messages as values

Search results