FilterInputHandler
in package
This is the FilterInputHandler class.
The purpose of this class is to filter (validate and sanitize) the given values according to the given filter configuration.
Use examples: It is commonly used to filter the parameters of a request,...
Tags
Table of Contents
ARRAY_PARAMS | = [\FWK\Enums\Parameters::FILTER_CUSTOMTAG, \FWK\Enums\Parameters::FILTER_OPTION, \FWK\Enums\Parameters::FILTER_CUSTOMTAG_INTERVAL, \FWK\Enums\Parameters::VALUES, \FWK\Enums\Parameters::OPTIONS, \FWK\Enums\Parameters::BRANDS_LIST, \FWK\Enums\Parameters::CATEGORY_ID_LIST, \FWK\Enums\Parameters::HASHES] | |
---|---|---|
DATE_PARAMS | = [\FWK\Enums\Parameters::FROM_DATE, \FWK\Enums\Parameters::TO_DATE] | |
DYNAMIC_NAME_PARAM_DELIMITER | = '_' | |
DYNAMIC_NAME_PARAMS | = [\FWK\Enums\Parameters::CUSTOM_TAGS, \FWK\Enums\Parameters::FILTER_CUSTOMTAG, \FWK\Enums\Parameters::FILTER_CUSTOMTAG_RANGE, \FWK\Enums\Parameters::FILTER_CUSTOMTAG_INTERVAL, \FWK\Enums\Parameters::FILTER_OPTION, \FWK\Enums\Parameters::OPTION_ID, \FWK\Enums\Parameters::RETURN_QUANTITY, \FWK\Enums\Parameters::RETURN_CHECK] | |
PARAMS_FROM_GET | = 1 | |
PARAMS_FROM_POST | = 3 | |
PARAMS_FROM_POST_DATA_OBJECT | = 4 | |
PARAMS_FROM_QUERY_STRING | = 2 | |
getAvailableDinamicParam() | This method returns null if the given param is not a dynamic param (see filterInputHandler::DYNAMIC_NAME_PARAMS), otherwise returns a two positions array where position 0 contains the name of the dynamic param and the position 1 contains its value. | : array<string|int, mixed>|null |
getFilterFilterInputs() | This method gets the params of the specified origin and applies to them the specified filters defined in the given $availableParams. | : array<string|int, mixed> |
Constants
ARRAY_PARAMS
public
mixed
ARRAY_PARAMS
= [\FWK\Enums\Parameters::FILTER_CUSTOMTAG, \FWK\Enums\Parameters::FILTER_OPTION, \FWK\Enums\Parameters::FILTER_CUSTOMTAG_INTERVAL, \FWK\Enums\Parameters::VALUES, \FWK\Enums\Parameters::OPTIONS, \FWK\Enums\Parameters::BRANDS_LIST, \FWK\Enums\Parameters::CATEGORY_ID_LIST, \FWK\Enums\Parameters::HASHES]
DATE_PARAMS
public
mixed
DATE_PARAMS
= [\FWK\Enums\Parameters::FROM_DATE, \FWK\Enums\Parameters::TO_DATE]
DYNAMIC_NAME_PARAM_DELIMITER
public
mixed
DYNAMIC_NAME_PARAM_DELIMITER
= '_'
DYNAMIC_NAME_PARAMS
public
mixed
DYNAMIC_NAME_PARAMS
= [\FWK\Enums\Parameters::CUSTOM_TAGS, \FWK\Enums\Parameters::FILTER_CUSTOMTAG, \FWK\Enums\Parameters::FILTER_CUSTOMTAG_RANGE, \FWK\Enums\Parameters::FILTER_CUSTOMTAG_INTERVAL, \FWK\Enums\Parameters::FILTER_OPTION, \FWK\Enums\Parameters::OPTION_ID, \FWK\Enums\Parameters::RETURN_QUANTITY, \FWK\Enums\Parameters::RETURN_CHECK]
PARAMS_FROM_GET
public
mixed
PARAMS_FROM_GET
= 1
PARAMS_FROM_POST
public
mixed
PARAMS_FROM_POST
= 3
PARAMS_FROM_POST_DATA_OBJECT
public
mixed
PARAMS_FROM_POST_DATA_OBJECT
= 4
PARAMS_FROM_QUERY_STRING
public
mixed
PARAMS_FROM_QUERY_STRING
= 2
Methods
getAvailableDinamicParam()
This method returns null if the given param is not a dynamic param (see filterInputHandler::DYNAMIC_NAME_PARAMS), otherwise returns a two positions array where position 0 contains the name of the dynamic param and the position 1 contains its value.
public
static getAvailableDinamicParam(string $param) : array<string|int, mixed>|null
Parameters
- $param : string
Return values
array<string|int, mixed>|null —getFilterFilterInputs()
This method gets the params of the specified origin and applies to them the specified filters defined in the given $availableParams.
public
static getFilterFilterInputs(mixed $orginQueryParams, array<string|int, mixed> $availableParams) : array<string|int, mixed>
It returns the filtered params with its values.
Parameters
- $orginQueryParams : mixed
-
Could be string as FilterParams::PARAMS_FROM_GET, FilterParams::PARAMS_FROM_QUERY_STRING or FilterParams::PARAMS_FROM_POST, or an array with the varaibles and values.
- $availableParams : array<string|int, mixed>
-
each node must be the param name, and the filter to apply to the param.