You are here

public function LanguageServiceProvider::alter in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/language/src/LanguageServiceProvider.php \Drupal\language\LanguageServiceProvider::alter()

Modifies existing service definitions.

Parameters

ContainerBuilder $container: The ContainerBuilder whose service definitions can be altered.

Overrides ServiceProviderBase::alter

File

core/modules/language/src/LanguageServiceProvider.php, line 51
Contains \Drupal\language\LanguageServiceProvider.

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

  // For monolingual sites, we explicitly set the default language for the
  // language config override service as there is no language negotiation.
  if (!$this
    ->isMultilingual()) {
    $container
      ->getDefinition('language.config_factory_override')
      ->addMethodCall('setLanguageFromDefault', array(
      new Reference('language.default'),
    ));
  }
}