public function handle(Request $request): Response
    {
        try {
            $matcher = $this->getUrlMatcher($request);

            $parameters = $matcher->match($request->getPathInfo());

            if (empty($parameters['_controller'])) {
                throw new InvalidRouteException('Route requires a _controller callable');
            }

            if (!\is_callable($parameters['_controller'])) {
                throw new InvalidRouteException('_controller must be a callable');
            }

            $callback = $parameters['_controller'];

            $result = call_user_func_array($callback, $this->getControllerParameters($request, $parameters));

            if (!$result instanceof Response) {
                throw new InvalidResponseException('Response must be an instance of \Symfony\Component\HttpFoundation\Response');
            }
        } catch (\Exception $e) {
            $result = $this->handleException($request, $e);
        }

        return $result;
    }
public function handle(Request $request): Response
    {
        try {
            $matcher = $this->getUrlMatcher($request);

            $parameters = $matcher->match($request->getPathInfo());

            if (empty($parameters['_controller'])) {
                throw new InvalidRouteException('Route requires a _controller callable');
            }

            if (!\is_callable($parameters['_controller'])) {
                throw new InvalidRouteException('_controller must be a callable');
            }

            $callback = $parameters['_controller'];

            $result = call_user_func_array($callback, $this->getControllerParameters($request, $parameters));

            if (!$result instanceof Response) {
                throw new InvalidResponseException('Response must be an instance of \Symfony\Component\HttpFoundation\Response');
            }
        } catch (\Exception $e) {
            $result = $this->handleException($request, $e);
        }

        return $result;
    }
public function handle ( Request $ request ) : Response { try { $ matcher = $ this -> getUrlMatcher ( $ request ) ; $ parameters = $ matcher -> match ( $ request -> getPathInfo ( ) ) ; if ( empty ( $ parameters [ '_controller' ] ) ) { throw new InvalidRouteException ( 'Route requires a _controller callable' ) ; } if ( ! \ is_callable ( $ parameters [ '_controller' ] ) ) { throw new InvalidRouteException ( '_controller must be a callable' ) ; } $ callback = $ parameters [ '_controller' ] ; $ result = call_user_func_array ( $ callback , $ this -> getControllerParameters ( $ request , $ parameters ) ) ; if ( ! $ result instanceof Response ) { throw new InvalidResponseException ( 'Response must be an instance of \Symfony\Component\HttpFoundation\Response' ) ; } } catch ( \ Exception $ e ) { $ result = $ this -> handleException ( $ request , $ e ) ; } return $ result ; }
Handles HTTP request and returns response.

@param Request $request
@return Response
Handles HTTP request and returns response .