\Hazaar\Application
Request
Abstract
Summary
Methods Properties Constants
get
has
set
No constants
Properties
$action
$action
$base_path
$base_path
The original path excluding the application base path
$config
$config
$controller
$controller
$dispatched
$dispatched
$exception
$exception
$params
$params
$path
$path
The path excluding the controller and action references
$raw_path
$raw_path
The path without the controller reference in it
$response_type
$response_type
Methods
__construct()
__construct()
__get()
__get($key)

Parameters

$key

No description

__unset()
__unset($key)

Parameters

$key

No description

count()
count()
evaluate()
evaluate($string)

Parses a request URL string and turns it into a controller name, action name, and argument list. This is essentially the core method of Hazaar that decides what to execute based on

Parameters

$string

No description

get()
get($key, $default = null) : string|mixed
Retrieve a request value.

These values can be sent in a number of ways.

Only JSON encoded request bodies support data typing. All other request values will be strings.

Tags

Since

2.3.44

Parameters

$keymixed

The data key to retrieve

$defaultmixed

If the value is not set, use this default value.

Returns

\Hazaar\Application\string|mixed

Most of the time this will return a string, unless data-typing is available when using JSON requests.

getActionName()
getActionName()
getBasePath()
getBasePath()
getControllerName()
getControllerName()
getException()
getException()
getParams()
getParams($filter = null) : array
Return an array of request parameters as key/value pairs.

Parameters

$filterarray

Only include parameters with keys specified in this filter.

Returns

array
getPath()
getPath() : string

Return the request path suffix. This is the path that comes after the controller and action path elements. Take the path /myapp/public/index/test/foo/bar for example. In this case this method would return ‘/foo/bar’.

Tags

Since

1.0.0

Returns

string

The path suffix of the request URI

getRawPath()
getRawPath() : string

Return the complete raw request URI relative to the application path. That is the full path including the controller and action elements. Take the path /myapp/public/index/test/foo/bar for example. In this case this method would return ‘/index/test/foo/bar’.

Tags

Since

1.0.0

Returns

string

The raw request URI relative to the application path.

getResponseType()
getResponseType() : string
Returns the requested response type.

The requested response type can be set in the request itself. If it is not set, then the default will be ‘html’ or the X-Requested-With header will be checked to determine the response type.

This method is used internally to determine the response type to send when one has not been explicitly used. Normally the response type is determined by the Controller\Response object type returned by a controller action.

Returns

string
get_bool()
get_bool($key, $default = null) : boolean
Retrieve an boolean value from the request

The most common requests will not provide data typing and data value will always be a string. This method will automatically return the requested value as an boolean unless it is NULL or not set. In which case either NULL or the default value will be returned.

This internally uses the boolify() function so the usual bool strings are supported (t, f, true, false, 0, 1, on, off, etc).

Tags

Since

2.3.44

Parameters

$keymixed

The key of the request value to return.

$defaultmixed

A default value to use if the value is NULL or not set.

Returns

boolean
get_float()
get_float($key, $default = null) : float
Retrieve an float value from the request

The most common requests will not provide data typing and data value will always be a string. This method will automatically return the requested value as an float unless it is NULL or not set. In which case either NULL or the default value will be returned.

Tags

Since

2.3.44

Parameters

$keymixed

The key of the request value to return.

$defaultmixed

A default value to use if the value is NULL or not set.

Returns

\Hazaar\Application\float
get_int()
get_int($key, $default = null) : int
Retrieve an integer value from the request

The most common requests will not provide data typing and data value will always be a string. This method will automatically return the requested value as an integer unless it is NULL or not set. In which case either NULL or the default value will be returned.

Tags

Since

2.3.44

Parameters

$keymixed

The key of the request value to return.

$defaultmixed

A default value to use if the value is NULL or not set.

Returns

int
has()
has($keys) : boolean
Check to see if a request value has been set

Parameters

$keysmixed

The key of the request value to check for.

Returns

boolean

True if the value is set, False otherwise.

hasException()
hasException()
hasParams()
hasParams()
isDELETE()
isDELETE()
isDispatched()
isDispatched()
isGET()
isGET()
isMobileDevice()
isMobileDevice() : boolean
Detect if a request originated on a mobile device

This method will return true to indicate that the requesting device is a mobile browser. It uses the freely available script from detectmobilebrowsers.com

Returns

boolean

True to indicate requesting device is a mobile browser, false otherwise.

isPOST()
isPOST()
isPUT()
isPUT()
method()
method()
processRoute()
processRoute()
referer()
referer()
remove()
remove($key)

Parameters

$key

No description

resetAction()
resetAction()
set()
set($key, $value)
Set a request value.

This would not normally be used and has no internal implications on how the application will function as this data is not processed in any way. However setting request data may be useful in your application when reusing/repurposing controller actions so that they may be called from somewhere else in your application.

Parameters

$keymixed

The key value to set.

$valuemixed

The new value.

setActionName()
setActionName($name)

Parameters

$name

No description

setControllerName()
setControllerName($name)

Parameters

$name

No description

setDispatched()
setDispatched($flag = true)

Parameters

$flag

No description

setException()
setException($e)

Parameters

$e\Hazaar\Application\Exception

No description

setParams()
setParams($array)

Parameters

$arrayarray

No description

setResponseType()
setResponseType($type)

Parameters

$type

No description