You are here

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

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

Prefixes all fields in an EntityConditionGroup.

2 calls to TemporaryQueryGuard::addConditionFieldPrefix()
TemporaryQueryGuard::applyAccessConditions in src/Access/TemporaryQueryGuard.php
Applies access conditions to ensure 'view' access is respected.
TemporaryQueryGuard::getCommentAccessCondition in src/Access/TemporaryQueryGuard.php
Gets an access condition for a comment entity.

File

src/Access/TemporaryQueryGuard.php, line 202

Class

TemporaryQueryGuard
Adds sufficient access control to collection queries.

Namespace

Drupal\jsonapi\Access

Code

protected static function addConditionFieldPrefix(EntityConditionGroup $group, $field_prefix) {
  $prefixed = [];
  foreach ($group
    ->members() as $member) {
    if ($member instanceof EntityConditionGroup) {
      $prefixed[] = static::addConditionFieldPrefix($member, $field_prefix);
    }
    else {
      $field = !empty($field_prefix) ? "{$field_prefix}." . $member
        ->field() : $member
        ->field();
      $prefixed[] = new EntityCondition($field, $member
        ->value(), $member
        ->operator());
    }
  }
  return new EntityConditionGroup($group
    ->conjunction(), $prefixed);
}