Issue #2163371 by alexpott: Replace \Drupal:config()->get with ConfigFactory::loadMultiple in Drupal\Core\Config\Entity\Query.
parent
1a24063df3
commit
0cecf582b9
|
@ -304,7 +304,7 @@ services:
|
|||
- [setContainer, ['@service_container']]
|
||||
entity.query.config:
|
||||
class: Drupal\Core\Config\Entity\Query\QueryFactory
|
||||
arguments: ['@config.storage']
|
||||
arguments: ['@config.storage', '@config.factory']
|
||||
entity.query.sql:
|
||||
class: Drupal\Core\Entity\Query\Sql\QueryFactory
|
||||
arguments: ['@database']
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
namespace Drupal\Core\Config\Entity\Query;
|
||||
|
||||
use Drupal\Core\Config\ConfigFactory;
|
||||
use Drupal\Core\Config\StorageInterface;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Entity\Query\QueryBase;
|
||||
|
@ -31,6 +32,13 @@ class Query extends QueryBase implements QueryInterface {
|
|||
*/
|
||||
protected $configStorage;
|
||||
|
||||
/**
|
||||
* The config factory used by the config entity query.
|
||||
*
|
||||
* @var \Drupal\Core\Config\ConfigFactory;
|
||||
*/
|
||||
protected $configFactory;
|
||||
|
||||
/**
|
||||
* Constructs a Query object.
|
||||
*
|
||||
|
@ -46,10 +54,11 @@ class Query extends QueryBase implements QueryInterface {
|
|||
* @param array $namespaces
|
||||
* 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);
|
||||
$this->entityManager = $entity_manager;
|
||||
$this->configStorage = $config_storage;
|
||||
$this->configFactory = $config_factory;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -81,8 +90,9 @@ class Query extends QueryBase implements QueryInterface {
|
|||
$prefix_length = strlen($prefix);
|
||||
$names = $this->configStorage->listAll($prefix);
|
||||
$configs = array();
|
||||
foreach ($names as $name) {
|
||||
$configs[substr($name, $prefix_length)] = \Drupal::config($name)->get();
|
||||
$config_objects = $this->configFactory->loadMultiple($names);
|
||||
foreach ($config_objects as $config) {
|
||||
$configs[substr($config->getName(), $prefix_length)] = $config->get();
|
||||
}
|
||||
|
||||
$result = $this->condition->compile($configs);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
namespace Drupal\Core\Config\Entity\Query;
|
||||
|
||||
use Drupal\Core\Config\ConfigFactory;
|
||||
use Drupal\Core\Config\StorageInterface;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Entity\Query\QueryBase;
|
||||
|
@ -25,6 +26,13 @@ class QueryFactory implements QueryFactoryInterface {
|
|||
*/
|
||||
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.
|
||||
*
|
||||
|
@ -37,9 +45,12 @@ class QueryFactory implements QueryFactoryInterface {
|
|||
*
|
||||
* @param \Drupal\Core\Config\StorageInterface $config_storage
|
||||
* 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->configFactory = $config_factory;
|
||||
$this->namespaces = QueryBase::getNamespaces($this);
|
||||
}
|
||||
|
||||
|
@ -47,7 +58,7 @@ class QueryFactory implements QueryFactoryInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue