DetectLocaleMiddleware
class DetectLocaleMiddleware implements HTTPMiddleware (View source)
DetectLocaleMiddleware will detect if a locale has been requested (or is default) and is not the current locale, and will redirect the user to that locale if needed.
Will cascade through different checks in order, see "configuration" docs for details. Additionally, detected locales will be set in session and cookies.
Traits
Provides extensions to this object to integrate it with standard config API methods.
Properties
static private string[] | $persist_ids | IDs to persist the locale in cookies / session in the front end, CMS, etc |
|
static private bool | $persist_cookie | Use cookies for locale persistence. |
|
static private int | $persist_cookie_expiry | The expiry time in days for a locale persistence cookie |
|
static private string | $persist_cookie_path | Use this path when setting the locale cookie |
|
static private string | $persist_cookie_domain | Use this domain when setting the locale cookie |
|
static private bool | $persist_cookie_http_only | Use http-only cookies. Set to false if you need js access. |
Methods
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).
Gets the uninherited value for the given config option
Sets the current locale to the FluentState, provided no previous middleware has set it first
Details
static Config_ForClass
config()
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).
mixed
uninherited(string $name)
Gets the uninherited value for the given config option
HTTPResponse
process(HTTPRequest $request, callable $delegate)
Sets the current locale to the FluentState, provided no previous middleware has set it first
{@inheritDoc}