LanguageNegotiationUrlFallback
class LanguageNegotiationUrlFallback extends LanguageNegotiationMethodBase (View source)
Class that determines the language to be assigned to URLs when none is detected.
The language negotiation process has a fallback chain that ends with the default language negotiation method. Each built-in language type has a separate initialization:
- Interface language, which is the only configurable one, always gets a valid value. If no request-specific language is detected, the default language will be used.
- Content language merely inherits the interface language by default.
- URL language is detected from the requested URL and will be used to rewrite
URLs appearing in the page being rendered. If no language can be detected,
there are two possibilities:
- If the default language has no configured path prefix or domain, then the default language is used. This guarantees that (missing) URL prefixes are preserved when navigating through the site.
- If the default language has a configured path prefix or domain, a requested URL having an empty prefix or domain is an anomaly that must be fixed. This is done by introducing a prefix or domain in the rendered page matching the detected interface language.
Constants
| METHOD_ID |
The language negotiation method id. |
Properties
| protected LanguageManagerInterface | $languageManager | The language manager. |
from LanguageNegotiationMethodBase |
| protected ConfigFactoryInterface | $config | The configuration factory. |
from LanguageNegotiationMethodBase |
| protected AccountInterface | $currentUser | The current active user. |
from LanguageNegotiationMethodBase |
Methods
Injects the language manager.
Notifies the plugin that the language code it returned has been accepted.
Performs language negotiation.
Details
setLanguageManager(ConfigurableLanguageManagerInterface $language_manager)
Injects the language manager.
setConfig(ConfigFactoryInterface $config)
Injects the configuration factory.
setCurrentUser(AccountInterface $current_user)
Injects the current user.
persist(LanguageInterface $language)
Notifies the plugin that the language code it returned has been accepted.
string
getLangcode(Request $request = NULL)
Performs language negotiation.