public function parseRequest(ServerRequestInterface $request)
    {
        $uri = $request->getUri();
        $urlPath = urldecode($uri->getPath());

        // Sort path segments matching longest paths first.
        $paths = array_keys($this->_paths);
        rsort($paths);

        foreach ($paths as $path) {
            if (strpos($urlPath, $path) !== 0) {
                continue;
            }

            /* @var \Cake\Routing\Route\Route $route */
            foreach ($this->_paths[$path] as $route) {
                $r = $route->parseRequest($request);
                if ($r === false) {
                    continue;
                }
                if ($uri->getQuery()) {
                    parse_str($uri->getQuery(), $queryParameters);
                    $r['?'] = $queryParameters;
                }

                return $r;
            }
        }
        throw new MissingRouteException(['url' => $urlPath]);
    }
public function parseRequest(ServerRequestInterface $request)
    {
        $uri = $request->getUri();
        $urlPath = urldecode($uri->getPath());

        // Sort path segments matching longest paths first.
        $paths = array_keys($this->_paths);
        rsort($paths);

        foreach ($paths as $path) {
            if (strpos($urlPath, $path) !== 0) {
                continue;
            }

            /* @var \Cake\Routing\Route\Route $route */
            foreach ($this->_paths[$path] as $route) {
                $r = $route->parseRequest($request);
                if ($r === false) {
                    continue;
                }
                if ($uri->getQuery()) {
                    parse_str($uri->getQuery(), $queryParameters);
                    $r['?'] = $queryParameters;
                }

                return $r;
            }
        }
        throw new MissingRouteException(['url' => $urlPath]);
    }
public function parseRequest ( ServerRequestInterface $ request ) { $ uri = $ request -> getUri ( ) ; $ urlPath = urldecode ( $ uri -> getPath ( ) ) ; // Sort path segments matching longest paths first. $ paths = array_keys ( $ this -> _paths ) ; rsort ( $ paths ) ; foreach ( $ paths as $ path ) { if ( strpos ( $ urlPath , $ path ) !== 0 ) { continue ; } /* @var \Cake\Routing\Route\Route $route */ foreach ( $ this -> _paths [ $ path ] as $ route ) { $ r = $ route -> parseRequest ( $ request ) ; if ( $ r === false ) { continue ; } if ( $ uri -> getQuery ( ) ) { parse_str ( $ uri -> getQuery ( ) , $ queryParameters ) ; $ r [ '?' ] = $ queryParameters ; } return $ r ; } } throw new MissingRouteException ( [ 'url' => $ urlPath ] ) ; }
Takes the ServerRequestInterface, iterates the routes until one is able to parse the route.

@param \Psr\Http\Message\ServerRequestInterface $request The request to parse route data from.
@return array An array of request parameters parsed from the URL.
@throws \Cake\Routing\Exception\MissingRouteException When a URL has no matching route.
Takes the ServerRequestInterface iterates the routes until one is able to parse the route .