abstract class Controller

Class Controller

Properties

string|null $username Contains the user's name or null
string $shortName Class short name.
Session $session To manage PHP Sessions.
TemplateRender $renderer Manage the renderer.
Request $request Request from client.
Response $response Response to client.
DebugTool $debugTool The debug tool used.
Logger $logger The logger.
protected Container|null $container Contains dependencies.
protected Translator $translator The translator manager.
private array $vars Array that contains the variables that will be passed to the template.

Methods

__construct()

Controller constructor.

Response
sendResponseTemplate(array $data = [])

Add new vars to render, render the template and send the Response.

Response
sendResponse(string $reply, int $status = Response::HTTP_OK)

Send the Response with data received.

RedirectResponse
redirect(string $destiny = '')

Send a RedirectResponse to destiny receive.

Response
runMethod(string $methodName)

No description

void
addToVar(string $name, mixed $value)

Add a new element to a value saved in the array that is passed to the template.

string
addResource(string $resourceName, boolean $relative = true)

Check if the resource is in the application's resource folder (for example, in the css or js folders of the skin folder). It's a specific file.

void
addCSS(string $file)

addCSS includes the CSS files to template.

void
addJS(string $file)

addJS includes the JS files to template.

array
getArrayPost()

Return body parameters $_POST values.

array
getArrayGet()

Return query string parameters $_GET values.

array
getArrayServer()

Return server and execution environment parameters from $_SERVER values.

array
getArrayHeaders()

Return headers from $_SERVER header values.

array
getArrayFiles()

Return uploaded files from $_FILES.

array
getArrayCookies()

Return cookies from $_COOKIES.

Details

at line 110
__construct()

Controller constructor.

at line 135
Response sendResponseTemplate(array $data = [])

Add new vars to render, render the template and send the Response.

Parameters

array $data

Return Value

Response

at line 149
Response sendResponse(string $reply, int $status = Response::HTTP_OK)

Send the Response with data received.

Parameters

string $reply
int $status

Return Value

Response

at line 163
RedirectResponse redirect(string $destiny = '')

Send a RedirectResponse to destiny receive.

Parameters

string $destiny

Return Value

RedirectResponse

at line 178
Response runMethod(string $methodName)

Parameters

string $methodName

Return Value

Response

at line 195
void addToVar(string $name, mixed $value)

Add a new element to a value saved in the array that is passed to the template.

It is used when what we are saving is an array and we want to add a new element to that array. IMPORTANT: The element only is added if is not empty.

Parameters

string $name
mixed $value

Return Value

void

at line 216
string addResource(string $resourceName, boolean $relative = true)

Check if the resource is in the application's resource folder (for example, in the css or js folders of the skin folder). It's a specific file.

If it can not be found, check if it is in the templates folder (for example in the css or js folders of the templates folder). It's a common file.

If it is not in either of the two, no route is specified (it will surely give loading error).

Parameters

string $resourceName is the name of the file (with extension)
boolean $relative set to false for use an absolute path.

Return Value

string the complete path of resource.

at line 240
void addCSS(string $file)

addCSS includes the CSS files to template.

Parameters

string $file

Return Value

void

at line 252
void addJS(string $file)

addJS includes the JS files to template.

Parameters

string $file

Return Value

void

at line 262
array getArrayPost()

Return body parameters $_POST values.

Return Value

array

at line 272
array getArrayGet()

Return query string parameters $_GET values.

Return Value

array

at line 282
array getArrayServer()

Return server and execution environment parameters from $_SERVER values.

Return Value

array

at line 292
array getArrayHeaders()

Return headers from $_SERVER header values.

Return Value

array

at line 302
array getArrayFiles()

Return uploaded files from $_FILES.

Return Value

array

at line 312
array getArrayCookies()

Return cookies from $_COOKIES.

Return Value

array