Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/Query/ConditionBase.php \Drupal\Core\Entity\Query\ConditionBase::condition()
  2. 9 core/lib/Drupal/Core/Entity/Query/ConditionBase.php \Drupal\Core\Entity\Query\ConditionBase::condition()

Adds a condition.

Parameters

string|\Drupal\Core\Entity\Query\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

Overrides ConditionInterface::condition

See also

\Drupal\Core\Entity\Query\QueryInterface::condition()

4 calls to ConditionBase::condition()
Condition::exists in core/lib/Drupal/Core/Entity/Query/Null/Condition.php
Queries for the existence of a field.
Condition::exists in core/lib/Drupal/Core/Config/Entity/Query/Condition.php
Queries for the existence of a field.
Condition::notExists in core/lib/Drupal/Core/Entity/Query/Null/Condition.php
Queries for the nonexistence of a field.
Condition::notExists in core/lib/Drupal/Core/Config/Entity/Query/Condition.php
Queries for the nonexistence of a field.

File

core/lib/Drupal/Core/Entity/Query/ConditionBase.php, line 13

Class

ConditionBase
Defines a common base class for all entity condition implementations.

Namespace

Drupal\Core\Entity\Query

Code

public function condition($field, $value = NULL, $operator = NULL, $langcode = NULL) {
  $this->conditions[] = [
    'field' => $field,
    'value' => $value,
    'operator' => $operator,
    'langcode' => $langcode,
  ];
  return $this;
}