LanguageNegotiator
class LanguageNegotiator implements LanguageNegotiatorInterface (View source)
Class responsible for performing language negotiation.
Properties
| protected PluginManagerInterface | $negotiatorManager | The language negotiation method plugin manager. |
|
| protected ConfigurableLanguageManagerInterface | $languageManager | The language manager. |
|
| protected ConfigFactoryInterface | $configFactory | The configuration factory. |
|
| protected Settings | $settings | The settings instance. |
|
| protected RequestStack | $requestStack | The request stack object. |
|
| protected AccountInterface | $currentUser | The current active user. |
|
| protected array | $methods | Local cache for language negotiation method instances. |
|
| protected LanguageInterface[] | $negotiatedLanguages | An array of language objects keyed by method id. |
Methods
Constructs a new LanguageNegotiator object.
Initializes the injected language manager with the negotiator.
Resets the negotiated languages and the method instances.
Sets the current active user and resets all language types.
Initializes the specified language type.
Gets enabled detection methods for the provided language type.
Performs language negotiation using the specified negotiation method.
Returns the language negotiation methods enabled for a language type.
Returns an instance of the specified language negotiation method.
Returns the ID of the language type's primary language negotiation method.
Checks whether a language negotiation method is enabled for a language type.
Saves a list of language negotiation methods for a language type.
Resave the configuration to purge missing negotiation methods.
Updates the configuration based on the given language types.
Details
__construct(ConfigurableLanguageManagerInterface $language_manager, PluginManagerInterface $negotiator_manager, ConfigFactoryInterface $config_factory, Settings $settings, RequestStack $requestStack)
Constructs a new LanguageNegotiator object.
initLanguageManager()
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.
reset()
Resets the negotiated languages and the method instances.
setCurrentUser(AccountInterface $current_user)
Sets the current active user and resets all language types.
LanguageInterface[]
initializeType(string $type)
Initializes the specified language type.
protected array
getEnabledNegotiators(string $type)
Gets enabled detection methods for the provided language type.
protected LanguageInterface|null
negotiateLanguage(string $type, string $method_id)
Performs language negotiation using the specified negotiation method.
array[]
getNegotiationMethods(string $type = NULL)
Returns the language negotiation methods enabled for a language type.
LanguageNegotiationMethodInterface
getNegotiationMethodInstance(string $method_id)
Returns an instance of the specified language negotiation method.
string
getPrimaryNegotiationMethod(string $type)
Returns the ID of the language type's primary language negotiation method.
bool
isNegotiationMethodEnabled(string $method_id, string $type = NULL)
Checks whether a language negotiation method is enabled for a language type.
saveConfiguration(string $type, int[] $enabled_methods)
Saves a list of language negotiation methods for a language type.
purgeConfiguration()
Resave the configuration to purge missing negotiation methods.
updateConfiguration(array $types)
Updates the configuration based on the given language types.
Stores the list of the language types along with information about their configurable state. Stores the default settings if the language type is not configurable.