class Condition extends Condition (View source)

Defines the condition class for the key value entity query.

Properties

protected array $conditions

Array of conditions.

from  ConditionFundamentals
protected string $conjunction

The conjunction of this condition group.

from  ConditionFundamentals
protected QueryInterface $query

The query this condition belongs to.

from  ConditionFundamentals
protected array $namespaces

List of potential namespaces of the classes belonging to this condition.

from  ConditionFundamentals

Methods

__construct(string $conjunction, QueryInterface $query, array $namespaces = [])

Constructs a Condition object.

getConjunction()

{@inheritdoc}

count()

{@inheritdoc}

conditions()

{@inheritdoc}

__clone()

Implements the magic __clone function.

$this
condition(string|ConditionInterface $field, mixed $value = NULL, string $operator = NULL, string $langcode = NULL)

Adds a condition.

compile($configs)

Compiles this conditional clause.

$this
exists(string $field, string $langcode = NULL)

Queries for the existence of a field.

$this
notExists(string $field, string $langcode = NULL)

Queries for the nonexistence of a field.

bool
matchArray(array $condition, array $data, array $needs_matching, array $parents = [])

Matches for an array representing one or more config paths.

bool
match(array $condition, string $value)

Perform the actual matching.

Details

__construct(string $conjunction, QueryInterface $query, array $namespaces = [])

Constructs a Condition object.

Parameters

string $conjunction

The operator to use to combine conditions: 'AND' or 'OR'.

QueryInterface $query

The entity query this condition belongs to.

array $namespaces

List of potential namespaces of the classes belonging to this condition.

getConjunction()

{@inheritdoc}

count()

{@inheritdoc}

conditions()

{@inheritdoc}

__clone()

Implements the magic __clone function.

Makes sure condition groups are cloned as well.

$this condition(string|ConditionInterface $field, mixed $value = NULL, string $operator = NULL, string $langcode = NULL)

Adds a condition.

Parameters

string|ConditionInterface $field

The field.

mixed $value

(optional) The value.

string $operator

(optional) The operator.

string $langcode

(optional) For which language the entity should be prepared, defaults to the current content language.

Return Value

$this

compile($configs)

Compiles this conditional clause.

Parameters

$configs

$this exists(string $field, string $langcode = NULL)

Queries for the existence of a field.

Parameters

string $field

The field to query for existence.

string $langcode

(optional) For which language the entity should be prepared, defaults to the current content language.

Return Value

$this

$this notExists(string $field, string $langcode = NULL)

Queries for the nonexistence of a field.

Parameters

string $field

The field to query for nonexistence.

string $langcode

(optional) For which language the entity should be prepared, defaults to the current content language.

Return Value

$this

protected bool matchArray(array $condition, array $data, array $needs_matching, array $parents = [])

Matches for an array representing one or more config paths.

Parameters

array $condition

The condition array as created by the condition() method.

array $data

The config array or part of it.

array $needs_matching

The list of config array keys needing a match. Can contain config keys and the * wildcard.

array $parents

The current list of parents.

Return Value

bool

TRUE when the condition matched to the data else FALSE.

protected bool match(array $condition, string $value)

Perform the actual matching.

Parameters

array $condition

The condition array as created by the condition() method.

string $value

The value to match against.

Return Value

bool

TRUE when matches else FALSE.