You are here

protected static function TemporaryQueryGuard::addConditionFieldPrefix in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/jsonapi/src/Access/TemporaryQueryGuard.php \Drupal\jsonapi\Access\TemporaryQueryGuard::addConditionFieldPrefix()
  2. 10 core/modules/jsonapi/src/Access/TemporaryQueryGuard.php \Drupal\jsonapi\Access\TemporaryQueryGuard::addConditionFieldPrefix()

Prefixes all fields in an EntityConditionGroup.

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

File

core/modules/jsonapi/src/Access/TemporaryQueryGuard.php, line 211

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);
}