Chris@0: query->has('q') && strtok($request->query->get('q'), '/') == 'admin') { Chris@0: * return $this->languageManager->getDefaultLanguage()->getId(); Chris@0: * } Chris@0: * return $langcode; Chris@0: * } Chris@0: * } Chris@0: * } Chris@0: * @endcode Chris@0: * Chris@0: * For more information, see Chris@0: * @link https://www.drupal.org/node/1497272 Language Negotiation API @endlink Chris@0: */ Chris@0: interface LanguageNegotiatorInterface { Chris@0: Chris@0: /** Chris@0: * The language negotiation method id for the language negotiator itself. Chris@0: */ Chris@0: const METHOD_ID = 'language-default'; Chris@0: Chris@0: /** Chris@0: * Resets the negotiated languages and the method instances. Chris@0: */ Chris@0: public function reset(); Chris@0: Chris@0: /** Chris@0: * Sets the current active user and resets all language types. Chris@0: * Chris@0: * @param \Drupal\Core\Session\AccountInterface $current_user Chris@0: * The current active user. Chris@0: */ Chris@0: public function setCurrentUser(AccountInterface $current_user); Chris@0: Chris@0: /** Chris@0: * Initializes the specified language type. Chris@0: * Chris@0: * @param string $type Chris@0: * The language type to be initialized. Chris@0: * Chris@0: * @return \Drupal\Core\Language\LanguageInterface[] Chris@0: * Returns an array containing a single language keyed by the language Chris@0: * negotiation method ID used to determine the language of the specified Chris@0: * type. If negotiation is not possible the default language is returned. Chris@0: */ Chris@0: public function initializeType($type); Chris@0: Chris@0: /** Chris@0: * Returns the language negotiation methods enabled for a language type. Chris@0: * Chris@0: * @param string $type Chris@0: * (optional) The language type. If no type is specified all the method Chris@0: * definitions are returned. Chris@0: * Chris@0: * @return array[] Chris@0: * An array of language negotiation method definitions keyed by method id. Chris@0: */ Chris@0: public function getNegotiationMethods($type = NULL); Chris@0: Chris@0: /** Chris@0: * Returns an instance of the specified language negotiation method. Chris@0: * Chris@0: * @param string $method_id Chris@0: * The method identifier. Chris@0: * Chris@0: * @return \Drupal\language\LanguageNegotiationMethodInterface Chris@0: */ Chris@0: public function getNegotiationMethodInstance($method_id); Chris@0: Chris@0: /** Chris@0: * Returns the ID of the language type's primary language negotiation method. Chris@0: * Chris@0: * @param string $type Chris@0: * The language type. Chris@0: * Chris@0: * @return string Chris@0: * The identifier of the primary language negotiation method for the given Chris@0: * language type, or the default method if none exists. Chris@0: */ Chris@0: public function getPrimaryNegotiationMethod($type); Chris@0: Chris@0: /** Chris@0: * Checks whether a language negotiation method is enabled for a language type. Chris@0: * Chris@0: * @param string $method_id Chris@0: * The language negotiation method ID. Chris@0: * @param string $type Chris@0: * (optional) The language type. If none is passed, all the configurable Chris@0: * language types will be inspected. Chris@0: * Chris@0: * @return bool Chris@0: * TRUE if the method is enabled for at least one of the given language Chris@0: * types, or FALSE otherwise. Chris@0: */ Chris@0: public function isNegotiationMethodEnabled($method_id, $type = NULL); Chris@0: Chris@0: /** Chris@0: * Saves a list of language negotiation methods for a language type. Chris@0: * Chris@0: * @param string $type Chris@0: * The language type. Chris@0: * @param int[] $enabled_methods Chris@0: * An array of language negotiation method weights keyed by method ID. Chris@0: */ Chris@0: public function saveConfiguration($type, $enabled_methods); Chris@0: Chris@0: /** Chris@0: * Resave the configuration to purge missing negotiation methods. Chris@0: */ Chris@0: public function purgeConfiguration(); Chris@0: Chris@0: /** Chris@0: * Updates the configuration based on the given language types. Chris@0: * Chris@0: * Stores the list of the language types along with information about their Chris@0: * configurable state. Stores the default settings if the language type is Chris@0: * not configurable. Chris@0: * Chris@0: * @param string[] $types Chris@0: * An array of configurable language types. Chris@0: */ Chris@0: public function updateConfiguration(array $types); Chris@0: Chris@0: }