Aplus Framework MVC Library

Controller extends RouteActions
in package

Class Controller.

Table of Contents

$request  : Request
The matched route Request.
$response  : Response
The matched route Response.
__construct()  : mixed
Controller constructor.
prepareModel()  : static
Initialize $model with property type name.
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

__construct()

Controller constructor.

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

prepareModel()

Initialize $model with property type name.

protected prepareModel() : static
Tags
since
3.6
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