ConfigImportServiceProvider.php in Config Importer and Tools 8
File
src/ConfigImportServiceProvider.php
View source
<?php
namespace Drupal\config_import;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ServiceProviderBase;
class ConfigImportServiceProvider extends ServiceProviderBase {
private $container;
public function register(ContainerBuilder $container) {
$this->container = $container;
$this
->registerFeaturesImporter();
}
protected function registerFeaturesImporter() {
$this
->registerService('config_import.features_importer', ConfigFeaturesImporterService::class, [
'config_update.config_update',
'features.manager',
'features_assigner',
], [
'logger.factory',
]);
}
protected function registerService($id, $class, array $required, array $optional = []) {
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)));
}
}
}