FrontController
The front controller designed to optionally handle all requests.
Tags
Table of Contents
- $currentRoute : string
- The route for the current request.
- $defaultParamValues : array<string|int, mixed>
- An optional 2D hash array of default request parameter values to use when those params are left off the request.
- $encryptedQuery : bool
- Boolean to flag if the GET query string is encrypted or not.
- $filters : array<string|int, mixed>
- An array of HTTP filters applied to each request to the front controller. Each member must implement FilterInterface!
- $logger : Logger
- Trace logger.
- $pageController : string
- The name of the page controller we want to invoke.
- $queryString : string
- The GET query string.
- $routes : array<string|int, mixed>
- An associative array of URIs to callable methods to service matching requests.
- __construct() : mixed
- The constructor method.
- addRoute() : FrontController
- Add a new route to map a URI to the callback that will service its requests, normally by invoking a controller class.
- decodeQueryParams() : string
- Static method to return the decoded GET paramters from an encrytpted tk value.
- encodeQuery() : string
- Static method for encoding a query string.
- generateSecureURL() : string
- Static method for generating an absolute, secure URL for a page controller.
- getDecodeQueryParams() : array<string|int, mixed>
- Static method to return the decoded GET paramters from an encrytpted tk value as an array of key/value pairs.
- getFilters() : array<string|int, mixed>
- Returns the array of filters currently attached to this FrontController.
- getPageController() : string
- Getter for the page controller.
- getRouteCallback() : callable
- Get the defined callback in the routes array for the URI provided.
- process() : Response
- Processes the supplied request by invoking the callable defined matching the request's URI.
- registerFilter() : mixed
- Add the supplied filter object to the list of filters ran on each request to the front controller.
- setEncrypt() : mixed
- Sets the encryption flag.
- value() : FrontController
- Method to allow the setting of default request param values to be used when they are left off the request URI.
Properties
$currentRoute
The route for the current request.
private
string
$currentRoute
Tags
$defaultParamValues
An optional 2D hash array of default request parameter values to use when those params are left off the request.
private
array<string|int, mixed>
$defaultParamValues
Tags
$encryptedQuery
Boolean to flag if the GET query string is encrypted or not.
private
bool
$encryptedQuery
= false
Tags
$filters
An array of HTTP filters applied to each request to the front controller. Each member must implement FilterInterface!
private
array<string|int, mixed>
$filters
= array()
Tags
$logger
Trace logger.
private
static Logger
$logger
= null
Tags
$pageController
The name of the page controller we want to invoke.
private
string
$pageController
Tags
$queryString
The GET query string.
private
string
$queryString
Tags
$routes
An associative array of URIs to callable methods to service matching requests.
private
array<string|int, mixed>
$routes
Tags
Methods
__construct()
The constructor method.
public
__construct() : mixed
Tags
Return values
mixed —addRoute()
Add a new route to map a URI to the callback that will service its requests, normally by invoking a controller class.
public
addRoute(string $URI, callable $callback) : FrontController
Parameters
- $URI : string
-
The URL to match, can include params within curly } braces.
- $callback : callable
-
The method to service the matched requests (should return a Response!).
Tags
Return values
FrontController —decodeQueryParams()
Static method to return the decoded GET paramters from an encrytpted tk value.
public
static decodeQueryParams(mixed $tk) : string
Parameters
- $tk : mixed
Tags
Return values
string —encodeQuery()
Static method for encoding a query string.
public
static encodeQuery(string $queryString) : string
Parameters
- $queryString : string
Tags
Return values
string —generateSecureURL()
Static method for generating an absolute, secure URL for a page controller.
public
static generateSecureURL(string $params) : string
Parameters
- $params : string
Tags
Return values
string —getDecodeQueryParams()
Static method to return the decoded GET paramters from an encrytpted tk value as an array of key/value pairs.
public
static getDecodeQueryParams(mixed $tk) : array<string|int, mixed>
Parameters
- $tk : mixed
Tags
Return values
array<string|int, mixed> —getFilters()
Returns the array of filters currently attached to this FrontController.
public
getFilters() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —getPageController()
Getter for the page controller.
public
getPageController() : string
Tags
Return values
string —getRouteCallback()
Get the defined callback in the routes array for the URI provided.
public
getRouteCallback(string $URI) : callable
Parameters
- $URI : string
-
The URI to search for.
Tags
Return values
callable —process()
Processes the supplied request by invoking the callable defined matching the request's URI.
public
process(Request $request) : Response
Parameters
- $request : Request
-
The request to process
Tags
Return values
Response —registerFilter()
Add the supplied filter object to the list of filters ran on each request to the front controller.
public
registerFilter(FilterInterface $filterObject) : mixed
Parameters
- $filterObject : FilterInterface
Tags
Return values
mixed —setEncrypt()
Sets the encryption flag.
public
setEncrypt(bool $encryptedQuery) : mixed
Parameters
- $encryptedQuery : bool
Tags
Return values
mixed —value()
Method to allow the setting of default request param values to be used when they are left off the request URI.
public
value(string $param, mixed $defaultValue) : FrontController
Parameters
- $param : string
-
The param name (as defined on the route between } braces)
- $defaultValue : mixed
-
The value to use