function LanguageNegotiator::getNegotiationMethodInstance
Returns an instance of the specified language negotiation method.
Parameters
string $method_id: The method identifier.
Return value
\Drupal\language\LanguageNegotiationMethodInterface
Overrides LanguageNegotiatorInterface::getNegotiationMethodInstance
File
- 
              core/
modules/ language/ src/ LanguageNegotiator.php, line 219  
Class
- LanguageNegotiator
 - Class responsible for performing language negotiation.
 
Namespace
Drupal\languageCode
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.