protected static function DataProvider::isValidOperatorsForFilter in RESTful 7.2
Check if an operator is valid for filtering.
Parameters
array $operators: The array of operators.
Throws
1 call to DataProvider::isValidOperatorsForFilter()
- DataProvider::processFilterInput in src/
Plugin/ resource/ DataProvider/ DataProvider.php - Processes the input for a filter and adds the appropriate defaults.
1 method overrides DataProvider::isValidOperatorsForFilter()
- DataProviderEntity::isValidOperatorsForFilter in src/
Plugin/ resource/ DataProvider/ DataProviderEntity.php - Overrides DataProvider::isValidOperatorsForFilter().
File
- src/
Plugin/ resource/ DataProvider/ DataProvider.php, line 461 - Contains \Drupal\restful\Plugin\resource\DataProvider\DataProvider.
Class
Namespace
Drupal\restful\Plugin\resource\DataProviderCode
protected static function isValidOperatorsForFilter(array $operators) {
$allowed_operators = array(
'=',
'>',
'<',
'>=',
'<=',
'<>',
'!=',
'NOT IN',
'BETWEEN',
'CONTAINS',
'IN',
'NOT IN',
'STARTS_WITH',
);
foreach ($operators as $operator) {
if (!in_array($operator, $allowed_operators)) {
throw new BadRequestException(sprintf('Operator "%s" is not allowed for filtering on this resource. Allowed operators are: %s', $operator, implode(', ', $allowed_operators)));
}
}
}