setNegotiator example


  public function onContainerInitializeSubrequestFinished() {
    $this->setLanguageOverrides();
  }

  /** * Sets the language for config overrides on the language manager. */
  private function setLanguageOverrides() {
    $this->negotiator->setCurrentUser($this->currentUser);
    if ($this->languageManager instanceof ConfigurableLanguageManagerInterface) {
      $this->languageManager->setNegotiator($this->negotiator);
      $this->languageManager->setConfigOverrideLanguage($this->languageManager->getCurrentLanguage());
    }
    // After the language manager has initialized, set the default langcode for     // the string translations.     $langcode = $this->languageManager->getCurrentLanguage()->getId();
    $this->translation->setDefaultLangcode($langcode);
  }

  /** * Registers the methods in this class that should be listeners. * * @return array * An array of event listener definitions. */
$this->requestStack = $requestStack;
  }

  /** * Initializes the injected language manager with the negotiator. * * This should be called right after instantiating the negotiator to make it * available to the language manager without introducing a circular * dependency. */
  public function initLanguageManager() {
    $this->languageManager->setNegotiator($this);
  }

  /** * {@inheritdoc} */
  public function reset() {
    $this->negotiatedLanguages = [];
    $this->methods = [];
  }

  /** * {@inheritdoc} */
Home | Imprint | This part of the site doesn't use cookies.