| 
                     * @return \Cake\Http\Exception\MissingControllerException | 
            
                    
                 | 
                     */ | 
            
                    
                 | 
                    protected function missingController(ServerRequest $request) | 
            
                    
                 | 
                    { | 
            
                    
                 | 
                        return new MissingControllerException([ | 
            
                    
                 | 
                            'class' => $request->getParam('controller'), | 
            
                    
                 | 
                            'plugin' => $request->getParam('plugin'), | 
            
                    
                 | 
                            'prefix' => $request->getParam('prefix'), | 
            
                    
                 | 
                            '_ext' => $request->getParam('_ext'), | 
            
                
        
            
Arguments
                    
     
    
        
        
                            
                 | 
                            strpos($controller, '/') !== false || | 
            
                    
                 | 
                            strpos($controller, '.') !== false || | 
            
                    
                 | 
                            $firstChar === strtolower($firstChar) | 
            
                    
                 | 
                        ) { | 
            
                    
                 | 
                            throw $this->missingController($request); | 
            
                    
                 | 
                        } | 
            
                    
                 | 
                 | 
            
                    
                 | 
                        /** @var class-string<\Cake\Controller\Controller>|null */ | 
            
                    
                 | 
                        return App::className($pluginPath . $controller, $namespace, 'Controller'); | 
            
                
        
     
    
        
        
                            
                 | 
                     * @throws \Cake\Http\Exception\MissingControllerException | 
            
                    
                 | 
                     */ | 
            
                    
                 | 
                    public function create(ServerRequestInterface $request): Controller | 
            
                    
                 | 
                    { | 
            
                    
                 | 
                        $className = $this->getControllerClass($request); | 
            
                    
                 | 
                        if ($className === null) { | 
            
                    
                 | 
                            throw $this->missingController($request); | 
            
                    
                 | 
                        } | 
            
                    
                 | 
                 | 
            
                
        
     
    
        
        
                            
                 | 
                        if (Router::getRequest() !== $request) { | 
            
                    
                 | 
                            Router::setRequest($request); | 
            
                    
                 | 
                        } | 
            
                    
                 | 
                 | 
            
                    
                 | 
                        $controller = $this->controllerFactory->create($request); | 
            
                    
                 | 
                 | 
            
                    
                 | 
                        return $this->controllerFactory->invoke($controller); | 
            
                    
                 | 
                    } | 
            
                    
                 | 
                } | 
            
                
        
     
    
        
        
                            
                 | 
                            return $middleware->process($request, $this); | 
            
                    
                 | 
                        } | 
            
                    
                 | 
                 | 
            
                    
                 | 
                        if ($this->fallbackHandler) { | 
            
                    
                 | 
                            return $this->fallbackHandler->handle($request); | 
            
                    
                 | 
                        } | 
            
                    
                 | 
                 | 
            
                    
                 | 
                        return new Response([ | 
            
                    
                 | 
                            'body' => 'Middleware queue was exhausted without returning a response ' | 
            
                
        
     
    
        
        
                            
                 | 
                        $request = $request->withAttribute('authentication', $service); | 
            
                    
                 | 
                        $request = $request->withAttribute('authenticationResult', $result); | 
            
                    
                 | 
                 | 
            
                    
                 | 
                        try { | 
            
                    
                 | 
                            $response = $handler->handle($request); | 
            
                    
                 | 
                            $authenticator = $service->getAuthenticationProvider(); | 
            
                    
                 | 
                 | 
            
                    
                 | 
                            if ($authenticator !== null && !$authenticator instanceof StatelessInterface) { | 
            
                    
                 | 
                                $return = $service->persistIdentity($request, $response, $result->getData()); | 
            
                
        
     
    
        
        
                            
                 | 
                        if ($this->queue->valid()) { | 
            
                    
                 | 
                            $middleware = $this->queue->current(); | 
            
                    
                 | 
                            $this->queue->next(); | 
            
                    
                 | 
                 | 
            
                    
                 | 
                            return $middleware->process($request, $this); | 
            
                    
                 | 
                        } | 
            
                    
                 | 
                 | 
            
                    
                 | 
                        if ($this->fallbackHandler) { | 
            
                    
                 | 
                            return $this->fallbackHandler->handle($request); | 
            
                
        
     
    
        
        
                            
                 | 
                            ); | 
            
                    
                 | 
                        } | 
            
                    
                 | 
                        $matching = Router::getRouteCollection()->getMiddleware($middleware); | 
            
                    
                 | 
                        if (!$matching) { | 
            
                    
                 | 
                            return $handler->handle($request); | 
            
                    
                 | 
                        } | 
            
                    
                 | 
                 | 
            
                    
                 | 
                        $middleware = new MiddlewareQueue($matching); | 
            
                    
                 | 
                        $runner = new Runner(); | 
            
                
        
     
    
        
        
                            
                 | 
                        if ($this->queue->valid()) { | 
            
                    
                 | 
                            $middleware = $this->queue->current(); | 
            
                    
                 | 
                            $this->queue->next(); | 
            
                    
                 | 
                 | 
            
                    
                 | 
                            return $middleware->process($request, $this); | 
            
                    
                 | 
                        } | 
            
                    
                 | 
                 | 
            
                    
                 | 
                        if ($this->fallbackHandler) { | 
            
                    
                 | 
                            return $this->fallbackHandler->handle($request); | 
            
                
        
     
    
        
        
                            
                 | 
                        if ($method === 'GET' && $cookieData === null) { | 
            
                    
                 | 
                            $token = $this->createToken(); | 
            
                    
                 | 
                            $request = $request->withAttribute('csrfToken', $this->saltToken($token)); | 
            
                    
                 | 
                            /** @var mixed $response */ | 
            
                    
                 | 
                            $response = $handler->handle($request); | 
            
                    
                 | 
                 | 
            
                    
                 | 
                            return $this->_addTokenCookie($token, $request, $response); | 
            
                    
                 | 
                        } | 
            
                    
                 | 
                 | 
            
                
        
     
    
        
        
                            
                 | 
                        if ($this->queue->valid()) { | 
            
                    
                 | 
                            $middleware = $this->queue->current(); | 
            
                    
                 | 
                            $this->queue->next(); | 
            
                    
                 | 
                 | 
            
                    
                 | 
                            return $middleware->process($request, $this); | 
            
                    
                 | 
                        } | 
            
                    
                 | 
                 | 
            
                    
                 | 
                        if ($this->fallbackHandler) { | 
            
                    
                 | 
                            return $this->fallbackHandler->handle($request); | 
            
                
        
     
    
        
        
                            
                 | 
                     */ | 
            
                    
                 | 
                    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface | 
            
                    
                 | 
                    { | 
            
                    
                 | 
                        if (!in_array($request->getMethod(), $this->methods, true)) { | 
            
                    
                 | 
                            return $handler->handle($request); | 
            
                    
                 | 
                        } | 
            
                    
                 | 
                        [$type] = explode(';', $request->getHeaderLine('Content-Type')); | 
            
                    
                 | 
                        $type = strtolower($type); | 
            
                    
                 | 
                        if (!isset($this->parsers[$type])) { | 
            
                
        
     
    
        
        
                            
                 | 
                        if ($this->queue->valid()) { | 
            
                    
                 | 
                            $middleware = $this->queue->current(); | 
            
                    
                 | 
                            $this->queue->next(); | 
            
                    
                 | 
                 | 
            
                    
                 | 
                            return $middleware->process($request, $this); | 
            
                    
                 | 
                        } | 
            
                    
                 | 
                 | 
            
                    
                 | 
                        if ($this->fallbackHandler) { | 
            
                    
                 | 
                            return $this->fallbackHandler->handle($request); | 
            
                
        
     
    
        
        
                            
                 | 
                            ); | 
            
                    
                 | 
                        } | 
            
                    
                 | 
                        $matching = Router::getRouteCollection()->getMiddleware($middleware); | 
            
                    
                 | 
                        if (!$matching) { | 
            
                    
                 | 
                            return $handler->handle($request); | 
            
                    
                 | 
                        } | 
            
                    
                 | 
                 | 
            
                    
                 | 
                        $middleware = new MiddlewareQueue($matching); | 
            
                    
                 | 
                        $runner = new Runner(); | 
            
                
        
     
    
        
        
                            
                 | 
                        if ($this->queue->valid()) { | 
            
                    
                 | 
                            $middleware = $this->queue->current(); | 
            
                    
                 | 
                            $this->queue->next(); | 
            
                    
                 | 
                 | 
            
                    
                 | 
                            return $middleware->process($request, $this); | 
            
                    
                 | 
                        } | 
            
                    
                 | 
                 | 
            
                    
                 | 
                        if ($this->fallbackHandler) { | 
            
                    
                 | 
                            return $this->fallbackHandler->handle($request); | 
            
                
        
     
    
        
        
                            
                 | 
                        } | 
            
                    
                 | 
                 | 
            
                    
                 | 
                        $assetFile = $this->_getAssetFile($url); | 
            
                    
                 | 
                        if ($assetFile === null || !is_file($assetFile)) { | 
            
                    
                 | 
                            return $handler->handle($request); | 
            
                    
                 | 
                        } | 
            
                    
                 | 
                 | 
            
                    
                 | 
                        $file = new SplFileInfo($assetFile); | 
            
                    
                 | 
                        $modifiedTime = $file->getMTime(); | 
            
                
        
     
    
        
        
                            
                 | 
                        if ($this->queue->valid()) { | 
            
                    
                 | 
                            $middleware = $this->queue->current(); | 
            
                    
                 | 
                            $this->queue->next(); | 
            
                    
                 | 
                 | 
            
                    
                 | 
                            return $middleware->process($request, $this); | 
            
                    
                 | 
                        } | 
            
                    
                 | 
                 | 
            
                    
                 | 
                        if ($this->fallbackHandler) { | 
            
                    
                 | 
                            return $this->fallbackHandler->handle($request); | 
            
                
        
     
    
        
        
                            
                 | 
                     */ | 
            
                    
                 | 
                    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface | 
            
                    
                 | 
                    { | 
            
                    
                 | 
                        try { | 
            
                    
                 | 
                            return $handler->handle($request); | 
            
                    
                 | 
                        } catch (RedirectException $exception) { | 
            
                    
                 | 
                            return $this->handleRedirect($exception); | 
            
                    
                 | 
                        } catch (Throwable $exception) { | 
            
                    
                 | 
                            return $this->handleException($exception, $request); | 
            
                
        
     
    
        
        
                            
                 | 
                        if ($this->queue->valid()) { | 
            
                    
                 | 
                            $middleware = $this->queue->current(); | 
            
                    
                 | 
                            $this->queue->next(); | 
            
                    
                 | 
                 | 
            
                    
                 | 
                            return $middleware->process($request, $this); | 
            
                    
                 | 
                        } | 
            
                    
                 | 
                 | 
            
                    
                 | 
                        if ($this->fallbackHandler) { | 
            
                    
                 | 
                            return $this->fallbackHandler->handle($request); | 
            
                
        
     
    
        
        
                            
                 | 
                        $this->queue = $queue; | 
            
                    
                 | 
                        $this->queue->rewind(); | 
            
                    
                 | 
                        $this->fallbackHandler = $fallbackHandler; | 
            
                    
                 | 
                 | 
            
                    
                 | 
                        return $this->handle($request); | 
            
                    
                 | 
                    } | 
            
                    
                 | 
                 | 
            
                    
                 | 
                    /** | 
            
                    
                 | 
                     * Handle incoming server request and return a response. | 
            
                
        
     
    
        
        
                            
                 | 
                        } | 
            
                    
                 | 
                 | 
            
                    
                 | 
                        $this->dispatchEvent('Server.buildMiddleware', ['middleware' => $middleware]); | 
            
                    
                 | 
                 | 
            
                    
                 | 
                        $response = $this->runner->run($middleware, $request, $this->app); | 
            
                    
                 | 
                 | 
            
                    
                 | 
                        if ($request instanceof ServerRequest) { | 
            
                    
                 | 
                            $request->getSession()->close(); | 
            
                    
                 | 
                        } | 
            
                
        
     
    
        
        
                            
                 | 
                // Bind your application to the server. | 
            
                    
                 | 
                $server = new Server(new Application(dirname(__DIR__) . '/config')); | 
            
                    
                 | 
                 | 
            
                    
                 | 
                // Run the request/response through the application and emit the response. | 
            
                    
                 | 
                $server->emit($server->run()); | 
            
                    
                 | 
                 | 
            
                
        
     
            
                            
                        
                If you want to customize this error message, create
                templates/Error/error500.php