class ConditionAggregate in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Entity/Query/Sql/ConditionAggregate.php \Drupal\Core\Entity\Query\Sql\ConditionAggregate
Defines the aggregate condition for sql based storage.
Hierarchy
- class \Drupal\Core\Entity\Query\ConditionFundamentals
- class \Drupal\Core\Entity\Query\ConditionAggregateBase implements ConditionAggregateInterface
- class \Drupal\Core\Entity\Query\Sql\ConditionAggregate
- class \Drupal\Core\Entity\Query\ConditionAggregateBase implements ConditionAggregateInterface
Expanded class hierarchy of ConditionAggregate
1 file declares its use of ConditionAggregate
- Query.php in core/
lib/ Drupal/ Core/ Entity/ Query/ Null/ Query.php - Contains \Drupal\Core\Entity\Query\Null\Query.
1 string reference to 'ConditionAggregate'
- QueryAggregate::conditionAggregateGroupFactory in core/
lib/ Drupal/ Core/ Entity/ Query/ Sql/ QueryAggregate.php - Creates an object holding a group of conditions.
File
- core/
lib/ Drupal/ Core/ Entity/ Query/ Sql/ ConditionAggregate.php, line 19 - Contains \Drupal\Core\Entity\Query\Sql\ConditionAggregate.
Namespace
Drupal\Core\Entity\Query\SqlView source
class ConditionAggregate extends ConditionAggregateBase {
/**
* {@inheritdoc}
*/
public function compile($conditionContainer) {
// If this is not the top level condition group then the sql query is
// added to the $conditionContainer object by this function itself. The
// SQL query object is only necessary to pass to Query::addField() so it
// can join tables as necessary. On the other hand, conditions need to be
// added to the $conditionContainer object to keep grouping.
$sql_query = $conditionContainer instanceof SelectInterface ? $conditionContainer : $conditionContainer->sqlQuery;
$tables = new Tables($sql_query);
foreach ($this->conditions as $condition) {
if ($condition['field'] instanceof ConditionAggregateInterface) {
$sql_condition = new SqlCondition($condition['field']
->getConjunction());
// Add the SQL query to the object before calling this method again.
$sql_condition->sqlQuery = $sql_query;
$condition['field']
->compile($sql_condition);
$sql_query
->condition($sql_condition);
}
else {
$type = strtoupper($this->conjunction) == 'OR' || $condition['operator'] == 'IS NULL' ? 'LEFT' : 'INNER';
$field = $tables
->addField($condition['field'], $type, $condition['langcode']);
$condition_class = QueryBase::getClass($this->namespaces, 'Condition');
$condition_class::translateCondition($condition, $sql_query, $tables
->isFieldCaseSensitive($condition['field']));
$function = $condition['function'];
$placeholder = ':db_placeholder_' . $conditionContainer
->nextPlaceholder();
$conditionContainer
->having("{$function}({$field}) {$condition['operator']} {$placeholder}", array(
$placeholder => $condition['value'],
));
}
}
}
/**
* {@inheritdoc}
*/
public function exists($field, $function, $langcode = NULL) {
return $this
->condition($field, $function, NULL, 'IS NOT NULL', $langcode);
}
/**
* {@inheritdoc}
*/
public function notExists($field, $function, $langcode = NULL) {
return $this
->condition($field, $function, NULL, 'IS NULL', $langcode);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConditionAggregate:: |
public | function |
Compiles this conditional clause. Overrides ConditionAggregateInterface:: |
|
ConditionAggregate:: |
public | function |
Queries for the existence of a field. Overrides ConditionAggregateInterface:: |
|
ConditionAggregate:: |
public | function |
Queries for the nonexistence of a field. Overrides ConditionAggregateInterface:: |
|
ConditionAggregateBase:: |
public | function |
Adds a condition. Overrides ConditionAggregateInterface:: |
|
ConditionFundamentals:: |
protected | property | Array of conditions. | |
ConditionFundamentals:: |
protected | property | The conjunction of this condition group. The value is one of the following: | |
ConditionFundamentals:: |
protected | property | List of potential namespaces of the classes belonging to this condition. | |
ConditionFundamentals:: |
protected | property | The query this condition belongs to. | 1 |
ConditionFundamentals:: |
public | function | ||
ConditionFundamentals:: |
public | function | ||
ConditionFundamentals:: |
public | function | ||
ConditionFundamentals:: |
public | function | Implements the magic __clone function. | |
ConditionFundamentals:: |
public | function | Constructs a Condition object. |