PHP 클래스 Zend\Expressive\Application

상속: extends Zend\Stratigility\MiddlewarePipe, implements Zend\Expressive\Router\RouteResultSubjectInterface, use trait MarshalMiddlewareTrait
파일 보기 프로젝트 열기: zendframework/zend-expressive 1 사용 예제들

공개 메소드들

메소드 설명
__call ( string $method, array $args ) : Zend\Expressive\Router\Route
__construct ( Zend\Expressive\Router\RouterInterface $router, Interop\Container\ContainerInterface $container = null, callable $finalHandler = null, Zend\Diactoros\Response\EmitterInterface $emitter = null ) Constructor
__invoke ( Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Message\ResponseInterface $response, callable $out = null ) : Psr\Http\Message\ResponseInterface Overload middleware invocation.
any ( string | Zend\Expressive\Router\Route $path, callable | string $middleware, null | string $name = null ) : Zend\Expressive\Router\Route
attachRouteResultObserver ( Zend\Expressive\Router\RouteResultObserverInterface $observer ) Attach a route result observer.
detachRouteResultObserver ( Zend\Expressive\Router\RouteResultObserverInterface $observer ) Detach a route result observer.
dispatchMiddleware ( Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Message\ResponseInterface $response, callable $next ) Dispatch the middleware matched by routing.
getContainer ( ) : Interop\Container\ContainerInterface Retrieve the IoC container.
getEmitter ( ) : Zend\Diactoros\Response\EmitterInterface Retrieve an emitter to use during run().
getFinalHandler ( Psr\Http\Message\ResponseInterface $response = null ) : callable | null Return the final handler to use during run() if the stack is exhausted.
notifyRouteResultObservers ( Zend\Expressive\Router\RouteResult $result ) Notify all route result observers with the given route result.
pipe ( string | array | callable $path, null | string | array | callable $middleware = null ) : self Overload pipe() operation.
pipeDispatchMiddleware ( ) Register the dispatch middleware in the middleware pipeline.
pipeErrorHandler ( string | callable $path, null | string | callable $middleware = null ) : self Pipe an error handler.
pipeRouteResultObserverMiddleware ( ) Register the route result observer middleware in the middleware pipeline.
pipeRoutingMiddleware ( ) Register the routing middleware in the middleware pipeline.
route ( string | Zend\Expressive\Router\Route $path, callable | string | array $middleware = null, array $methods = null, null | string $name = null ) : Zend\Expressive\Router\Route Add a route for the route middleware to match.
routeMiddleware ( Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Message\ResponseInterface $response, callable $next ) : Psr\Http\Message\ResponseInterface Middleware that routes the incoming request and delegates to the matched middleware.
routeResultObserverMiddleware ( Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Message\ResponseInterface $response, callable $next ) Middleware for notifying route result observers.
run ( Psr\Http\Message\ServerRequestInterface $request = null, Psr\Http\Message\ResponseInterface $response = null ) Run the application

비공개 메소드들

메소드 설명
checkForDuplicateRoute ( string $path, null | array $methods = null ) Determine if the route is duplicated in the current list.

메소드 상세

__call() 공개 메소드

public __call ( string $method, array $args ) : Zend\Expressive\Router\Route
$method string
$args array
리턴 Zend\Expressive\Router\Route

__construct() 공개 메소드

Calls on the parent constructor, and then uses the provided arguments to set internal properties.
public __construct ( Zend\Expressive\Router\RouterInterface $router, Interop\Container\ContainerInterface $container = null, callable $finalHandler = null, Zend\Diactoros\Response\EmitterInterface $emitter = null )
$router Zend\Expressive\Router\RouterInterface
$container Interop\Container\ContainerInterface IoC container from which to pull services, if any.
$finalHandler callable Final handler to use when $out is not provided on invocation.
$emitter Zend\Diactoros\Response\EmitterInterface Emitter to use when `run()` is invoked.

__invoke() 공개 메소드

If $out is not provided, uses the result of getFinalHandler().
public __invoke ( Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Message\ResponseInterface $response, callable $out = null ) : Psr\Http\Message\ResponseInterface
$request Psr\Http\Message\ServerRequestInterface
$response Psr\Http\Message\ResponseInterface
$out callable
리턴 Psr\Http\Message\ResponseInterface

any() 공개 메소드

public any ( string | Zend\Expressive\Router\Route $path, callable | string $middleware, null | string $name = null ) : Zend\Expressive\Router\Route
$path string | Zend\Expressive\Router\Route
$middleware callable | string Middleware (or middleware service name) to associate with route.
$name null | string the name of the route
리턴 Zend\Expressive\Router\Route

attachRouteResultObserver() 공개 메소드

Attach a route result observer.
사용 중단: This method will be removed in v1.1.
public attachRouteResultObserver ( Zend\Expressive\Router\RouteResultObserverInterface $observer )
$observer Zend\Expressive\Router\RouteResultObserverInterface

detachRouteResultObserver() 공개 메소드

Detach a route result observer.
사용 중단: This method will be removed in v1.1.
public detachRouteResultObserver ( Zend\Expressive\Router\RouteResultObserverInterface $observer )
$observer Zend\Expressive\Router\RouteResultObserverInterface

dispatchMiddleware() 공개 메소드

If the request does not have the route result, calls on the next middleware. Next, it checks if the route result has matched middleware; if not, it raises an exception. Finally, it attempts to marshal the middleware, and dispatches it when complete, return the response.
public dispatchMiddleware ( Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Message\ResponseInterface $response, callable $next )
$request Psr\Http\Message\ServerRequestInterface
$response Psr\Http\Message\ResponseInterface
$next callable

getContainer() 공개 메소드

If no IoC container is registered, we raise an exception.
public getContainer ( ) : Interop\Container\ContainerInterface
리턴 Interop\Container\ContainerInterface

getEmitter() 공개 메소드

If none was registered during instantiation, this will lazy-load an EmitterStack composing an SapiEmitter instance.
public getEmitter ( ) : Zend\Diactoros\Response\EmitterInterface
리턴 Zend\Diactoros\Response\EmitterInterface

getFinalHandler() 공개 메소드

Return the final handler to use during run() if the stack is exhausted.
public getFinalHandler ( Psr\Http\Message\ResponseInterface $response = null ) : callable | null
$response Psr\Http\Message\ResponseInterface Response instance with which to seed the FinalHandler; used to determine if the response passed to the handler represents the original or final response state.
리턴 callable | null

notifyRouteResultObservers() 공개 메소드

Notify all route result observers with the given route result.
사용 중단: This method will be removed in v1.1.
public notifyRouteResultObservers ( Zend\Expressive\Router\RouteResult $result )
$result Zend\Expressive\Router\RouteResult

pipe() 공개 메소드

Middleware piped may be either callables or service names. Middleware specified as services will be wrapped in a closure similar to the following: function ($request, $response, $next = null) use ($container, $middleware) { $invokable = $container->get($middleware); if (! is_callable($invokable)) { throw new Exception\InvalidMiddlewareException(sprintf( 'Lazy-loaded middleware "%s" is not invokable', $middleware )); } return $invokable($request, $response, $next); }; This is done to delay fetching the middleware until it is actually used; the upshot is that you will not be notified if the service is invalid to use as middleware until runtime. Middleware may also be passed as an array; each item in the array must resolve to middleware eventually (i.e., callable or service name). Finally, ensures that the route middleware is only ever registered once.
public pipe ( string | array | callable $path, null | string | array | callable $middleware = null ) : self
$path string | array | callable Either a URI path prefix, or middleware.
$middleware null | string | array | callable Middleware
리턴 self

pipeDispatchMiddleware() 공개 메소드

Register the dispatch middleware in the middleware pipeline.

pipeErrorHandler() 공개 메소드

Middleware piped may be either callables or service names. Middleware specified as services will be wrapped in a closure similar to the following: function ($error, $request, $response, $next) use ($container, $middleware) { $invokable = $container->get($middleware); if (! is_callable($invokable)) { throw new Exception\InvalidMiddlewareException(sprintf( 'Lazy-loaded middleware "%s" is not invokable', $middleware )); } return $invokable($error, $request, $response, $next); }; This is done to delay fetching the middleware until it is actually used; the upshot is that you will not be notified if the service is invalid to use as middleware until runtime. Once middleware detection and wrapping (if necessary) is complete, proxies to pipe().
public pipeErrorHandler ( string | callable $path, null | string | callable $middleware = null ) : self
$path string | callable Either a URI path prefix, or middleware.
$middleware null | string | callable Middleware
리턴 self

pipeRouteResultObserverMiddleware() 공개 메소드

Register the route result observer middleware in the middleware pipeline.
사용 중단: This method will be removed in v1.1.

pipeRoutingMiddleware() 공개 메소드

Register the routing middleware in the middleware pipeline.

route() 공개 메소드

Accepts either a Router\Route instance, or a combination of a path and middleware, and optionally the HTTP methods allowed. On first invocation, pipes the route middleware to the middleware pipeline.
public route ( string | Zend\Expressive\Router\Route $path, callable | string | array $middleware = null, array $methods = null, null | string $name = null ) : Zend\Expressive\Router\Route
$path string | Zend\Expressive\Router\Route
$middleware callable | string | array Middleware (or middleware service name) to associate with route.
$methods array HTTP method to accept; null indicates any.
$name null | string the name of the route
리턴 Zend\Expressive\Router\Route

routeMiddleware() 공개 메소드

Uses the router to route the incoming request, injecting the request with: - the route result object (under a key named for the RouteResult class) - attributes for each matched routing parameter On completion, it calls on the next middleware (typically the dispatchMiddleware()). If routing fails, $next() is called; if routing fails due to HTTP method negotiation, the response is set to a 405, injected with an Allow header, and $next() is called with its $error argument set to the value 405 (invoking the next error middleware).
public routeMiddleware ( 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
리턴 Psr\Http\Message\ResponseInterface

routeResultObserverMiddleware() 공개 메소드

If the request has a route result, calls notifyRouteResultObservers(). This middleware should be injected between the routing and dispatch middleware when creating your middleware pipeline. If you are using this, rewrite your observers as middleware that pulls the route result from the request instead.
사용 중단: This method will be removed in v1.1.
public routeResultObserverMiddleware ( Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Message\ResponseInterface $response, callable $next )
$request Psr\Http\Message\ServerRequestInterface
$response Psr\Http\Message\ResponseInterface
$next callable

run() 공개 메소드

If no request or response are provided, the method will use ServerRequestFactory::fromGlobals to create a request instance, and instantiate a default response instance. It then will invoke itself with the request and response, and emit the returned response using the composed emitter.
public run ( Psr\Http\Message\ServerRequestInterface $request = null, Psr\Http\Message\ResponseInterface $response = null )
$request Psr\Http\Message\ServerRequestInterface
$response Psr\Http\Message\ResponseInterface