diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php index a70ad36..8a26ec0 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php @@ -66,13 +66,6 @@ class ConfigStorageController extends EntityStorageControllerBase implements Con protected $configStorage; /** - * The entity query factory. - * - * @var \Drupal\Core\Entity\Query\QueryFactory - */ - protected $entityQueryFactory; - - /** * Constructs a ConfigStorageController object. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type @@ -81,12 +74,10 @@ class ConfigStorageController extends EntityStorageControllerBase implements Con * The config factory service. * @param \Drupal\Core\Config\StorageInterface $config_storage * The config storage service. - * @param \Drupal\Core\Entity\Query\QueryFactory $entity_query_factory - * The entity query factory. * @param \Drupal\Component\Uuid\UuidInterface $uuid_service * The UUID service. */ - public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, StorageInterface $config_storage, QueryFactory $entity_query_factory, UuidInterface $uuid_service) { + public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, StorageInterface $config_storage, UuidInterface $uuid_service) { parent::__construct($entity_type); $this->idKey = $this->entityType->getKey('id'); @@ -94,7 +85,6 @@ public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInter $this->configFactory = $config_factory; $this->configStorage = $config_storage; - $this->entityQueryFactory = $entity_query_factory; $this->uuidService = $uuid_service; } @@ -106,7 +96,6 @@ public static function createInstance(ContainerInterface $container, EntityTypeI $entity_type, $container->get('config.factory'), $container->get('config.storage'), - $container->get('entity.query'), $container->get('uuid') ); } @@ -175,13 +164,6 @@ public function deleteRevision($revision_id) { /** * {@inheritdoc} */ - public function getQuery($conjunction = 'AND') { - return $this->entityQueryFactory->get($this->entityTypeId, $conjunction); - } - - /** - * {@inheritdoc} - */ public function getConfigPrefix() { return $this->entityType->getConfigPrefix() . '.'; } diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigStorageControllerInterface.php b/core/lib/Drupal/Core/Config/Entity/ConfigStorageControllerInterface.php index 114fa33..4ffe876 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigStorageControllerInterface.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigStorageControllerInterface.php @@ -31,20 +31,6 @@ public function importCreate($name, Config $new_config, Config $old_config); /** - * Returns an entity query instance. - * - * @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 instance. - * - * @see \Drupal\Core\Entity\EntityStorageControllerInterface::getQueryServicename() - */ - public function getQuery($conjunction = 'AND'); - - /** * Updates configuration upon synchronizing configuration changes. * * This callback is invoked when configuration is synchronized between storages diff --git a/core/lib/Drupal/Core/Entity/EntityStorageControllerBase.php b/core/lib/Drupal/Core/Entity/EntityStorageControllerBase.php index 5416935..9405ab2 100644 --- a/core/lib/Drupal/Core/Entity/EntityStorageControllerBase.php +++ b/core/lib/Drupal/Core/Entity/EntityStorageControllerBase.php @@ -8,6 +8,7 @@ namespace Drupal\Core\Entity; use Drupal\Core\Entity\Query\QueryInterface; use Drupal\Core\Extension\ModuleHandlerInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * A base entity storage controller class. @@ -194,10 +195,17 @@ protected function buildPropertyQuery(QueryInterface $entity_query, array $value */ public function loadByProperties(array $values = array()) { // Build a query to fetch the entity IDs. - $entity_query = \Drupal::entityQuery($this->entityTypeId); + $entity_query = $this->getQuery(); $this->buildPropertyQuery($entity_query, $values); $result = $entity_query->execute(); return $result ? $this->loadMultiple($result) : array(); } + /** + * {@inheritdoc} + */ + public function getQuery($conjunction = 'AND') { + return \Drupal::service($this->getQueryServicename())->get($this->entityType, $conjunction); + } + } diff --git a/core/lib/Drupal/Core/Entity/EntityStorageControllerInterface.php b/core/lib/Drupal/Core/Entity/EntityStorageControllerInterface.php index 3da5abc..56a0784 100644 --- a/core/lib/Drupal/Core/Entity/EntityStorageControllerInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityStorageControllerInterface.php @@ -155,6 +155,20 @@ public function save(EntityInterface $entity); public function getQueryServicename(); /** + * Returns an entity query instance. + * + * @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 instance. + * + * @see \Drupal\Core\Entity\EntityStorageControllerInterface::getQueryServicename() + */ + public function getQuery($conjunction = 'AND'); + + /** * Returns the entity type ID. * * @return string diff --git a/core/modules/field/lib/Drupal/field/FieldConfigStorageController.php b/core/modules/field/lib/Drupal/field/FieldConfigStorageController.php index f6d8759..7fb0866 100644 --- a/core/modules/field/lib/Drupal/field/FieldConfigStorageController.php +++ b/core/modules/field/lib/Drupal/field/FieldConfigStorageController.php @@ -54,8 +54,6 @@ class FieldConfigStorageController extends ConfigStorageController { * The config factory service. * @param \Drupal\Core\Config\StorageInterface $config_storage * The config storage service. - * @param \Drupal\Core\Entity\Query\QueryFactory $entity_query_factory - * The entity query factory. * @param \Drupal\Component\Uuid\UuidInterface $uuid_service * The UUID service. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager @@ -65,8 +63,8 @@ class FieldConfigStorageController extends ConfigStorageController { * @param \Drupal\Core\KeyValueStore\StateInterface $state * The state key value store. */ - public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, StorageInterface $config_storage, QueryFactory $entity_query_factory, UuidInterface $uuid_service, EntityManagerInterface $entity_manager, ModuleHandler $module_handler, StateInterface $state) { - parent::__construct($entity_type, $config_factory, $config_storage, $entity_query_factory, $uuid_service); + public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, StorageInterface $config_storage, UuidInterface $uuid_service, EntityManagerInterface $entity_manager, ModuleHandler $module_handler, StateInterface $state) { + parent::__construct($entity_type, $config_factory, $config_storage, $uuid_service); $this->entityManager = $entity_manager; $this->moduleHandler = $module_handler; $this->state = $state; @@ -80,7 +78,6 @@ public static function createInstance(ContainerInterface $container, EntityTypeI $entity_type, $container->get('config.factory'), $container->get('config.storage'), - $container->get('entity.query'), $container->get('uuid'), $container->get('entity.manager'), $container->get('module_handler'), diff --git a/core/modules/field/lib/Drupal/field/FieldInstanceConfigStorageController.php b/core/modules/field/lib/Drupal/field/FieldInstanceConfigStorageController.php index 1251b5e..d18fbf3 100644 --- a/core/modules/field/lib/Drupal/field/FieldInstanceConfigStorageController.php +++ b/core/modules/field/lib/Drupal/field/FieldInstanceConfigStorageController.php @@ -52,8 +52,6 @@ class FieldInstanceConfigStorageController extends ConfigStorageController { * The config factory service. * @param \Drupal\Core\Config\StorageInterface $config_storage * The config storage service. - * @param \Drupal\Core\Entity\Query\QueryFactory $entity_query_factory - * The entity query factory. * @param \Drupal\Component\Uuid\UuidInterface $uuid_service * The UUID service. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager @@ -61,8 +59,8 @@ class FieldInstanceConfigStorageController extends ConfigStorageController { * @param \Drupal\Core\KeyValueStore\StateInterface $state * The state key value store. */ - public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, StorageInterface $config_storage, QueryFactory $entity_query_factory, UuidInterface $uuid_service, EntityManagerInterface $entity_manager, StateInterface $state) { - parent::__construct($entity_type, $config_factory, $config_storage, $entity_query_factory, $uuid_service); + public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, StorageInterface $config_storage, UuidInterface $uuid_service, EntityManagerInterface $entity_manager, StateInterface $state) { + parent::__construct($entity_type, $config_factory, $config_storage, $uuid_service); $this->entityManager = $entity_manager; $this->state = $state; } @@ -75,7 +73,6 @@ public static function createInstance(ContainerInterface $container, EntityTypeI $entity_type, $container->get('config.factory'), $container->get('config.storage'), - $container->get('entity.query'), $container->get('uuid'), $container->get('entity.manager'), $container->get('state') diff --git a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php index ee9d0b8..51a7241 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php @@ -166,7 +166,7 @@ public function updateParentalStatus(EntityInterface $entity, $exclude = FALSE) // If plid == 0, there is nothing to update. if ($entity->plid) { // Check if at least one visible child exists in the table. - $query = \Drupal::entityQuery($this->entityTypeId); + $query = $this->getQuery(); $query ->condition('menu_name', $entity->menu_name) ->condition('hidden', 0) @@ -259,7 +259,7 @@ public function moveChildren(EntityInterface $entity) { * {@inheritdoc} */ public function countMenuLinks($menu_name) { - $query = \Drupal::entityQuery($this->entityTypeId); + $query = $this->getQuery(); $query ->condition('menu_name', $menu_name) ->count(); @@ -275,7 +275,7 @@ public function getParentFromHierarchy(EntityInterface $entity) { $parent = FALSE; $parent_path = substr($parent_path, 0, strrpos($parent_path, '/')); - $query = \Drupal::entityQuery($this->entityTypeId); + $query = $this->getQuery(); $query ->condition('mlid', $entity->id(), '<>') ->condition('module', 'system')