function LanguageNegotiator::getNegotiationMethodInstance

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

File

core/modules/language/src/LanguageNegotiator.php, line 219

Class

LanguageNegotiator
Class responsible for performing language negotiation.

Namespace

Drupal\language

Code

public function getNegotiationMethodInstance($method_id) {
  if (!isset($this->methods[$method_id])) {
    $instance = $this->negotiatorManager
      ->createInstance($method_id, []);
    $instance->setLanguageManager($this->languageManager);
    $instance->setConfig($this->configFactory);
    $instance->setCurrentUser($this->currentUser);
    $this->methods[$method_id] = $instance;
  }
  return $this->methods[$method_id];
}

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