Problem/Motivation
Language module alters definition of 'language_manager' service from core.services.yml (see LanguageServiceProvider::alter()):
<?php
public function alter(ContainerBuilder $container) {
$definition = $container->getDefinition('language_manager');
$definition->setClass('Drupal\language\ConfigurableLanguageManager')
->addArgument(new Reference('config.factory'))
->addArgument(new Reference('module_handler'))
->addArgument(new Reference('language.config_factory_override'))
->addArgument(new Reference('request_stack'));
if ($default_language_values = $this->getDefaultLanguageValues()) {
$container->setParameter('language.default_values', $default_language_values);
}
}
?>
This way of altering the service makes it hard for non-core modules to decorate the service, since the decorator cannot know the class of decorated service.
Proposed resolution
Instead of altering language manager service, language module could declare another public service, which will decorate language manager service.
Remaining tasks
- Create the new service (language.language_manager?) in language.services.yml
- Remove LanguageServiceProvider::alter() method
- Update the code of language module to use the new service
- Update the tests
User interface changes
No UI changes
API changes
New service language.language_manager, existing only when language module is enabled
Data model changes
No data model changes.
Release notes snippet
Language module exposes its own, extended language_manager service as language.language_manager