function TemporaryQueryGuard::addConditionFieldPrefix

Same name in other branches
  1. 9 core/modules/jsonapi/src/Access/TemporaryQueryGuard.php \Drupal\jsonapi\Access\TemporaryQueryGuard::addConditionFieldPrefix()
  2. 8.9.x core/modules/jsonapi/src/Access/TemporaryQueryGuard.php \Drupal\jsonapi\Access\TemporaryQueryGuard::addConditionFieldPrefix()
  3. 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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.