protected function DataProviderEntity::validateFilters in RESTful 7.2
Validates the query parameters.
Parameters
array $filters: The parsed filters.
Throws
BadRequestException When there is an invalid target for relational filters.
1 call to DataProviderEntity::validateFilters()
- DataProviderEntity::queryForListFilter in src/
Plugin/ resource/ DataProvider/ DataProviderEntity.php - Filter the query for list.
File
- src/
Plugin/ resource/ DataProvider/ DataProviderEntity.php, line 790 - Contains \Drupal\restful\Plugin\resource\DataProvider\DataProviderEntity.
Class
- DataProviderEntity
- Class DataProviderEntity.
Namespace
Drupal\restful\Plugin\resource\DataProviderCode
protected function validateFilters(array $filters) {
foreach ($filters as $filter) {
if (empty($filter['target'])) {
continue;
}
// If the target is not a part of the field, then raise an error.
$field_name_parts = explode('.', $filter['public_field']);
$target_parts = explode('.', $filter['target']);
foreach ($target_parts as $delta => $target_part) {
if ($target_part != $field_name_parts[$delta]) {
// There is a discrepancy between target and field name.
throw new BadRequestException(sprintf('The target "%s" should be a part of the field name "%s".', $filter['target'], $filter['public_field']));
}
}
}
}