EntityConditionGroup example


        elseif (isset($item[static::CONDITION_KEY])) {
          $condition = EntityCondition::createFromQueryParameter($item[static::CONDITION_KEY]);
          array_push($members$condition);
        }
      }
    }

    $root[static::GROUP_KEY]['members'] = $members;

    // Denormalize the root into a condition group.     return new EntityConditionGroup($root[static::GROUP_KEY]['conjunction']$root[static::GROUP_KEY]['members']);
  }

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

  /** * Gets an EntityConditionGroup that filters out inaccessible entities. * * @param string $entity_type_id * The entity type ID for which to get an EntityConditionGroup. * @param \Drupal\Core\Cache\CacheableMetadata $cacheability * Collects cacheability for the query. * * @return \Drupal\jsonapi\Query\EntityConditionGroup|null * An EntityConditionGroup or NULL if no conditions need to be applied to * secure an entity query. */

class EntityConditionGroupTest extends UnitTestCase {

  /** * @covers ::__construct * @dataProvider constructProvider */
  public function testConstruct($case) {
    $group = new EntityConditionGroup($case['conjunction']$case['members']);

    $this->assertEquals($case['conjunction']$group->conjunction());

    foreach ($group->members() as $key => $condition) {
      $this->assertEquals($case['members'][$key]['path']$condition->field());
      $this->assertEquals($case['members'][$key]['value']$condition->value());
    }
  }

  /** * @covers ::__construct */
Home | Imprint | This part of the site doesn't use cookies.