PHP Class Respect\Rest\Request

Afficher le fichier Open project: respect/rest Class Usage Examples

Méthodes publiques

Свойство Type Description
$method The HTTP method (commonly GET, POST, PUT, DELETE, HEAD)
$params A numeric array containing valid URL parameters. For a route path like /users/*, a Request for /users/alganet should have an array equivalent to ['alganet']
$route A route matched for this request
$uri The called URI

Méthodes publiques

Méthode Description
__construct ( string $method = null, string $uri = null )
__toString ( ) Converting this request to string dispatch
forward ( Respect\Rest\Routes\AbstractRoute $route ) : Response Forwards a route
response ( ) : string Generates and returns the response from the current route
routineCall ( string $type, string $method, Respect\Rest\Routines\Routinable $routine, array &$params ) : mixed Calls a routine on the current route and returns its result

Méthodes protégées

Méthode Description
catchExceptions ( Exception $e ) : mixed Does a catch-like operation on an exception based on previously declared instances from Router::exceptionRoute
extractRouteParam ( ReflectionFunctionAbstract $callback, ReflectionParameter $routeParam, array &$params ) : mixed Extracts a parameter value from the current route
forwardErrors ( mixed $errorHandler ) : mixed Restores the previous error handler if present then check error routes for logged errors, forwarding them or returning null silently
prepareForErrorForwards ( ) : mixed Declares an error handler for a single Router::errorRoute instance on the fly before dispatching the request, so the application can capture the errors. These are cleaned after dispatching by forwardErrors()
processPosRoutines ( $response ) : mixed Iterates over routines to find instances of Respect\Rest\Routines\ProxyableThrough and call them, forwarding if necessary
processPreRoutines ( ) : mixed Iterates over routines to find instances of Respect\Rest\Routines\ProxyableBy and call them, forwarding if necessary

Method Details

__construct() public méthode

public __construct ( string $method = null, string $uri = null )
$method string The HTTP method
$uri string The called URI

__toString() public méthode

Converting this request to string dispatch
public __toString ( )

catchExceptions() protected méthode

Does a catch-like operation on an exception based on previously declared instances from Router::exceptionRoute
protected catchExceptions ( Exception $e ) : mixed
$e Exception Any exception
Résultat mixed A route forwarding or a silent null

extractRouteParam() protected méthode

Extracts a parameter value from the current route
protected extractRouteParam ( ReflectionFunctionAbstract $callback, ReflectionParameter $routeParam, array &$params ) : mixed
$callback ReflectionFunctionAbstract Any function reflection
$routeParam ReflectionParameter Any parameter reflection
$params array Request URI params
Résultat mixed a value from the reflected param

forward() public méthode

Forwards a route
public forward ( Respect\Rest\Routes\AbstractRoute $route ) : Response
$route Respect\Rest\Routes\AbstractRoute Any route
Résultat Response from the forwarded route

forwardErrors() protected méthode

Restores the previous error handler if present then check error routes for logged errors, forwarding them or returning null silently
protected forwardErrors ( mixed $errorHandler ) : mixed
$errorHandler mixed Some error handler (internal or external to Respect)
Résultat mixed A route forwarding or a silent null

prepareForErrorForwards() protected méthode

Declares an error handler for a single Router::errorRoute instance on the fly before dispatching the request, so the application can capture the errors. These are cleaned after dispatching by forwardErrors()
See also: Respect\Rest\Request::forwardErrors
See also: http://php.net/set_error_handler
protected prepareForErrorForwards ( ) : mixed
Résultat mixed The previous error handler

processPosRoutines() protected méthode

Iterates over routines to find instances of Respect\Rest\Routines\ProxyableThrough and call them, forwarding if necessary
See also: Respect\Rest\Routines\ProxyableThrough
See also: Respect\Rest\Request::routineCall
protected processPosRoutines ( $response ) : mixed
Résultat mixed A route forwarding or false

processPreRoutines() protected méthode

Iterates over routines to find instances of Respect\Rest\Routines\ProxyableBy and call them, forwarding if necessary
See also: Respect\Rest\Routines\ProxyableBy
See also: Respect\Rest\Request::routineCall
protected processPreRoutines ( ) : mixed
Résultat mixed A route forwarding or false

response() public méthode

Generates and returns the response from the current route
public response ( ) : string
Résultat string A response!

routineCall() public méthode

Calls a routine on the current route and returns its result
public routineCall ( string $type, string $method, Respect\Rest\Routines\Routinable $routine, array &$params ) : mixed
$type string The name of the routine (accept, when, etc)
$method string The method name (GET, HEAD, POST, etc)
$routine Respect\Rest\Routines\Routinable Some routine instance
$params array Params from the routine
Résultat mixed Whatever the routine returns

Property Details

$method public_oe property

The HTTP method (commonly GET, POST, PUT, DELETE, HEAD)
public $method

$params public_oe property

A numeric array containing valid URL parameters. For a route path like /users/*, a Request for /users/alganet should have an array equivalent to ['alganet']
public $params

$route public_oe property

A route matched for this request
public $route

$uri public_oe property

The called URI
public $uri