/var/www/vhosts/ihelp.ro/_OLD/vendor/cakephp/cakephp/src/Routing/Middleware
NameSizeModeActions
AssetMiddleware.php55150644editdlrm
RoutingMiddleware.php60700644editdlrm
Edit: /var/www/vhosts/ihelp.ro/_OLD/vendor/cakephp/cakephp/src/Routing/Middleware/RoutingMiddleware.php (6070B)
app = $app; $this->cacheConfig = $cacheConfig; } /** * 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. * * @return void */ protected function loadRoutes(): void { $routeCollection = $this->buildRouteCollection(); Router::setRouteCollection($routeCollection); } /** * Check if route cache is enabled and use the configured Cache to 'remember' the route collection * * @return \Cake\Routing\RouteCollection */ protected function buildRouteCollection(): RouteCollection { if (Cache::enabled() && $this->cacheConfig !== null) { return Cache::remember(static::ROUTE_COLLECTION_CACHE_KEY, function () { return $this->prepareRouteCollection(); }, $this->cacheConfig); } return $this->prepareRouteCollection(); } /** * Generate the route collection using the builder * * @return \Cake\Routing\RouteCollection */ protected function prepareRouteCollection(): RouteCollection { $builder = Router::createRouteBuilder('/'); $this->app->routes($builder); if ($this->app instanceof PluginApplicationInterface) { $this->app->pluginRoutes($builder); } return Router::getRouteCollection(); } /** * 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. * * @param \Psr\Http\Message\ServerRequestInterface $request The request. * @param \Psr\Http\Server\RequestHandlerInterface $handler The request handler. * @return \Psr\Http\Message\ResponseInterface A response. */ public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { $this->loadRoutes(); try { Router::setRequest($request); $params = (array)$request->getAttribute('params', []); $middleware = []; if (empty($params['controller'])) { $parsedBody = $request->getParsedBody(); if (is_array($parsedBody) && isset($parsedBody['_method'])) { /** @var \Cake\Http\ServerRequest $request */ $request = $request->withMethod($parsedBody['_method']); } $params = Router::parseRequest($request) + $params; if (isset($params['_middleware'])) { $middleware = $params['_middleware']; unset($params['_middleware']); } /** @var \Cake\Http\ServerRequest $request */ $request = $request->withAttribute('params', $params); Router::setRequest($request); } } catch (RedirectException $e) { return new RedirectResponse( $e->getMessage(), (int)$e->getCode() ); } catch (DeprecatedRedirectException $e) { return new RedirectResponse( $e->getMessage(), (int)$e->getCode() ); } $matching = Router::getRouteCollection()->getMiddleware($middleware); if (!$matching) { return $handler->handle($request); } $middleware = new MiddlewareQueue($matching); $runner = new Runner(); return $runner->run($middleware, $request, $handler); } }