src/Routing/Router.php
public function route(Application $app, Request $request)
    {
        $url = $request->getPathInfo();
        $method = $request->getMethod();

        /** @var $route Route */
        foreach ($this->routes as $route) {

            // Match by method
            if ($route->getMethod() == $method) {

                // Match by URL
                $matches = $route->matches($url);
                if ($matches !== false) {

                    // Emit match event
                    $app['emitter']->emit(self::EVENT_MATCH, [$app, $request, $route]);

                    // Execute the route
                    return $route->run($app, $request, $matches);
                }
            }
        }

        // Emit no_match event
        $app['emitter']->emit(self::EVENT_NO_MATCH, [$app, $request]);

        // Return HTTP 404
        return new Response("Page not found", Response::HTTP_NOT_FOUND);
    }
public function route(Application $app, Request $request)
    {
        $url = $request->getPathInfo();
        $method = $request->getMethod();

        /** @var $route Route */
        foreach ($this->routes as $route) {

            // Match by method
            if ($route->getMethod() == $method) {

                // Match by URL
                $matches = $route->matches($url);
                if ($matches !== false) {

                    // Emit match event
                    $app['emitter']->emit(self::EVENT_MATCH, [$app, $request, $route]);

                    // Execute the route
                    return $route->run($app, $request, $matches);
                }
            }
        }

        // Emit no_match event
        $app['emitter']->emit(self::EVENT_NO_MATCH, [$app, $request]);

        // Return HTTP 404
        return new Response("Page not found", Response::HTTP_NOT_FOUND);
    }
public function route ( Application $ app , Request $ request ) { $ url = $ request -> getPathInfo ( ) ; $ method = $ request -> getMethod ( ) ; /** @var $route Route */ foreach ( $ this -> routes as $ route ) { // Match by method if ( $ route -> getMethod ( ) == $ method ) { // Match by URL $ matches = $ route -> matches ( $ url ) ; if ( $ matches !== false ) { // Emit match event $ app [ 'emitter' ] -> emit ( self :: EVENT_MATCH , [ $ app , $ request , $ route ] ) ; // Execute the route return $ route -> run ( $ app , $ request , $ matches ) ; } } } // Emit no_match event $ app [ 'emitter' ] -> emit ( self :: EVENT_NO_MATCH , [ $ app , $ request ] ) ; // Return HTTP 404 return new Response ( "Page not found" , Response :: HTTP_NOT_FOUND ) ; }
Routes the request, and returns a Response.

@param Application $app
@param Request $request
@return Response
Routes the request and returns a Response .