You are here

protected function DataProviderEntity::alterFilterQuery in RESTful 7.2

Placeholder method to alter the filters.

If no further processing for the filter is needed (i.e. alterFilterQuery already added the query filters to $query), then set the 'processed' flag in $filter to TRUE. Otherwise normal filtering will be added on top, leading to unexpected results.

Parameters

array $filter: The parsed filter information.

\EntityFieldQuery $query: The EFQ to add the filter to.

Return value

array The modified $filter array.

1 call to DataProviderEntity::alterFilterQuery()
DataProviderEntity::queryForListFilter in src/Plugin/resource/DataProvider/DataProviderEntity.php
Filter the query for list.

File

src/Plugin/resource/DataProvider/DataProviderEntity.php, line 723
Contains \Drupal\restful\Plugin\resource\DataProvider\DataProviderEntity.

Class

DataProviderEntity
Class DataProviderEntity.

Namespace

Drupal\restful\Plugin\resource\DataProvider

Code

protected function alterFilterQuery(array $filter, \EntityFieldQuery $query) {
  if (!($resource_field = $this->fieldDefinitions
    ->get($filter['public_field']))) {
    return $filter;
  }
  if (!$resource_field instanceof ResourceFieldEntityAlterableInterface) {

    // Check if the resource can check on decorated instances.
    if (!$resource_field instanceof ExplorableDecoratorInterface || !$resource_field
      ->isInstanceOf(ResourceFieldEntityAlterableInterface::class)) {
      return $filter;
    }
  }
  return $resource_field
    ->alterFilterEntityFieldQuery($filter, $query);
}