Axiom (v1.2.0)

A lightweight PHP framework
axRequest Class Reference

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.

Detailed Description

Request Class.

Todo:
axRequest long description
Author:
Delespierre
License:
http://www.gnu.org/licenses/lgpl.html Lesser General Public Licence version 3

Definition at line 17 of file axRequest.class.php.


Constructor & Destructor Documentation

axRequest::__construct ( cache_dir = null)

Constructor.

Parameters:
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.


Member Function Documentation

axRequest::__get ( key)

__get implementation

Alias of axRequest::getParameter() using INPUT_REQUEST type.

Parameters:
string$key
Returns:
mixed

Definition at line 316 of file axRequest.class.php.

axRequest::__set ( key,
value 
)

__set implementation

Alias of axRequest::setParameter() with INPUT_REQUEST type.

Parameters:
string$key
mixed$value
Returns:
void

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.

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)
Exceptions:
RuntimeExceptionIn case of incorrect type
Returns:
axRequest

Definition at line 365 of file axRequest.class.php.

static axRequest::_determineType ( type) [static, protected]

Determine the real type according to the $type parameter.

Parameters:
mixed$type
Returns:
string

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

Parameters:
mixed$collectionAn 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
Exceptions:
InvalidArgumentExceptionIf the $method parameter is invalid
Returns:
axRequest

Definition at line 286 of file axRequest.class.php.

Tells if the given cookie exists (identified by its name)

Parameters:
string$name
Returns:
boolean

Definition at line 170 of file axRequest.class.php.

axRequest::getCookie ( name)

Get the given cookie (identified by its name)

Parameters:
string$name
Returns:
string

Definition at line 179 of file axRequest.class.php.

Get the request cookies.

Returns:
array

Definition at line 161 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()

string $varname string

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.

Parameters:
string$param_nameThe POST parameter name
Returns:
array

Definition at line 341 of file axRequest.class.php.

Get the $_FILES structure.

Returns:
array

Definition at line 350 of file axRequest.class.php.

axRequest::getHeader ( header)

Get the given request header value (identified by its name)

Parameters:
string$header
Returns:
string

Definition at line 117 of file axRequest.class.php.

Get the request headers.

Returns:
array

Definition at line 99 of file axRequest.class.php.

Get the HTTP request method.

Returns:
string

Definition at line 125 of file axRequest.class.php.

axRequest::getParameter ( name,
type = INPUT_REQUEST 
)

Get a request parameter.

Parameters:
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)
Exceptions:
InvalidArgumentExceptionIn case of invalid $type
Returns:
mixed

Definition at line 225 of file axRequest.class.php.

axRequest::getParameters ( type = INPUT_REQUEST)

Get all request parameters.

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)
Exceptions:
InvalidArgumentExceptionIn case of invalid $type
Returns:
array

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.

Parameters:
string$varname[optional] [default null]
Returns:
string

Definition at line 150 of file axRequest.class.php.

axRequest::headerExists ( header)

Tells if a header had been recieved (identified by its name)

Parameters:
string$header
Returns:
boolean

Definition at line 108 of file axRequest.class.php.

Resets the request object in its default state.

Returns:
void

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.

Warning:
The $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().
Note:
The filter will be applied on read so your changes won't take effects until you extract response data with axRequest::getParameters(), axRequest::getParameter() or axResponse::__get().
Parameters:
array$filterThe 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)
Exceptions:
InvalidArgumentExceptionIn case of invalid $type
Returns:
axRequest

Definition at line 204 of file axRequest.class.php.

axRequest::setParameter ( name,
value,
type = INPUT_REQUEST 
)

Manually set a request parameter.

Parameters:
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)
Exceptions:
InvalidArgumentExceptionIn case of invalid $type
Returns:
axRequest

Definition at line 265 of file axRequest.class.php.


Field Documentation

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.

Definition at line 404 of file axRequest.class.php.

Definition at line 403 of file axRequest.class.php.


The documentation for this class was generated from the following file:
 All Data Structures Files Functions Variables