\QuickApps\Routing\FilterLanguageFilter

A dispatcher filter that prepares the language code to be used.

This filter MUST be used right after Routing filter or an exception will be throw.

Summary

Methods
Properties
Constants
beforeDispatch()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

beforeDispatch()

beforeDispatch(\Cake\Event\Event $event) : void

Prepares the default language to use by the script.

Detection Methods

This method applies the following detection methods when looking for language to use:

  • GET parameter: If locale GET parameter is present in current request, and if it's a valid language code, then will be used as current language and also will be persisted on locale session for further use.

  • URL: If current URL is prefixed with a valid language code and url_locale_prefix option is enabled, URL's language code will be used.

  • Locale session: If locale session exists it will be used.

  • User session: If user is logged in and has selected a valid preferred language it will be used.

  • Default: Site's language will be used otherwise.

Locale Prefix

If url_locale_prefix option is enabled, and current request's URL is not language prefixed, user will be redirected to a locale-prefixed version of the requested URL (using the language code selected as explained above).

For example:

/article/demo-article.html

Might redirects to:

/en_US/article/demo-article.html

Parameters

\Cake\Event\Event $event

containing the request, response and additional parameters

Throws

\Cake\Network\Exception\InternalErrorException

When no valid request object could be found