![]() |
NanoFramework 1.4.0
A tiny PHP Framework
|
Handles I/O and HTTP methods. More...
Public Member Functions | |
__construct () | |
Protected Member Functions | |
fragment (string $page) | |
render () | |
getMethod () | |
isPost () | |
isGet () | |
isAjax () | |
getPost (?string $element=null) | |
getGet (?string $element=null) | |
redirect (string $location) | |
show404 (?string $message=null) | |
Protected Attributes | |
$data = [] | |
$rawData = [] | |
Handles I/O and HTTP methods.
This class must be inherited by all the controllers placed in app/Controllers, directly or indirectly. It provides the options to interact with the user as methods of input/output.
Definition at line 12 of file Controller.php.
__construct | ( | ) |
Default constructor, only present to allow specialized class to use theirs.
Definition at line 27 of file Controller.php.
|
protected |
This method sends the data contained in $data and $rawData to the View and returns the formatted page located at $page.
string | $page | The location of the page to parse, relative to APPPATH/Views. The ".html" can be ommited. |
Definition at line 38 of file Controller.php.
|
protected |
This method returns an element located in the "get" body of the request or the whole body.
If the $element parameter is provided, it returns the value at the given index or null
if it doesn't exist.
If no parameters are provided, it returns an associative array of all the values in the body or null
if the "get" part of the URL doesn't exist.
null | string | $element | the index of the value to retrieve or nothing to retrieve all the values |
Definition at line 139 of file Controller.php.
|
protected |
This method returns a string containing the name of the HTTP method used for the request.
Definition at line 73 of file Controller.php.
|
protected |
This method returns an element located in the "post" body of the request or the whole body.
If the $element parameter is provided, it returns the value at the given index or null
if it doesn't exist.
If no parameters are provided, it returns an associative array of all the values in the body or null
if the HTTP method isn't "post".
null | string | $element | the index of the value to retrieve or nothing to retrieve all the values |
Definition at line 119 of file Controller.php.
|
protected |
This method returns a boolean representing if the request has been made through with AJAX.
Definition at line 103 of file Controller.php.
|
protected |
This method returns a boolean representing if the request has been made with the "get" HTTP method.
Definition at line 93 of file Controller.php.
|
protected |
This method returns a boolean representing if the request has been made with the "post" HTTP method.
Definition at line 83 of file Controller.php.
|
protected |
This method throws a RedirectException that will be caught by Route::display in order to redirect the page.
string | $location | the URI where to redirect the page |
RedirectException | to bubble the information to Route::display |
Definition at line 155 of file Controller.php.
|
protected |
This method sends the data contained in $data and $rawData to the View and displays the formatted page located at the page corresponding to the Controller method after having it inserted in APPPATH/Views/template.html. For instance, using $this->render()
in the controller method Article::show()
will fetch the page located in APPPATH/Views/article/show.html.
Definition at line 51 of file Controller.php.
|
protected |
This method displays a 404 message to the user.
null | string | $message | The message to display |
Definition at line 165 of file Controller.php.
|
protected |
All the protected (escaped) data to send to the View.
Definition at line 17 of file Controller.php.
|
protected |
All the unprotected (unescaped) data to send to the View.
Definition at line 22 of file Controller.php.