\Cake\Routing\MiddlewareRoutingMiddleware

Applies routing rules to the request and creates the controller instance if possible.

Summary

Methods
Properties
Constants
__construct()
__invoke()
No public properties found
ROUTE_COLLECTION_CACHE_KEY
loadRoutes()
buildRouteCollection()
prepareRouteCollection()
$app
$cacheConfig
N/A
No private methods found
No private properties found
N/A

Constants

ROUTE_COLLECTION_CACHE_KEY

ROUTE_COLLECTION_CACHE_KEY = 'routeCollection'

Key used to store the route collection in the cache engine

Properties

$cacheConfig

$cacheConfig : string|null

The cache configuration name to use for route collection caching, null to disable caching

Type

string|null

Methods

__construct()

__construct(\Cake\Core\HttpApplicationInterface|null  $app = null, string|null  $cacheConfig = null) 

Constructor

Parameters

\Cake\Core\HttpApplicationInterface|null $app

The application instance that routes are defined on.

string|null $cacheConfig

The cache config name to use or null to disable routes cache

__invoke()

__invoke(\Psr\Http\Message\ServerRequestInterface  $request, \Psr\Http\Message\ResponseInterface  $response, callable  $next) : \Psr\Http\Message\ResponseInterface

Apply routing and update the request.

Any route/path specific middleware will be wrapped around $next and then the new middleware stack will be invoked.

Parameters

\Psr\Http\Message\ServerRequestInterface $request

The request.

\Psr\Http\Message\ResponseInterface $response

The response.

callable $next

The next middleware to call.

Returns

\Psr\Http\Message\ResponseInterface

A response.

loadRoutes()

loadRoutes() : void

Trigger the application's routes() hook if the application exists and Router isn't initialized.

Uses the routes cache if enabled via configuration param "Router.cache"

If the middleware is created without an Application, routes will be loaded via the automatic route loading that pre-dates the routes() hook.

buildRouteCollection()

buildRouteCollection() : \Cake\Routing\RouteCollection

Check if route cache is enabled and use the configured Cache to 'remember' the route collection

Returns

\Cake\Routing\RouteCollection

prepareRouteCollection()

prepareRouteCollection() : \Cake\Routing\RouteCollection

Generate the route collection using the builder

Returns

\Cake\Routing\RouteCollection