resolveInternalEntityQueryPath example

$this->assertEquals('AND', $nested_and_group->conjunction());
    $nested_and_group_members = $nested_and_group->members();
    $this->assertEquals('field2', $nested_and_group_members[0]->field());
    $this->assertEquals('field3', $nested_and_group_members[1]->field());
  }

  /** * Provides a mock field resolver. */
  protected function getFieldResolverMock(ResourceType $resource_type) {
    $field_resolver = $this->prophesize(FieldResolver::class);
    $field_resolver->resolveInternalEntityQueryPath($resource_type, Argument::any(), Argument::any())->willReturnArgument(1);
    return $field_resolver->reveal();
  }

}
// Compute and apply an entity query condition from the filter parameter.     if (isset($params[Filter::KEY_NAME]) && $filter = $params[Filter::KEY_NAME]) {
      $query->condition($filter->queryCondition($query));
      TemporaryQueryGuard::setFieldManager($this->fieldManager);
      TemporaryQueryGuard::setModuleHandler(\Drupal::moduleHandler());
      TemporaryQueryGuard::applyAccessControls($filter$query$query_cacheability);
    }

    // Apply any sorts to the entity query.     if (isset($params[Sort::KEY_NAME]) && $sort = $params[Sort::KEY_NAME]) {
      foreach ($sort->fields() as $field) {
        $path = $this->fieldResolver->resolveInternalEntityQueryPath($resource_type$field[Sort::PATH_KEY]);
        $direction = $field[Sort::DIRECTION_KEY] ?? 'ASC';
        $langcode = $field[Sort::LANGUAGE_KEY] ?? NULL;
        $query->sort($path$direction$langcode);
      }
    }

    // Apply any pagination options to the query.     if (isset($params[OffsetPage::KEY_NAME])) {
      $pagination = $params[OffsetPage::KEY_NAME];
    }
    else {
      
'`field_test_ref1.field_test3` is not a valid include path.',
      ],
    ];
  }

  /** * @covers ::resolveInternalEntityQueryPath * @dataProvider resolveInternalEntityQueryPathProvider */
  public function testResolveInternalEntityQueryPath($expect$external_path$entity_type_id = 'entity_test_with_bundle', $bundle = 'bundle1') {
    $resource_type = $this->resourceTypeRepository->get($entity_type_id$bundle);
    $this->assertEquals($expect$this->sut->resolveInternalEntityQueryPath($resource_type$external_path));
  }

  /** * Provides test cases for ::testResolveInternalEntityQueryPath. */
  public function resolveInternalEntityQueryPathProvider() {
    return [
      'config entity as base' => [
        'uuid', 'id', 'entity_test_bundle', 'entity_test_bundle',
      ],
      'config entity as target' => ['type.entity:entity_test_bundle.uuid', 'type.id'],

      

  public static function createFromQueryParameter($parameter, ResourceType $resource_type, FieldResolver $field_resolver) {
    $expanded = static::expand($parameter);
    foreach ($expanded as &$filter_item) {
      if (isset($filter_item[static::CONDITION_KEY][EntityCondition::PATH_KEY])) {
        $unresolved = $filter_item[static::CONDITION_KEY][EntityCondition::PATH_KEY];
        $operator = $filter_item[static::CONDITION_KEY][EntityCondition::OPERATOR_KEY];
        $filter_item[static::CONDITION_KEY][EntityCondition::PATH_KEY] = $field_resolver->resolveInternalEntityQueryPath($resource_type$unresolved$operator);
      }
    }
    return new static(static::buildEntityConditionGroup($expanded));
  }

  /** * Expands any filter parameters using shorthand notation. * * @param array $original * The unexpanded filter data. * * @return array * The expanded filter data. */
Home | Imprint | This part of the site doesn't use cookies.