You are here

protected function DataProviderEntity::addNestedFilter in RESTful 7.2

Add relational filters to EFQ.

This is for situation like when you only want articles that have taxonomies that contain the word Drupal in their body field. This cannot be resolved via EFQ alone.

Parameters

array $filter: The filter.

\EntityFieldQuery $query: The query to alter.

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

File

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

Class

DataProviderEntity
Class DataProviderEntity.

Namespace

Drupal\restful\Plugin\resource\DataProvider

Code

protected function addNestedFilter(array $filter, \EntityFieldQuery $query) {
  $relational_filters = array();
  foreach ($this
    ->getFieldsInfoFromPublicName($filter['public_field']) as $field_info) {
    $relational_filters[] = new RelationalFilter($field_info['name'], $field_info['type'], $field_info['column'], $field_info['entity_type'], $field_info['bundles'], $field_info['target_column']);
  }
  $query
    ->addRelationship($filter + array(
    'relational_filters' => $relational_filters,
  ));
}