Commit 0cecf582 authored by webchick's avatar webchick

Issue #2163371 by alexpott: Replace \Drupal:config()->get with...

Issue #2163371 by alexpott: Replace \Drupal:config()->get with ConfigFactory::loadMultiple in Drupal\Core\Config\Entity\Query.
parent 1a24063d
...@@ -304,7 +304,7 @@ services: ...@@ -304,7 +304,7 @@ services:
- [setContainer, ['@service_container']] - [setContainer, ['@service_container']]
entity.query.config: entity.query.config:
class: Drupal\Core\Config\Entity\Query\QueryFactory class: Drupal\Core\Config\Entity\Query\QueryFactory
arguments: ['@config.storage'] arguments: ['@config.storage', '@config.factory']
entity.query.sql: entity.query.sql:
class: Drupal\Core\Entity\Query\Sql\QueryFactory class: Drupal\Core\Entity\Query\Sql\QueryFactory
arguments: ['@database'] arguments: ['@database']
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
namespace Drupal\Core\Config\Entity\Query; namespace Drupal\Core\Config\Entity\Query;
use Drupal\Core\Config\ConfigFactory;
use Drupal\Core\Config\StorageInterface; use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\Query\QueryBase; use Drupal\Core\Entity\Query\QueryBase;
...@@ -31,6 +32,13 @@ class Query extends QueryBase implements QueryInterface { ...@@ -31,6 +32,13 @@ class Query extends QueryBase implements QueryInterface {
*/ */
protected $configStorage; protected $configStorage;
/**
* The config factory used by the config entity query.
*
* @var \Drupal\Core\Config\ConfigFactory;
*/
protected $configFactory;
/** /**
* Constructs a Query object. * Constructs a Query object.
* *
...@@ -46,10 +54,11 @@ class Query extends QueryBase implements QueryInterface { ...@@ -46,10 +54,11 @@ class Query extends QueryBase implements QueryInterface {
* @param array $namespaces * @param array $namespaces
* List of potential namespaces of the classes belonging to this query. * List of potential namespaces of the classes belonging to this query.
*/ */
function __construct($entity_type, $conjunction, EntityManagerInterface $entity_manager, StorageInterface $config_storage, array $namespaces) { function __construct($entity_type, $conjunction, EntityManagerInterface $entity_manager, StorageInterface $config_storage, ConfigFactory $config_factory, array $namespaces) {
parent::__construct($entity_type, $conjunction, $namespaces); parent::__construct($entity_type, $conjunction, $namespaces);
$this->entityManager = $entity_manager; $this->entityManager = $entity_manager;
$this->configStorage = $config_storage; $this->configStorage = $config_storage;
$this->configFactory = $config_factory;
} }
/** /**
...@@ -81,8 +90,9 @@ public function execute() { ...@@ -81,8 +90,9 @@ public function execute() {
$prefix_length = strlen($prefix); $prefix_length = strlen($prefix);
$names = $this->configStorage->listAll($prefix); $names = $this->configStorage->listAll($prefix);
$configs = array(); $configs = array();
foreach ($names as $name) { $config_objects = $this->configFactory->loadMultiple($names);
$configs[substr($name, $prefix_length)] = \Drupal::config($name)->get(); foreach ($config_objects as $config) {
$configs[substr($config->getName(), $prefix_length)] = $config->get();
} }
$result = $this->condition->compile($configs); $result = $this->condition->compile($configs);
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
namespace Drupal\Core\Config\Entity\Query; namespace Drupal\Core\Config\Entity\Query;
use Drupal\Core\Config\ConfigFactory;
use Drupal\Core\Config\StorageInterface; use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\Query\QueryBase; use Drupal\Core\Entity\Query\QueryBase;
...@@ -25,6 +26,13 @@ class QueryFactory implements QueryFactoryInterface { ...@@ -25,6 +26,13 @@ class QueryFactory implements QueryFactoryInterface {
*/ */
protected $configStorage; protected $configStorage;
/**
* The config factory used by the config entity query.
*
* @var \Drupal\Core\Config\ConfigFactory;
*/
protected $configFactory;
/** /**
* The namespace of this class, the parent class etc. * The namespace of this class, the parent class etc.
* *
...@@ -37,9 +45,12 @@ class QueryFactory implements QueryFactoryInterface { ...@@ -37,9 +45,12 @@ class QueryFactory implements QueryFactoryInterface {
* *
* @param \Drupal\Core\Config\StorageInterface $config_storage * @param \Drupal\Core\Config\StorageInterface $config_storage
* The config storage used by the config entity query. * The config storage used by the config entity query.
* @param \Drupal\Core\Config\ConfigFactory $config_factory
* The config storage used by the config entity query.
*/ */
public function __construct(StorageInterface $config_storage) { public function __construct(StorageInterface $config_storage, ConfigFactory $config_factory) {
$this->configStorage = $config_storage; $this->configStorage = $config_storage;
$this->configFactory = $config_factory;
$this->namespaces = QueryBase::getNamespaces($this); $this->namespaces = QueryBase::getNamespaces($this);
} }
...@@ -47,7 +58,7 @@ public function __construct(StorageInterface $config_storage) { ...@@ -47,7 +58,7 @@ public function __construct(StorageInterface $config_storage) {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function get($entity_type, $conjunction, EntityManagerInterface $entity_manager) { public function get($entity_type, $conjunction, EntityManagerInterface $entity_manager) {
return new Query($entity_type, $conjunction, $entity_manager, $this->configStorage, $this->namespaces); return new Query($entity_type, $conjunction, $entity_manager, $this->configStorage, $this->configFactory, $this->namespaces);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment