class ConfigFilterServiceProvider in Config Filter 8
Service provider to swap out the config sync service.
Hierarchy
- class \Drupal\Core\DependencyInjection\ServiceProviderBase implements ServiceModifierInterface, ServiceProviderInterface
- class \Drupal\config_filter\ConfigFilterServiceProvider
Expanded class hierarchy of ConfigFilterServiceProvider
File
- src/
ConfigFilterServiceProvider.php, line 15
Namespace
Drupal\config_filterView source
class ConfigFilterServiceProvider extends ServiceProviderBase {
/**
* {@inheritdoc}
*/
public function alter(ContainerBuilder $container) {
if ($container
->hasDefinition('config.storage.sync')) {
$original = $container
->getDefinition('config.storage.sync');
$id = 'config.storage.sync';
}
elseif ($container
->hasDefinition('config.storage.staging')) {
// For Drupal 8.
$original = $container
->getDefinition('config.storage.staging');
$id = 'config.storage.staging';
}
else {
throw new ServiceNotFoundException('config_filter.storage.original', 'config.storage.sync');
}
// Save the original service so that we can use it in the factory.
$container
->setDefinition('config_filter.storage.original', $original);
$definition = new Definition(FilteredStorage::class);
$definition
->setFactory([
new Reference('config_filter.storage_factory'),
'getSync',
]);
$container
->setDefinition($id, $definition);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigFilterServiceProvider:: |
public | function |
Modifies existing service definitions. Overrides ServiceProviderBase:: |
|
ServiceProviderBase:: |
public | function |
Registers services to the container. Overrides ServiceProviderInterface:: |
1 |