PHP Class Psr7Middlewares\Middleware\LanguageNegotiator

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

Méthodes publiques

Méthode 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 méthode

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

__invoke() public méthode

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
Résultat Psr\Http\Message\ResponseInterface

getLanguage() public static méthode

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

usePath() public méthode

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