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

$persist_cookie

Use cookies for locale persistence.

$persist_cookie_expiry

The expiry time in days for a locale persistence cookie

$persist_cookie_path

Use this path when setting the locale cookie

$persist_cookie_domain

Use this domain when setting the locale cookie

$persist_cookie_http_only

Use http-only cookies. Set to false if you need js access.

Methods

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

process(HTTPRequest $request, callable $delegate)

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, .....).

Return Value

Config_ForClass

mixed uninherited(string $name)

Gets the uninherited value for the given config option

Parameters

string $name

Return Value

mixed

HTTPResponse process(HTTPRequest $request, callable $delegate)

Sets the current locale to the FluentState, provided no previous middleware has set it first

{@inheritDoc}

Parameters

HTTPRequest $request
callable $delegate

Return Value

HTTPResponse