3 namespace Drupal\Core\Entity\Query\Sql;
5 use Drupal\Core\Database\Connection;
6 use Drupal\Core\Entity\EntityTypeInterface;
7 use Drupal\Core\Entity\Query\QueryBase;
8 use Drupal\Core\Entity\Query\QueryFactoryInterface;
11 * Factory class creating entity query objects for the SQL backend.
13 * @see \Drupal\Core\Entity\Query\Sql\Query
14 * @see \Drupal\Core\Entity\Query\Sql\QueryAggregate
16 class QueryFactory implements QueryFactoryInterface {
19 * The database connection to use.
21 * @var \Drupal\Core\Database\Connection
23 protected $connection;
26 * The namespace of this class, the parent class etc.
30 protected $namespaces;
33 * Constructs a QueryFactory object.
35 * @param \Drupal\Core\Database\Connection $connection
36 * The database connection used by the entity query.
38 public function __construct(Connection $connection) {
39 $this->connection = $connection;
40 $this->namespaces = QueryBase::getNamespaces($this);
46 public function get(EntityTypeInterface $entity_type, $conjunction) {
47 $class = QueryBase::getClass($this->namespaces, 'Query');
48 return new $class($entity_type, $conjunction, $this->connection, $this->namespaces);
54 public function getAggregate(EntityTypeInterface $entity_type, $conjunction) {
55 $class = QueryBase::getClass($this->namespaces, 'QueryAggregate');
56 return new $class($entity_type, $conjunction, $this->connection, $this->namespaces);