Updated to Drupal 8.6.4, which is PHP 7.3 friendly. Also updated HTMLaw library....
[yaffs-website] / web / core / lib / Drupal / Core / Entity / Query / Sql / QueryFactory.php
1 <?php
2
3 namespace Drupal\Core\Entity\Query\Sql;
4
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;
9
10 /**
11  * Factory class creating entity query objects for the SQL backend.
12  *
13  * @see \Drupal\Core\Entity\Query\Sql\Query
14  * @see \Drupal\Core\Entity\Query\Sql\QueryAggregate
15  */
16 class QueryFactory implements QueryFactoryInterface {
17
18   /**
19    * The database connection to use.
20    *
21    * @var \Drupal\Core\Database\Connection
22    */
23   protected $connection;
24
25   /**
26    * The namespace of this class, the parent class etc.
27    *
28    * @var array
29    */
30   protected $namespaces;
31
32   /**
33    * Constructs a QueryFactory object.
34    *
35    * @param \Drupal\Core\Database\Connection $connection
36    *   The database connection used by the entity query.
37    */
38   public function __construct(Connection $connection) {
39     $this->connection = $connection;
40     $this->namespaces = QueryBase::getNamespaces($this);
41   }
42
43   /**
44    * {@inheritdoc}
45    */
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);
49   }
50
51   /**
52    * {@inheritdoc}
53    */
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);
57   }
58
59 }