class ConfigImportServiceProvider in Config Importer and Tools 8.2
Same name and namespace in other branches
- 8 src/ConfigImportServiceProvider.php \Drupal\config_import\ConfigImportServiceProvider
Class ConfigImportServiceProvider.
Hierarchy
- class \Drupal\Core\DependencyInjection\ServiceProviderBase implements ServiceModifierInterface, ServiceProviderInterface
- class \Drupal\config_import\ConfigImportServiceProvider
Expanded class hierarchy of ConfigImportServiceProvider
File
- src/
ConfigImportServiceProvider.php, line 11
Namespace
Drupal\config_importView source
class ConfigImportServiceProvider extends ServiceProviderBase {
/**
* DI container.
*
* @var ContainerBuilder
*/
private $container;
/**
* {@inheritdoc}
*/
public function register(ContainerBuilder $container) {
$this->container = $container;
$this
->registerFeaturesImporter();
}
/**
* Register features importer service if dependencies installed.
*
* @see ConfigFeaturesImporterService::create()
*/
protected function registerFeaturesImporter() {
$this
->registerService('config_import.features_importer', ConfigFeaturesImporterService::class, [
'config_update.config_update',
'features.manager',
'features_assigner',
], [
'logger.factory',
]);
}
/**
* Register service if required dependencies are available within container.
*
* @param string $id
* Service ID.
* @param string $class
* FQN of service class.
* @param string[] $required
* List of required dependency names.
* @param string[] $optional
* List of optional dependency names.
*/
protected function registerService($id, $class, array $required, array $optional = []) {
// All required services must be available within container.
if (count(array_filter(array_map([
$this->container,
'has',
], $required))) === count($required)) {
$this->container
->register($id, $class)
->setArguments(array_map([
$this->container,
'getDefinition',
], array_merge($required, $optional)));
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigImportServiceProvider:: |
private | property | DI container. | |
ConfigImportServiceProvider:: |
public | function |
Registers services to the container. Overrides ServiceProviderBase:: |
|
ConfigImportServiceProvider:: |
protected | function | Register features importer service if dependencies installed. | |
ConfigImportServiceProvider:: |
protected | function | Register service if required dependencies are available within container. | |
ServiceProviderBase:: |
public | function |
Modifies existing service definitions. Overrides ServiceModifierInterface:: |
5 |