class Login extends Controller

Class Login

Constants

COOKIE_EXPIRATION

Cookie time expiration.

COOKIE_EXPIRATION_MIN

Minimum cookie time expiration.

Properties

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

Methods

__construct()

Controller constructor.

from Controller
Response
sendResponseTemplate(array $data = [])

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

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

Send the Response with data received.

from Controller
RedirectResponse
redirect(string $destiny = '')

Send a RedirectResponse to destiny receive.

from Controller
Response
runMethod(string $methodName)

No description

from Controller
void
addToVar(string $name, mixed $value)

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

from Controller
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.

from Controller
void
addCSS(string $file)

addCSS includes the CSS files to template.

from Controller
void
addJS(string $file)

addJS includes the JS files to template.

from Controller
array
getArrayPost()

Return body parameters $_POST values.

from Controller
array
getArrayGet()

Return query string parameters $_GET values.

from Controller
array
getArrayServer()

Return server and execution environment parameters from $_SERVER values.

from Controller
array
getArrayHeaders()

Return headers from $_SERVER header values.

from Controller
array
getArrayFiles()

Return uploaded files from $_FILES.

from Controller
array
getArrayCookies()

Return cookies from $_COOKIES.

from Controller
array
pageDetails()

Returns the page details.

Response
indexMethod()

The start point of the controller.

RedirectResponse
redirectToController()

Redirect to controller, default or selected by the user.

string|null
getCookieUser($remember)

Returns the cookie from the user

adjustCookieUser(int $time = 0, int $remember = 0)

Adjust auth cookie user.

void
clearCookieUser()

Clear the cookie user.

Response
main()

Main is invoked if method is not specified.

RedirectResponse
logoutMethod()

Close the user session and go to the main page

string|null
getUserName()

Returns the user name if setted or null.

User|null
getUser()

Returns the user if setted or null.

bool
setUser(string $userName, string $password, bool $remember = false)

Set cookie's user.

Details

in Controller at line 110
__construct()

Controller constructor.

in Controller 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

in Controller 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

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

Send a RedirectResponse to destiny receive.

Parameters

string $destiny

Return Value

RedirectResponse

in Controller at line 178
Response runMethod(string $methodName)

Parameters

string $methodName

Return Value

Response

in Controller 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

in Controller 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.

in Controller at line 240
void addCSS(string $file)

addCSS includes the CSS files to template.

Parameters

string $file

Return Value

void

in Controller at line 252
void addJS(string $file)

addJS includes the JS files to template.

Parameters

string $file

Return Value

void

in Controller at line 262
array getArrayPost()

Return body parameters $_POST values.

Return Value

array

in Controller at line 272
array getArrayGet()

Return query string parameters $_GET values.

Return Value

array

in Controller at line 282
array getArrayServer()

Return server and execution environment parameters from $_SERVER values.

Return Value

array

in Controller at line 292
array getArrayHeaders()

Return headers from $_SERVER header values.

Return Value

array

in Controller at line 302
array getArrayFiles()

Return uploaded files from $_FILES.

Return Value

array

in Controller at line 312
array getArrayCookies()

Return cookies from $_COOKIES.

Return Value

array

at line 58
array pageDetails()

Returns the page details.

Return Value

array

at line 74
Response indexMethod()

The start point of the controller.

Return Value

Response

at line 114
private RedirectResponse redirectToController()

Redirect to controller, default or selected by the user.

Return Value

RedirectResponse

at line 130
string|null getCookieUser($remember)

Returns the cookie from the user

Parameters

$remember

Return Value

string|null

at line 156
private adjustCookieUser(int $time = 0, int $remember = 0)

Adjust auth cookie user.

Parameters

int $time
int $remember

at line 176
private void clearCookieUser()

Clear the cookie user.

Return Value

void

at line 191
private Response main()

Main is invoked if method is not specified.

Load the view of the login form, if there is no user identified.

Return Value

Response

at line 205
RedirectResponse logoutMethod()

Close the user session and go to the main page

Return Value

RedirectResponse

at line 217
string|null getUserName()

Returns the user name if setted or null.

Return Value

string|null

at line 227
User|null getUser()

Returns the user if setted or null.

Return Value

User|null

at line 241
bool setUser(string $userName, string $password, bool $remember = false)

Set cookie's user.

Parameters

string $userName
string $password
bool $remember

Return Value

bool