Pull merge.
[yaffs-website] / web / core / lib / Drupal / Core / Entity / KeyValueStore / Query / QueryFactory.php
1 <?php
2
3 namespace Drupal\Core\Entity\KeyValueStore\Query;
4
5 use Drupal\Core\Entity\EntityTypeInterface;
6 use Drupal\Core\Entity\Query\QueryException;
7 use Drupal\Core\Entity\Query\QueryFactoryInterface;
8 use Drupal\Core\KeyValueStore\KeyValueFactoryInterface;
9
10 /**
11  * Provides a factory for creating the key value entity query.
12  */
13 class QueryFactory implements QueryFactoryInterface {
14
15   /**
16    * The key value factory.
17    *
18    * @var \Drupal\Core\KeyValueStore\KeyValueFactoryInterface
19    */
20   protected $keyValueFactory;
21
22   /**
23    * The namespace of this class, the parent class etc.
24    *
25    * @var array
26    */
27   protected $namespaces;
28
29   /**
30    * Constructs a QueryFactory object.
31    */
32   public function __construct(KeyValueFactoryInterface $key_value_factory) {
33     $this->keyValueFactory = $key_value_factory;
34     $this->namespaces = Query::getNamespaces($this);
35   }
36
37   /**
38    * {@inheritdoc}
39    */
40   public function get(EntityTypeInterface $entity_type, $conjunction) {
41     return new Query($entity_type, $conjunction, $this->namespaces, $this->keyValueFactory);
42   }
43
44   /**
45    * {@inheritdoc}
46    */
47   public function getAggregate(EntityTypeInterface $entity_type, $conjunction) {
48     throw new QueryException('Aggregation over key-value entity storage is not supported');
49   }
50
51 }