protected function DataProvider::parseRequestForListFilter in RESTful 7.2
Filter the query for list.
@returns array An array of filters to apply.
Throws
\Drupal\restful\Exception\BadRequestException
\Drupal\restful\Exception\UnprocessableEntityException
See also
\RestfulEntityBase::getQueryForList
4 calls to DataProvider::parseRequestForListFilter()
- DataProviderDbQuery::queryForListFilter in src/
Plugin/ resource/ DataProvider/ DataProviderDbQuery.php - Filter the query for list.
- DataProviderEntity::queryForListFilter in src/
Plugin/ resource/ DataProvider/ DataProviderEntity.php - Filter the query for list.
- DataProviderPlug::applyFilters in src/
Plugin/ resource/ DataProvider/ DataProviderPlug.php - Removes plugins from the list based on the request options.
- DataProviderVariable::applyFilters in modules/
restful_example/ src/ Plugin/ resource/ variables/ DataProviderVariable.php - Removes plugins from the list based on the request options.
File
- src/
Plugin/ resource/ DataProvider/ DataProvider.php, line 377 - Contains \Drupal\restful\Plugin\resource\DataProvider\DataProvider.
Class
Namespace
Drupal\restful\Plugin\resource\DataProviderCode
protected function parseRequestForListFilter() {
if (!$this->request
->isListRequest($this
->getResourcePath())) {
// Not a list request, so we don't need to filter.
// We explicitly check this, as this function might be called from a
// formatter plugin, after RESTful's error handling has finished, and an
// invalid key might be passed.
return array();
}
$input = $this
->getRequest()
->getParsedInput();
if (empty($input['filter'])) {
// No filtering is needed.
return array();
}
$url_params = empty($this->options['urlParams']) ? array() : $this->options['urlParams'];
if (isset($url_params['filter']) && !$url_params['filter']) {
throw new UnprocessableEntityException('Filter parameters have been disabled in server configuration.');
}
$filters = array();
foreach ($input['filter'] as $public_field => $value) {
if (!static::isNestedField($public_field) && !$this->fieldDefinitions
->get($public_field)) {
throw new BadRequestException(format_string('The filter @filter is not allowed for this path.', array(
'@filter' => $public_field,
)));
}
$filter = static::processFilterInput($value, $public_field);
$filters[] = $filter + array(
'resource_id' => $this->pluginId,
);
}
return $filters;
}