diff --git a/core/lib/Drupal/Core/Config/Entity/Query/Query.php b/core/lib/Drupal/Core/Config/Entity/Query/Query.php index 7f433cb..daafcd4 100644 --- a/core/lib/Drupal/Core/Config/Entity/Query/Query.php +++ b/core/lib/Drupal/Core/Config/Entity/Query/Query.php @@ -84,17 +84,8 @@ public function condition($property, $value = NULL, $operator = NULL, $langcode * Implements \Drupal\Core\Entity\Query\QueryInterface::execute(). */ public function execute() { - $entity_info = $this->entityManager->getDefinition($this->getEntityType()); - $prefix = $entity_info['config_prefix'] . '.'; - $prefix_length = strlen($prefix); - - // Load the relevant config files. - $configs = array(); - $names = $this->findNames($entity_info); - $config_objects = $this->configFactory->loadMultiple($names); - foreach ($config_objects as $config) { - $configs[substr($config->getName(), $prefix_length)] = $config->get(); - } + // Load the relevant config records. + $configs = $this->loadRecords(); // Apply conditions. $result = $this->condition->compile($configs); @@ -127,16 +118,15 @@ public function execute() { } /** - * Determines the names of config records to load for the query. - * - * @param array $entity_info - * The entity info. + * Loads the config records to examine for the query. * * @return array - * The list of config record names to load. + * Config records keyed by entity IDs. */ - protected function findNames(array $entity_info) { + protected function loadRecords() { + $entity_info = $this->entityManager->getDefinition($this->getEntityType()); $prefix = $entity_info['config_prefix'] . '.'; + $prefix_length = strlen($prefix); // If there are conditions on the config id, we can narrow the list of // config records to load and parse. @@ -160,12 +150,21 @@ protected function findNames(array $entity_info) { } } if ($ids) { - return array_map(function ($id) use ($prefix) { + $names = array_map(function ($id) use ($prefix) { return $prefix . $id; }, $ids); } + else { + // If no conditions on IDs were found, we need to look at all the records. + $names = $this->configStorage->listAll($prefix); + } - // If no conditions on IDs were found, we need to look at all the records. - return $this->configStorage->listAll($prefix); + // Load the corresponding records. + $records = array(); + foreach ($this->configFactory->loadMultiple($names) as $config) { + $records[substr($config->getName(), $prefix_length)] = $config->get(); + } + return $records; } + }