PHP Class Zend\Stratigility\Dispatch

This class is an implementation detail of Next.
Deprecation: since 1.3.0; to be removed in 2.0.0.
ファイルを表示 Open project: zendframework/zend-stratigility Class Usage Examples

Public Methods

Method Description
__invoke ( Route $route, mixed $err, Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Message\ResponseInterface $response, callable $next ) : Psr\Http\Message\ResponseInterface Dispatch middleware
process ( Route $route, Psr\Http\Message\RequestInterface $request, callable $next ) : Psr\Http\Message\ResponseInterface Process middleware as invoked from an http-interop middleware instance.
raiseThrowables ( ) : void Enables the "raise throwables", causing this instance to raise throwables instead of catch them.
setResponsePrototype ( Psr\Http\Message\ResponseInterface $responsePrototype ) : void Set a response prototype to use when invoking callable middleware following http-interop middleware.

Private Methods

Method Description
dispatchCallableMiddleware ( callable $middleware, callable $next, Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Message\ResponseInterface $response, mixed $err = null ) : Psr\Http\Message\ResponseInterface Dispatch non-interop middleware.
dispatchInteropMiddleware ( Interop\Http\Middleware\ServerMiddlewareInterface $middleware, callable $next, Psr\Http\Message\RequestInterface $request ) : Psr\Http\Message\ResponseInterface Dispatch http-interop middleware
handleThrowableFromInteropMiddleware ( Throwabl\Throwable | Exception $throwable, Psr\Http\Message\RequestInterface $request, callable $next ) : Psr\Http\Message\ResponseInterface
isNotInteropMiddleware ( mixed $handler, Psr\Http\Message\RequestInterface $request ) : boolean Test if the middleware composed by a route is not http-interop middleware.

Method Details

__invoke() public method

Given a route (which contains the handler for given middleware), the $err value passed to $next, $next, and the request and response objects, dispatch a middleware handler. If $err is non-falsy, and the current handler has an arity of 4, it will be dispatched. If $err is falsy, and the current handler has an arity of < 4, it will be dispatched. In all other cases, the handler will be ignored, and $next will be invoked with the current $err value. If an exception is raised when executing the handler, the exception will be assigned as the value of $err, and $next will be invoked with it.
public __invoke ( Route $route, mixed $err, Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Message\ResponseInterface $response, callable $next ) : Psr\Http\Message\ResponseInterface
$route Route
$err mixed
$request Psr\Http\Message\ServerRequestInterface
$response Psr\Http\Message\ResponseInterface
$next callable
return Psr\Http\Message\ResponseInterface

process() public method

Name chosen to mirror Interop\Http\Middleware\DelegateInterface, and thus imply this should be dispatched from interop middleware. If the route provided is not http-interop middleware, this method will dispatch using callable middleware semantics; otherwise, it dispatches using http-interop semantics.
public process ( Route $route, Psr\Http\Message\RequestInterface $request, callable $next ) : Psr\Http\Message\ResponseInterface
$route Route
$request Psr\Http\Message\RequestInterface
$next callable
return Psr\Http\Message\ResponseInterface

raiseThrowables() public method

Enables the "raise throwables", causing this instance to raise throwables instead of catch them.
public raiseThrowables ( ) : void
return void

setResponsePrototype() public method

Set a response prototype to use when invoking callable middleware following http-interop middleware.
public setResponsePrototype ( Psr\Http\Message\ResponseInterface $responsePrototype ) : void
$responsePrototype Psr\Http\Message\ResponseInterface
return void