function LanguageServiceProvider::register

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

Overrides ServiceProviderBase::register

File

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

Class

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

Namespace

Drupal\language

Code

public function register(ContainerBuilder $container) {
    // The following services are needed only on multilingual sites.
    if ($this->isMultilingual()) {
        $container->register('language_request_subscriber', 'Drupal\\language\\EventSubscriber\\LanguageRequestSubscriber')
            ->addTag('event_subscriber')
            ->addArgument(new Reference('language_manager'))
            ->addArgument(new Reference('language_negotiator'))
            ->addArgument(new Reference('string_translation'))
            ->addArgument(new Reference('current_user'));
        $container->register('path_processor_language', 'Drupal\\language\\HttpKernel\\PathProcessorLanguage')
            ->addTag('path_processor_inbound', [
            'priority' => 300,
        ])
            ->addTag('path_processor_outbound', [
            'priority' => 100,
        ])
            ->addArgument(new Reference('config.factory'))
            ->addArgument(new Reference('language_manager'))
            ->addArgument(new Reference('language_negotiator'))
            ->addArgument(new Reference('current_user'))
            ->addArgument(new Reference('language.config_subscriber'))
            ->addMethodCall('initConfigSubscriber');
    }
}

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