diff --git a/core/core.services.yml b/core/core.services.yml index 2cd6077..cbc61f6 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -242,7 +242,7 @@ services: - [setContainer, ['@service_container']] entity.query.config: class: Drupal\Core\Config\Entity\Query\QueryFactory - arguments: ['@config.storage'] + arguments: ['@config.storage', '@plugin.manager.entity'] router.dumper: class: Drupal\Core\Routing\MatcherDumper arguments: ['@database'] diff --git a/core/lib/Drupal/Core/Config/Entity/Query/QueryFactory.php b/core/lib/Drupal/Core/Config/Entity/Query/QueryFactory.php index e970819..7a89b73 100644 --- a/core/lib/Drupal/Core/Config/Entity/Query/QueryFactory.php +++ b/core/lib/Drupal/Core/Config/Entity/Query/QueryFactory.php @@ -10,13 +10,13 @@ use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Config\StorageInterface; use Drupal\Core\Entity\EntityManager; -use Drupal\Core\Entity\Query\QueryAggregateInterface; use Drupal\Core\Entity\Query\QueryException; +use Drupal\Core\Entity\Query\QueryFactoryInterface; /** * Provides a factory for creating entity query objects for the config backend. */ -class QueryFactory { +class QueryFactory implements QueryFactoryInterface { /** * The config storage used by the config entity query. @@ -26,49 +26,34 @@ class QueryFactory { protected $configStorage; /** + * Stores the entity manager used by the query. + * + * @var \Drupal\Core\Entity\EntityManager + */ + protected $entityManager; + + /** * Constructs a QueryFactory object. * * @param \Drupal\Core\Config\StorageInterface $config_storage * The config storage used by the config entity query. */ - public function __construct(StorageInterface $config_storage) { - return $this->configStorage = $config_storage; + public function __construct(StorageInterface $config_storage, EntityManager $entity_manager) { + $this->configStorage = $config_storage; + $this->entityManager = $entity_manager; } /** - * Instantiates an entity query for a given entity type. - * - * @param string $entity_type - * The entity type for the query. - * @param string $conjunction - * The operator to use to combine conditions: 'AND' or 'OR'. - * @param \Drupal\Core\Entity\EntityManager $entity_manager - * The entity manager that handles the entity type. - * - * @return \Drupal\Core\Config\Entity\Query\Query - * An entity query for a specific configuration entity type. + * {@inheritdoc} */ - public function get($entity_type, $conjunction, EntityManager $entity_manager) { - return new Query($entity_type, $conjunction, $entity_manager, $this->configStorage); + public function get($entity_type, $conjunction) { + return new Query($entity_type, $conjunction, $this->entityManager, $this->configStorage); } /** - * Returns a aggregation query object for a given entity type. - * - * @param string $entity_type - * The entity type. - * @param string $conjunction - * - AND: all of the conditions on the query need to match. - * - OR: at least one of the conditions on the query need to match. - * - * @param \Drupal\Core\Entity\EntityManager $entity_manager - * The entity manager. - * - * @throws \Drupal\Core\Entity\Query\QueryException - * @return \Drupal\Core\Entity\Query\QueryAggregateInterface - * The query object that can query the given entity type. + * @inheritdoc */ - public function getAggregate($entity_type, $conjunction, EntityManager $entity_manager) { + public function getAggregate($entity_type, $conjunction) { throw new QueryException('Aggregation over configuration entities is not supported'); } diff --git a/core/lib/Drupal/Core/Entity/Query/QueryFactory.php b/core/lib/Drupal/Core/Entity/Query/QueryFactory.php index fad531c..c613090 100644 --- a/core/lib/Drupal/Core/Entity/Query/QueryFactory.php +++ b/core/lib/Drupal/Core/Entity/Query/QueryFactory.php @@ -13,7 +13,7 @@ /** * Factory class Creating entity query objects. */ -class QueryFactory extends ContainerAware { +class QueryFactory extends ContainerAware implements QueryFactoryInterface { /** * Stores the entity manager used by the query. @@ -33,16 +33,7 @@ public function __construct(EntityManager $entity_manager) { } /** - * Returns a query object for a given entity type. - * - * @param string $entity_type - * The entity type. - * @param string $conjunction - * - AND: all of the conditions on the query need to match. - * - OR: at least one of the conditions on the query need to match. - * - * @return \Drupal\Core\Entity\Query\QueryInterface - * The query object that can query the given entity type. + * {@inheritdoc} */ public function get($entity_type, $conjunction = 'AND') { $service_name = $this->entityManager->getStorageController($entity_type)->getQueryServicename(); @@ -50,16 +41,7 @@ public function get($entity_type, $conjunction = 'AND') { } /** - * Returns an aggregated query object for a given entity type. - * - * @param string $entity_type - * The entity type. - * @param string $conjunction - * - AND: all of the conditions on the query need to match. - * - OR: at least one of the conditions on the query need to match. - * - * @return \Drupal\Core\Entity\Query\QueryAggregateInterface - * The aggregated query object that can query the given entity type. + * {@inheritdoc} */ public function getAggregate($entity_type, $conjunction = 'AND') { $service_name = $this->entityManager->getStorageController($entity_type)->getQueryServicename(); diff --git a/core/lib/Drupal/Core/Entity/Query/QueryFactoryInterface.php b/core/lib/Drupal/Core/Entity/Query/QueryFactoryInterface.php new file mode 100644 index 0000000..95e1481 --- /dev/null +++ b/core/lib/Drupal/Core/Entity/Query/QueryFactoryInterface.php @@ -0,0 +1,45 @@ +connection = $connection; + $this->entityManager = $entity_manager; } /** @@ -40,8 +56,8 @@ function __construct(Connection $connection) { * @return \Drupal\field_sql_storage\Entity\Query * The factored query. */ - function get($entity_type, $conjunction, EntityManager $entity_manager) { - return new Query($entity_type, $entity_manager, $conjunction, $this->connection); + function get($entity_type, $conjunction) { + return new Query($entity_type, $this->entityManager, $conjunction, $this->connection); } /** @@ -56,8 +72,8 @@ function get($entity_type, $conjunction, EntityManager $entity_manager) { * @return \Drupal\field_sql_storage\Entity\QueryAggregate * The factored aggregation query. */ - function getAggregate($entity_type, $conjunction, EntityManager $entity_manager) { - return new QueryAggregate($entity_type, $entity_manager, $conjunction, $this->connection); + function getAggregate($entity_type, $conjunction) { + return new QueryAggregate($entity_type, $this->entityManager, $conjunction, $this->connection); } }