Piwik\
Provides (type safe) access methods for request parameters.
Ensure to handle parameters received with this class with care. Especially parameters received as string, array or json might contain malicious content. Those should never be used raw in templates or other output.
Note: For security reasons this class will automatically remove null byte sequences from string values.
The class defines the following methods:
__construct()
fromRequest()
— Creates a request object using GET and POST parameters of the current requestfromGet()
— Creates a request object using only GET parameters of the current requestfromPost()
— Creates a request object using only POST parameters of the current requestfromQueryString()
— Creates a request object using the parameters that can be extracted from the provided query stringgetParameter()
— Returns the requested parameter from the request object.getIntegerParameter()
— Returns the requested parameter from the request object.getFloatParameter()
— Returns the requested parameter from the request object.getStringParameter()
— Returns the requested parameter from the request object.getBoolParameter()
— Returns the requested parameter from the request object.getArrayParameter()
— Returns the requested parameter from the request object.getJsonParameter()
— Returns the requested parameter from the request object.getParameters()
— Returns an array containing all parameters of the request object__construct()
$requestParameters
(array
) —fromRequest()
Creates a request object using GET and POST parameters of the current request
Request
value.fromGet()
Creates a request object using only GET parameters of the current request
Request
value.fromPost()
Creates a request object using only POST parameters of the current request
Request
value.fromQueryString()
Creates a request object using the parameters that can be extracted from the provided query string
It accepts the following parameter(s):
$queryString
(string
) —It returns a Request
value.
getParameter()
Returns the requested parameter from the request object.
If the requested parameter can't be found and no default is provided an exception will be thrown
Note: It's recommend to use one of type-safe methods instead, if a certain type is expected:
getIntegerParameter
getFloatParameter
getStringParameter
getArrayParameter
getJSONParameter
It accepts the following parameter(s):
$name
(string
) —
$default
(mixed
) —
It returns a mixed
value.
getIntegerParameter()
Returns the requested parameter from the request object.
If no default is provided and the requested parameter either can't be found or is not of type integer an exception will be thrown
It accepts the following parameter(s):
$name
(string
) —
$default
(int
|null
) —
It returns a int
value.
getFloatParameter()
Returns the requested parameter from the request object.
If no default is provided and the requested parameter either can't be found or is not of type float an exception will be thrown
It accepts the following parameter(s):
$name
(string
) —
$default
(float
|null
) —
It returns a float
value.
getStringParameter()
Returns the requested parameter from the request object.
If no default is provided and the requested parameter either can't be found or is not of type string an exception will be thrown
It accepts the following parameter(s):
$name
(string
) —
$default
(string
|null
) —
It returns a string
value.
getBoolParameter()
Returns the requested parameter from the request object.
If no default is provided and the requested parameter either can't be found or can't be converted to boolean exception will be thrown
Values accepted as bool-ish: true: true, 'true', '1', 1 false: false, 'false', '0', 0
It accepts the following parameter(s):
$name
(string
) —
$default
(bool
|null
) —
It returns a bool
value.
getArrayParameter()
Returns the requested parameter from the request object.
If no default is provided and the requested parameter either can't be found or is not of type array an exception will be thrown
It accepts the following parameter(s):
$name
(string
) —
$default
(array
|null
) —
It returns a array
value.
getJsonParameter()
Returns the requested parameter from the request object.
If no default is provided and the requested parameter either can't be found or can't be json_decode'd an exception will be thrown
It accepts the following parameter(s):
$name
(string
) —
$default
(mixed
) —
It returns a mixed
value.
getParameters()
Returns an array containing all parameters of the request object
array
value.