Drupal 8  8.0.2
LanguageNegotiationUrlFallback Class Reference
Inheritance diagram for LanguageNegotiationUrlFallback:

Public Member Functions

 getLangcode (Request $request=NULL)
 
- Public Member Functions inherited from LanguageNegotiationMethodBase
 setLanguageManager (ConfigurableLanguageManagerInterface $language_manager)
 
 setConfig (ConfigFactoryInterface $config)
 
 setCurrentUser (AccountInterface $current_user)
 
 persist (LanguageInterface $language)
 

Data Fields

const METHOD_ID = 'language-url-fallback'
 

Additional Inherited Members

- Protected Attributes inherited from LanguageNegotiationMethodBase
 $languageManager
 
 $config
 
 $currentUser
 

Detailed Description

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.

( id = Drupal::METHOD_ID, types = {Drupal::TYPE_URL}, weight = 8, name = ("URL fallback"), description = ("Use an already detected language for URLs if none is found.") )

Member Function Documentation

getLangcode ( Request  $request = NULL)

{Performs language negotiation.

Parameters
\Symfony\Component\HttpFoundation\Request$request(optional) The current request. Defaults to NULL if it has not been initialized yet.
Returns
string A valid language code or FALSE if the negotiation was unsuccessful.
}

Implements LanguageNegotiationMethodInterface.

References Drupal\config(), LanguageNegotiationUrl\CONFIG_PATH_PREFIX, and Drupal\languageManager().

Here is the call graph for this function:

Field Documentation

const METHOD_ID = 'language-url-fallback'

The language negotiation method id.


The documentation for this class was generated from the following file: