function EntityCondition::createFromQueryParameter

Same name in other branches
  1. 9 core/modules/jsonapi/src/Query/EntityCondition.php \Drupal\jsonapi\Query\EntityCondition::createFromQueryParameter()
  2. 8.9.x core/modules/jsonapi/src/Query/EntityCondition.php \Drupal\jsonapi\Query\EntityCondition::createFromQueryParameter()
  3. 10 core/modules/jsonapi/src/Query/EntityCondition.php \Drupal\jsonapi\Query\EntityCondition::createFromQueryParameter()

Creates an EntityCondition object from a query parameter.

Parameters

mixed $parameter: The `filter[condition]` query parameter from the request.

Return value

self An EntityCondition object with defaults.

3 calls to EntityCondition::createFromQueryParameter()
EntityConditionTest::testCreateFromQueryParameter in core/modules/jsonapi/tests/src/Unit/Query/EntityConditionTest.php
@covers ::createFromQueryParameter @dataProvider queryParameterProvider
EntityConditionTest::testValidation in core/modules/jsonapi/tests/src/Unit/Query/EntityConditionTest.php
@covers ::validate @dataProvider validationProvider
Filter::buildTree in core/modules/jsonapi/src/Query/Filter.php
Organizes the flat, normalized filter items into a tree structure.

File

core/modules/jsonapi/src/Query/EntityCondition.php, line 127

Class

EntityCondition
A condition object for the EntityQuery.

Namespace

Drupal\jsonapi\Query

Code

public static function createFromQueryParameter($parameter) {
    static::validate($parameter);
    $field = $parameter[static::PATH_KEY];
    $value = isset($parameter[static::VALUE_KEY]) ? $parameter[static::VALUE_KEY] : NULL;
    $operator = isset($parameter[static::OPERATOR_KEY]) ? $parameter[static::OPERATOR_KEY] : NULL;
    return new static($field, $value, $operator);
}

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