Component/HttpKernel/Kernel.php
public function handle(Request $request)
    {
        try {
            $this->loadConfiguration();

            // Now that Configuration is loaded let's resolve controller
            // for given request.
            $calls = $this->resolveController($request);
            $controller = $calls['controller'];
            $callable   = $calls['callable'];

            // Resolve arguments before calling controller
            $res = $controller->$callable();

            // Check if controller returned Response
            // and if so let's use it as our response
            if (is_a($res, 'Symfony\Component\HttpFoundation\Response')) {
                $this->response = $res;
            }

        } catch (\Exception $e) {
            $error = new \StdClass;
            $error->message = $e->getMessage();
            $error->code    = $e->getCode();
            $this->response->setStatusCode($e->getCode());
            $this->response->setContent(json_encode($error));
            $this->response->headers->set('Content-Type', 'application/json');
        }

        // Send response
        if ($request->getRequestFormat() == 'json') {
            $this->response->headers->set('Content-Type', 'application/json');
        }

        $this->response->send();

    }
public function handle(Request $request)
    {
        try {
            $this->loadConfiguration();

            // Now that Configuration is loaded let's resolve controller
            // for given request.
            $calls = $this->resolveController($request);
            $controller = $calls['controller'];
            $callable   = $calls['callable'];

            // Resolve arguments before calling controller
            $res = $controller->$callable();

            // Check if controller returned Response
            // and if so let's use it as our response
            if (is_a($res, 'Symfony\Component\HttpFoundation\Response')) {
                $this->response = $res;
            }

        } catch (\Exception $e) {
            $error = new \StdClass;
            $error->message = $e->getMessage();
            $error->code    = $e->getCode();
            $this->response->setStatusCode($e->getCode());
            $this->response->setContent(json_encode($error));
            $this->response->headers->set('Content-Type', 'application/json');
        }

        // Send response
        if ($request->getRequestFormat() == 'json') {
            $this->response->headers->set('Content-Type', 'application/json');
        }

        $this->response->send();

    }
public function handle ( Request $ request ) { try { $ this -> loadConfiguration ( ) ; // Now that Configuration is loaded let's resolve controller // for given request. $ calls = $ this -> resolveController ( $ request ) ; $ controller = $ calls [ 'controller' ] ; $ callable = $ calls [ 'callable' ] ; // Resolve arguments before calling controller $ res = $ controller -> $ callable ( ) ; // Check if controller returned Response // and if so let's use it as our response if ( is_a ( $ res , 'Symfony\Component\HttpFoundation\Response' ) ) { $ this -> response = $ res ; } } catch ( \ Exception $ e ) { $ error = new \ StdClass ; $ error -> message = $ e -> getMessage ( ) ; $ error -> code = $ e -> getCode ( ) ; $ this -> response -> setStatusCode ( $ e -> getCode ( ) ) ; $ this -> response -> setContent ( json_encode ( $ error ) ) ; $ this -> response -> headers -> set ( 'Content-Type' , 'application/json' ) ; } // Send response if ( $ request -> getRequestFormat ( ) == 'json' ) { $ this -> response -> headers -> set ( 'Content-Type' , 'application/json' ) ; } $ this -> response -> send ( ) ; }
Handles request.

@param   Request     $request
Handles request .