PHP Class Psr7Middlewares\Middleware\Geolocate

Inheritance: use trait Psr7Middlewares\Utils\StorageTrait
ファイルを表示 Open project: oscarotero/psr7-middlewares

Public Methods

Method Description
__construct ( Geocoder $geocoder = null ) Constructor. Set the geocoder instance.
__invoke ( Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Message\ResponseInterface $response, callable $next ) : Psr\Http\Message\ResponseInterface Execute the middleware.
getLocation ( Psr\Http\Message\ServerRequestInterface $request ) : Geocoder\Model\AddressCollection | null Returns the client location.
saveInSession ( boolean $save = true ) : self Wheter or not save the geolocation in a session variable.

Method Details

__construct() public method

Constructor. Set the geocoder instance.
public __construct ( Geocoder $geocoder = null )
$geocoder Geocoder\Geocoder

__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

getLocation() public static method

Returns the client location.
public static getLocation ( Psr\Http\Message\ServerRequestInterface $request ) : Geocoder\Model\AddressCollection | null
$request Psr\Http\Message\ServerRequestInterface
return Geocoder\Model\AddressCollection | null

saveInSession() public method

Wheter or not save the geolocation in a session variable.
public saveInSession ( boolean $save = true ) : self
$save boolean
return self