function LanguageServiceProvider::alter

Same name in other branches
  1. 9 core/modules/language/src/LanguageServiceProvider.php \Drupal\language\LanguageServiceProvider::alter()
  2. 8.9.x core/modules/language/src/LanguageServiceProvider.php \Drupal\language\LanguageServiceProvider::alter()
  3. 11.x core/modules/language/src/LanguageServiceProvider.php \Drupal\language\LanguageServiceProvider::alter()

Overrides ServiceProviderBase::alter

File

core/modules/language/src/LanguageServiceProvider.php, line 46

Class

LanguageServiceProvider
Overrides the language_manager service to point to language's module one.

Namespace

Drupal\language

Code

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);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.