LanguageServiceProvider::register

public LanguageServiceProvider::register(ContainerBuilder $container)

Registers services to the container.

Parameters

ContainerBuilder $container: The ContainerBuilder to register services to.

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', array('priority' => 300))
      ->addTag('path_processor_outbound', array('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');
  }
}
doc_Drupal
2016-10-29 09:23:00
Comments
Leave a Comment

Please login to continue.