PHP Class Psr7Middlewares\Middleware\LanguageNegotiator

Inheritance: use trait Psr7Middlewares\Utils\NegotiateTrait, use trait Psr7Middlewares\Utils\RedirectTrait, use trait Psr7Middlewares\Utils\AttributeTrait
Datei anzeigen Open project: oscarotero/psr7-middlewares Class Usage Examples

Public Methods

Method Description
__construct ( array $languages ) Define de available languages.
__invoke ( Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Message\ResponseInterface $response, callable $next ) : Psr\Http\Message\ResponseInterface Execute the middleware.
getLanguage ( Psr\Http\Message\ServerRequestInterface $request ) : string | null Returns the language.
usePath ( boolean $usePath = true ) : self Use the base path to detect the current language.

Method Details

__construct() public method

Define de available languages.
public __construct ( array $languages )
$languages array

__invoke() public method

Execute the middleware.
public __invoke ( Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Message\ResponseInterface $response, callable $next ) : Psr\Http\Message\ResponseInterface
$request Psr\Http\Message\ServerRequestInterface
$response Psr\Http\Message\ResponseInterface
$next callable
return Psr\Http\Message\ResponseInterface

getLanguage() public static method

Returns the language.
public static getLanguage ( Psr\Http\Message\ServerRequestInterface $request ) : string | null
$request Psr\Http\Message\ServerRequestInterface
return string | null

usePath() public method

Use the base path to detect the current language.
public usePath ( boolean $usePath = true ) : self
$usePath boolean
return self