Class RoutingMiddleware
Applies routing rules to the request and creates the controller instance if possible.
Constants
- 
          
          ROUTE_COLLECTION_CACHE_KEY ¶'routeCollection'Key used to store the route collection in the cache engine 
Property Summary
- 
        $app protectedCake\Http\BaseApplication|nullThe application that will have its routing hook invoked. 
- 
        $cacheConfig protectedstring|nullThe cache configuration name to use for route collection caching, null to disable caching 
Method Summary
- 
          __construct() publicConstructor 
- 
          __invoke() publicApply routing and update the request. 
- 
          buildRouteCollection() protectedCheck if route cache is enabled and use the configured Cache to 'remember' the route collection 
- 
          loadRoutes() protectedTrigger 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" 
- 
          prepareRouteCollection() protectedGenerate the route collection using the builder 
Method Detail
__construct() ¶ public
__construct(Cake\Http\BaseApplication|null $app = null, string|null $cacheConfig = null)Constructor
Parameters
- 
                Cake\Http\BaseApplication|null$app optional
- The application instance that routes are defined on. 
- 
                string|null$cacheConfig optional
- The cache config name to use or null to disable routes cache 
__invoke() ¶ public
__invoke(Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Message\ResponseInterface $response, callable $next): Psr\Http\Message\ResponseInterfaceApply 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\ResponseInterfaceA response.
buildRouteCollection() ¶ protected
buildRouteCollection(): Cake\Routing\RouteCollectionCheck if route cache is enabled and use the configured Cache to 'remember' the route collection
Returns
Cake\Routing\RouteCollectionloadRoutes() ¶ protected
loadRoutes(): voidTrigger 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.
Returns
voidprepareRouteCollection() ¶ protected
prepareRouteCollection(): Cake\Routing\RouteCollectionGenerate the route collection using the builder
Returns
Cake\Routing\RouteCollection