Request Class. More...
Public Member Functions | |
| __construct ($cache_dir=null) | |
| Constructor. | |
| reset () | |
| Resets the request object in its default state. | |
| getHeaders () | |
| Get the request headers. | |
| headerExists ($header) | |
| Tells if a header had been recieved (identified by its name) | |
| getHeader ($header) | |
| Get the given request header value (identified by its name) | |
| getMethod () | |
| Get the HTTP request method. | |
| getEnv ($varname) | |
| Get an environment variable (provided by Apache for instance) | |
| getServer ($varname=null) | |
| Get server variable. | |
| getCookies () | |
| Get the request cookies. | |
| cookieExists ($name) | |
| Tells if the given cookie exists (identified by its name) | |
| getCookie ($name) | |
| Get the given cookie (identified by its name) | |
| setFilter (array $filter, $type=INPUT_REQUEST) | |
| Set a request variable filter. | |
| getParameter ($name, $type=INPUT_REQUEST) | |
| Get a request parameter. | |
| getParameters ($type=INPUT_REQUEST) | |
| Get all request parameters. | |
| setParameter ($name, $value, $type=INPUT_REQUEST) | |
| Manually set a request parameter. | |
| add ($collection, $method=self::PROPERTY_MERGE, $type=INPUT_REQUEST) | |
| Add a collection of parameters. | |
| __get ($key) | |
| __get implementation | |
| __set ($key, $value) | |
| __set implementation | |
| getFile ($param_name) | |
| Get the given file (identified by the parameter name) | |
| getFiles () | |
| Get the $_FILES structure. | |
Data Fields | |
| const | PROPERTY_MERGE = 1 |
| const | PROPERTY_ADD = 2 |
Protected Member Functions | |
| _applyFilter ($type) | |
| Applies a filter on the given variable type. | |
Static Protected Member Functions | |
| static | _determineType ($type) |
Determine the real type according to the $type parameter. | |
Protected Attributes | |
| $_headers | |
| Request headers. | |
| $_post | |
| HTTP POST parameters. | |
| $_get | |
| HTTP GET parameters. | |
| $_request | |
| Request parameters (POST + GET) | |
| $_cookies | |
| Request cookies. | |
| $_files | |
| HTTP POST files. | |
| $_filters | |
| Request variables filters. | |
| $_browscap | |
| Browser capabilities instance. | |
Request Class.
Definition at line 17 of file axRequest.class.php.
| axRequest::__construct | ( | $ | cache_dir = null | ) |
Constructor.
| string | $cache_dir | [optional] [default null] The cache dir for the browscap settings (null to disable cache) |
Definition at line 71 of file axRequest.class.php.
| axRequest::__get | ( | $ | key | ) |
__get implementation
Alias of axRequest::getParameter() using INPUT_REQUEST type.
| string | $key |
Definition at line 316 of file axRequest.class.php.
| axRequest::__set | ( | $ | key, |
| $ | value | ||
| ) |
__set implementation
Alias of axRequest::setParameter() with INPUT_REQUEST type.
| string | $key | |
| mixed | $value |
Definition at line 329 of file axRequest.class.php.
| axRequest::_applyFilter | ( | $ | type | ) | [protected] |
Applies a filter on the given variable type.
Will return false if no filter is defined for this type.
| mixed | $type | [optional] [default INPUT_REQUEST] The kind of request parameters to filter. Can be either `INPUT_GET`, `INPUT_POST`, `INPUT_REQUEST`, `INPUT_COOKIE` or string `get`, `post`, `request`, `cookie` (the case is insensitive) |
| RuntimeException | In case of incorrect type |
Definition at line 365 of file axRequest.class.php.
| static axRequest::_determineType | ( | $ | type | ) | [static, protected] |
Determine the real type according to the $type parameter.
| mixed | $type |
Definition at line 381 of file axRequest.class.php.
| axRequest::add | ( | $ | collection, |
| $ | method = self::PROPERTY_MERGE, |
||
| $ | type = INPUT_REQUEST |
||
| ) |
Add a collection of parameters.
The method parameter can be either 'add', 'merge', axRequest::PROPERTY_MERGE, or axRequest::PROPERTY_ADD
| mixed | $collection | An associative structure to import |
| mixed | $method | [optional] [default axRequest::PROPERTY_MERGE] The merge mode |
| mixed | $type | [optional] [default INPUT_REQUEST] The type of variables to be added |
| InvalidArgumentException | If the $method parameter is invalid |
Definition at line 286 of file axRequest.class.php.
| axRequest::cookieExists | ( | $ | name | ) |
Tells if the given cookie exists (identified by its name)
| string | $name |
Definition at line 170 of file axRequest.class.php.
| axRequest::getCookie | ( | $ | name | ) |
Get the given cookie (identified by its name)
| string | $name |
Definition at line 179 of file axRequest.class.php.
| axRequest::getEnv | ( | $ | varname | ) |
Get an environment variable (provided by Apache for instance)
This method is an alias of PHP's getenv()
Definition at line 138 of file axRequest.class.php.
| axRequest::getFile | ( | $ | param_name | ) |
Get the given file (identified by the parameter name)
Will return null if the file isn't set in $_FILES structure.
| string | $param_name | The POST parameter name |
Definition at line 341 of file axRequest.class.php.
| axRequest::getHeader | ( | $ | header | ) |
Get the given request header value (identified by its name)
| string | $header |
Definition at line 117 of file axRequest.class.php.
| axRequest::getParameter | ( | $ | name, |
| $ | type = INPUT_REQUEST |
||
| ) |
Get a request parameter.
| string | $name | |
| mixed | $type | [optional] [default INPUT_REQUEST] The kind of request parameters to filter. Can be either `INPUT_GET`, `INPUT_POST`, `INPUT_REQUEST`, `INPUT_COOKIE` or string `get`, `post`, `request`, `cookie` (the case is insensitive) |
| InvalidArgumentException | In case of invalid $type |
Definition at line 225 of file axRequest.class.php.
| axRequest::getParameters | ( | $ | type = INPUT_REQUEST | ) |
Get all request parameters.
| mixed | $type | [optional] [default INPUT_REQUEST] The kind of request parameters to filter. Can be either `INPUT_GET`, `INPUT_POST`, `INPUT_REQUEST`, `INPUT_COOKIE` or string `get`, `post`, `request`, `cookie` (the case is insensitive) |
| InvalidArgumentException | In case of invalid $type |
Definition at line 244 of file axRequest.class.php.
| axRequest::getServer | ( | $ | varname = null | ) |
Get server variable.
If not variable is specified, the complete $_SERVER structure is returned.
| string | $varname | [optional] [default null] |
Definition at line 150 of file axRequest.class.php.
| axRequest::headerExists | ( | $ | header | ) |
Tells if a header had been recieved (identified by its name)
| string | $header |
Definition at line 108 of file axRequest.class.php.
| axRequest::reset | ( | ) |
Resets the request object in its default state.
Definition at line 86 of file axRequest.class.php.
| axRequest::setFilter | ( | array $ | filter, |
| $ | type = INPUT_REQUEST |
||
| ) |
Set a request variable filter.
When you set a variable filter, all data you may extract with axRequest::getParameters(), axRequest::getParameter() or axResponse::__get() are filtered using filter_var_array before they are returned, allowing you to set sanitize or validation filter, for instance to prevent injection attacks.
$filter parameter must be compliant with the $definition parameter of filter_var_array. If the filtering ends up with an error, all variables registered in axResponse are erased and a RuntimeException will be thrown when accessing datas with axResponse::getVar(), axResponse::__get() or axResponse::getVars().| array | $filter | The filter description (must be compliant with filter_var_array filter description) |
| mixed | $type | [optional] [default INPUT_REQUEST] The kind of request parameters to filter. Can be either `INPUT_GET`, `INPUT_POST`, `INPUT_REQUEST`, `INPUT_COOKIE` or string `get`, `post`, `request`, `cookie` (the case is insensitive) |
| InvalidArgumentException | In case of invalid $type |
Definition at line 204 of file axRequest.class.php.
| axRequest::setParameter | ( | $ | name, |
| $ | value, | ||
| $ | type = INPUT_REQUEST |
||
| ) |
Manually set a request parameter.
| string | $name | |
| mixed | $value | |
| mixed | $type | [optional] [default INPUT_REQUEST] The kind of request parameters to filter. Can be either `INPUT_GET`, `INPUT_POST`, `INPUT_REQUEST`, `INPUT_COOKIE` or string `get`, `post`, `request`, `cookie` (the case is insensitive) |
| InvalidArgumentException | In case of invalid $type |
Definition at line 265 of file axRequest.class.php.
Browscap axRequest::$_browscap [protected] |
Browser capabilities instance.
Definition at line 65 of file axRequest.class.php.
array axRequest::$_cookies [protected] |
Request cookies.
Definition at line 47 of file axRequest.class.php.
array axRequest::$_files [protected] |
HTTP POST files.
Definition at line 53 of file axRequest.class.php.
array axRequest::$_filters [protected] |
Request variables filters.
Definition at line 59 of file axRequest.class.php.
array axRequest::$_get [protected] |
HTTP GET parameters.
Definition at line 35 of file axRequest.class.php.
array axRequest::$_headers [protected] |
Request headers.
Definition at line 23 of file axRequest.class.php.
array axRequest::$_post [protected] |
HTTP POST parameters.
Definition at line 29 of file axRequest.class.php.
array axRequest::$_request [protected] |
Request parameters (POST + GET)
Definition at line 41 of file axRequest.class.php.
| const axRequest::PROPERTY_ADD = 2 |
Definition at line 404 of file axRequest.class.php.
| const axRequest::PROPERTY_MERGE = 1 |
Definition at line 403 of file axRequest.class.php.