LocaleMiddleware
in package
implements
MiddlewareInterface
Read onlyYes
FinalYes
Table of Contents
Interfaces
Constants
- ALLOWED_LOCALES = ['en', 'pl']
- DEFAULT_LOCALE = 'en'
Properties
Methods
- __construct() : mixed
- handle() : ResponseInterface
- detectLocale() : string
- getSessionLocale() : string|null
- parseAcceptLanguageHeader() : string|null
- validate() : string|null
Constants
ALLOWED_LOCALES
private
mixed
ALLOWED_LOCALES
= ['en', 'pl']
DEFAULT_LOCALE
private
mixed
DEFAULT_LOCALE
= 'en'
Properties
$context
private
LocaleContext
$context
Methods
__construct()
public
__construct(LocaleContext $context) : mixed
Parameters
- $context : LocaleContext
handle()
public
handle(ServerRequestInterface $request, callable $next) : ResponseInterface
Parameters
- $request : ServerRequestInterface
- $next : callable
Return values
ResponseInterfacedetectLocale()
private
detectLocale() : string
Return values
stringgetSessionLocale()
private
getSessionLocale() : string|null
Return values
string|nullparseAcceptLanguageHeader()
private
parseAcceptLanguageHeader() : string|null
Return values
string|nullvalidate()
private
validate(string $locale) : string|null
Parameters
- $locale : string