diff --git a/core/lib/Drupal/Core/Entity/Query/QueryBase.php b/core/lib/Drupal/Core/Entity/Query/QueryBase.php index 4fd5a44..c48cb17 100644 --- a/core/lib/Drupal/Core/Entity/Query/QueryBase.php +++ b/core/lib/Drupal/Core/Entity/Query/QueryBase.php @@ -183,7 +183,8 @@ public function range($start = NULL, $length = NULL) { * An object holding a group of conditions. */ protected function conditionGroupFactory($conjunction = 'AND') { - return new namespace\Condition($conjunction, $this); + $class = static::getNamespace($this) . '\\Condition'; + return new $class($conjunction, $this); } /** @@ -418,4 +419,17 @@ protected function getAggregationAlias($field, $function) { return strtolower($field . '_'. $function); } + /** + * Returns the namespace of an object. + * + * @param $object + * The object. + * + * @return string + * The namespace. + */ + public static function getNamespace($object) { + return preg_replace('/.[^\\\\]+$/', '', get_class($object)); + } + } diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/Query.php b/core/lib/Drupal/Core/Entity/Query/Sql/Query.php index c7ba54a..1c2a458 100644 --- a/core/lib/Drupal/Core/Entity/Query/Sql/Query.php +++ b/core/lib/Drupal/Core/Entity/Query/Sql/Query.php @@ -323,6 +323,7 @@ public function __clone() { * @return \Drupal\Core\Entity\Query\Sql\TablesInterface */ public function getTables(SelectInterface $sql_query) { + $class = QueryBase::getNamespace($this) . '\\Tables'; return new namespace\Tables($sql_query); } diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/QueryFactory.php b/core/lib/Drupal/Core/Entity/Query/Sql/QueryFactory.php index cb05237..31336d0 100644 --- a/core/lib/Drupal/Core/Entity/Query/Sql/QueryFactory.php +++ b/core/lib/Drupal/Core/Entity/Query/Sql/QueryFactory.php @@ -9,6 +9,7 @@ use Drupal\Core\Database\Connection; use Drupal\Core\Entity\EntityManager; +use Drupal\Core\Entity\Query\QueryBase; use Drupal\Core\Entity\Query\QueryFactoryInterface; /** @@ -49,7 +50,8 @@ public function __construct(Connection $connection) { * The factored query. */ public function get($entity_type, $conjunction, EntityManager $entity_manager) { - return new namespace\Query($entity_type, $entity_manager, $conjunction, $this->connection); + $class = QueryBase::getNamespace($this) . '\\Query'; + return new $class($entity_type, $entity_manager, $conjunction, $this->connection); } /** @@ -65,7 +67,8 @@ public function get($entity_type, $conjunction, EntityManager $entity_manager) { * The factored aggregation query. */ public function getAggregate($entity_type, $conjunction, EntityManager $entity_manager) { - return new namespace\QueryAggregate($entity_type, $entity_manager, $conjunction, $this->connection); + $class = QueryBase::getNamespace($this) . '\\QueryAggregate'; + return new $class($entity_type, $entity_manager, $conjunction, $this->connection); } }