protected static function RestfulBase::isValidOperatorsForFilter in RESTful 7
Check if an operator is valid for filtering.
Parameters
array $operators: The array of operators.
Throws
1 call to RestfulBase::isValidOperatorsForFilter()
- RestfulBase::parseRequestForListFilter in plugins/
restful/ RestfulBase.php - Filter the query for list.
1 method overrides RestfulBase::isValidOperatorsForFilter()
- RestfulDataProviderEFQ::isValidOperatorsForFilter in plugins/
restful/ RestfulDataProviderEFQ.php - Overrides \RestfulBase::isValidOperatorsForFilter().
File
- plugins/
restful/ RestfulBase.php, line 1053 - Contains RestfulBase.
Class
- RestfulBase
- Class \RestfulBase
Code
protected static function isValidOperatorsForFilter(array $operators) {
$allowed_operators = array(
'=',
'>',
'<',
'>=',
'<=',
'<>',
'!=',
'BETWEEN',
'CONTAINS',
'IN',
'NOT IN',
'STARTS_WITH',
);
foreach ($operators as $operator) {
if (!in_array($operator, $allowed_operators)) {
throw new \RestfulBadRequestException(format_string('Operator "@operator" is not allowed for filtering on this resource. Allowed operators are: !allowed', array(
'@operator' => $operator,
'!allowed' => implode(', ', $allowed_operators),
)));
}
}
}