You are here

public function LanguageNegotiator::getNegotiationMethodInstance in Drupal 10

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

File

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

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