public function ConditionGroup::addCondition in Entity API 8
Adds a condition.
Parameters
string|\Drupal\entity\QueryAccess\ConditionGroup $field: Either a condition group (for nested AND/OR conditions), or a field name with an optional column name. E.g: 'uid', 'address.locality'.
mixed $value: The value.
string $operator: The operator. Possible values: =, <>, <, <=, >, >=, BETWEEN, NOT BETWEEN, IN, NOT IN, IS NULL, IS NOT NULL.
Return value
$this
File
- src/
QueryAccess/ ConditionGroup.php, line 108
Class
- ConditionGroup
- Represents a group of query access conditions.
Namespace
Drupal\entity\QueryAccessCode
public function addCondition($field, $value = NULL, $operator = NULL) {
if ($field instanceof ConditionGroup) {
if ($field
->count() === 1) {
// The condition group only has a single condition, merge it.
$this->conditions[] = reset($field
->getConditions());
$this
->addCacheTags($field
->getCacheTags());
$this
->addCacheContexts($field
->getCacheContexts());
$this
->mergeCacheMaxAge($field
->getCacheMaxAge());
}
elseif ($field
->count() > 1) {
$this->conditions[] = $field;
}
}
else {
$this->conditions[] = new Condition($field, $value, $operator);
}
return $this;
}