class ConfigCollector in Configuration Provider 8
Same name and namespace in other branches
- 8.2 src/Plugin/ConfigCollector.php \Drupal\config_provider\Plugin\ConfigCollector
Class for invoking configuration providers..
Hierarchy
- class \Drupal\config_provider\Plugin\ConfigCollector implements ConfigCollectorInterface
Expanded class hierarchy of ConfigCollector
1 string reference to 'ConfigCollector'
1 service uses ConfigCollector
File
- src/
Plugin/ ConfigCollector.php, line 13
Namespace
Drupal\config_provider\PluginView source
class ConfigCollector implements ConfigCollectorInterface {
/**
* The configuration factory.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
/**
* The active configuration storage.
*
* @var \Drupal\Core\Config\StorageInterface
*/
protected $activeStorage;
/**
* The configuration manager.
*
* @var \Drupal\Core\Config\ConfigManagerInterface
*/
protected $configManager;
/**
* The provider configuration storage.
*
* @var \Drupal\Core\Config\StorageInterface
*/
protected $providerStorage;
/**
* The configuration provider manager.
*
* @var \Drupal\config_provider\Plugin\ConfigProviderManager
*/
protected $configProviderManager;
/**
* The configuration provider plugin instances.
*
* @var \Drupal\config_provider\Plugin\ConfigProvider
*/
protected $configProviders;
/**
* Constructor for ConfigCollector objects.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The configuration factory.
* @param \Drupal\Core\Config\StorageInterface $active_storage
* The active configuration storage.
* @param \Drupal\Core\Config\ConfigManagerInterface $config_manager
* The configuration manager.
* @param \Drupal\Core\Config\StorageInterface $provider_storage
* The provider configuration storage.
* @param \Drupal\config_provider\Plugin\ConfigProviderManager $config_provider_manager
* The configuration provider manager.
*/
public function __construct(ConfigFactoryInterface $config_factory, StorageInterface $active_storage, ConfigManagerInterface $config_manager, StorageInterface $provider_storage, ConfigProviderManager $config_provider_manager) {
$this->configFactory = $config_factory;
$this->activeStorage = $active_storage;
$this->configManager = $config_manager;
$this->providerStorage = $provider_storage;
$this->configProviderManager = $config_provider_manager;
$this->configProviders = [];
}
/**
* {@inheritdoc}
*/
public function getConfigProviders() {
if (empty($this->configProviders)) {
$definitions = $this->configProviderManager
->getDefinitions();
foreach (array_keys($definitions) as $id) {
$this
->initConfigProviderInstance($id);
}
}
return $this->configProviders;
}
/**
* {@inheritdoc}
*/
public function getInstallableConfig(array $extensions = []) {
// Start with an empty storage.
$this->providerStorage
->deleteAll();
/* @var \Drupal\config_provider\Plugin\ConfigProviderInterface[] $providers */
$providers = $this
->getConfigProviders();
foreach ($providers as $provider) {
$provider
->addInstallableConfig($this->providerStorage, $extensions);
}
return $this->providerStorage;
}
/**
* Initializes an instance of the specified configuration provider.
*
* @param string $id
* The string identifier of the configuration provider.
*/
protected function initConfigProviderInstance($id) {
if (!isset($this->configProviders[$id])) {
$instance = $this->configProviderManager
->createInstance($id, []);
$instance
->setConfigFactory($this->configFactory);
$instance
->setActiveStorages($this->activeStorage);
$instance
->setConfigManager($this->configManager);
$this->configProviders[$id] = $instance;
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigCollector:: |
protected | property | The active configuration storage. | |
ConfigCollector:: |
protected | property | The configuration factory. | |
ConfigCollector:: |
protected | property | The configuration manager. | |
ConfigCollector:: |
protected | property | The configuration provider manager. | |
ConfigCollector:: |
protected | property | The configuration provider plugin instances. | |
ConfigCollector:: |
protected | property | The provider configuration storage. | |
ConfigCollector:: |
public | function |
Gets all configuration provider plugins. Overrides ConfigCollectorInterface:: |
|
ConfigCollector:: |
public | function |
Gets installable configuration from all provider plugins. Overrides ConfigCollectorInterface:: |
|
ConfigCollector:: |
protected | function | Initializes an instance of the specified configuration provider. | |
ConfigCollector:: |
public | function | Constructor for ConfigCollector objects. |