You are here

protected static function TemporaryQueryGuard::collectFilteredFields in JSON:API 8

Same name and namespace in other branches
  1. 8.2 src/Access/TemporaryQueryGuard.php \Drupal\jsonapi\Access\TemporaryQueryGuard::collectFilteredFields()

Recursively collects all entity query condition fields.

Entity conditions can be nested within AND and OR groups. This recursively finds all unique fields in an entity query condition.

Parameters

\Drupal\jsonapi\Query\EntityConditionGroup $group: The root entity condition group.

array $fields: Internal use only.

Return value

array An array of entity query condition field names.

1 call to TemporaryQueryGuard::collectFilteredFields()
TemporaryQueryGuard::applyAccessControls in src/Access/TemporaryQueryGuard.php
Applies access controls to an entity query.

File

src/Access/TemporaryQueryGuard.php, line 586

Class

TemporaryQueryGuard
Adds sufficient access control to collection queries.

Namespace

Drupal\jsonapi\Access

Code

protected static function collectFilteredFields(EntityConditionGroup $group, array $fields = []) {
  foreach ($group
    ->members() as $member) {
    if ($member instanceof EntityConditionGroup) {
      $fields = static::collectFilteredFields($member, $fields);
    }
    else {
      $fields[] = $member
        ->field();
    }
  }
  return array_unique($fields);
}