QueryFactory.php 1.3 KB

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