/** * {@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 = $this->query->getTables($sql_query); foreach ($this->conditions as $condition) { if ($condition['field'] instanceof ConditionInterface) { $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); $conditionContainer->condition($sql_condition); } else { $type = strtoupper($this->conjunction) == 'OR' || $condition['operator'] == 'IS NULL' ? 'LEFT' : 'INNER'; $field = $tables->addField($condition['field'], $type, $condition['langcode']); $condition['real_field'] = $field; static::translateCondition($condition, $sql_query, $tables->isFieldCaseSensitive($condition['field'])); // Add the translated conditions back to the condition container. if (isset($condition['where']) && isset($condition['where_args'])) { $conditionContainer->where($condition['where'], $condition['where_args']); } else { $conditionContainer->condition($field, $condition['value'], $condition['operator']); } } } }
/** * Tests revision entity query for entity type without revision table. * * @covers ::prepare * * @expectedException \Drupal\Core\Entity\Query\QueryException * @expectedExceptionMessage No revision table for example_entity_query, invalid query. */ public function testNoRevisionTable() { $this->query->allRevisions()->execute(); }
/** * Overrides \Drupal\Core\Entity\Query\Sql\Query::result(). * * @return array|int * Returns the aggregated result, or a number if it's a count query. */ protected function result() { if ($this->count) { return parent::result(); } $return = array(); foreach ($this->sqlQuery->execute() as $row) { $return[] = (array) $row; } return $return; }
/** * {@inheritdoc} */ public function __construct(EntityTypeInterface $entity_type, $conjunction, Connection $connection, array $namespaces) { parent::__construct($entity_type, $conjunction, $connection, $namespaces); $this->entityManager = \Drupal::service('entity.manager'); $this->multiversionManager = \Drupal::service('multiversion.manager'); }