public function onKernelView(GetResponseForControllerResultEvent $event)
    {
        $parser = $this->container->get('thelia.parser');
        $templateHelper = $this->container->get('thelia.template_helper');
        $parser->setTemplateDefinition($templateHelper->getActiveFrontTemplate(), true);
        $request = $this->container->get('request_stack')->getCurrentRequest();
        $response = null;
        try {
            $view = $request->attributes->get('_view');

            $viewId = $request->attributes->get($view . '_id');

            $this->eventDispatcher->dispatch(TheliaEvents::VIEW_CHECK, new ViewCheckEvent($view, $viewId));

            $content = $parser->render($view . '.html');

            if ($content instanceof Response) {
                $response = $content;
            } else {
                $response = new Response($content, $parser->getStatus() ?: 200);
            }
        } catch (ResourceNotFoundException $e) {
            throw new NotFoundHttpException();
        } catch (OrderException $e) {
            switch ($e->getCode()) {
                case OrderException::CART_EMPTY:
                    // Redirect to the cart template
                    $response = RedirectResponse::create($this->container->get('router.chainRequest')->generate($e->cartRoute, $e->arguments, Router::ABSOLUTE_URL));
                    break;
                case OrderException::UNDEFINED_DELIVERY:
                    // Redirect to the delivery choice template
                    $response = RedirectResponse::create($this->container->get('router.chainRequest')->generate($e->orderDeliveryRoute, $e->arguments, Router::ABSOLUTE_URL));
                    break;
            }
            if (null === $response) {
                throw $e;
            }
        }

        $event->setResponse($response);
    }
public function onKernelView(GetResponseForControllerResultEvent $event)
    {
        $parser = $this->container->get('thelia.parser');
        $templateHelper = $this->container->get('thelia.template_helper');
        $parser->setTemplateDefinition($templateHelper->getActiveFrontTemplate(), true);
        $request = $this->container->get('request_stack')->getCurrentRequest();
        $response = null;
        try {
            $view = $request->attributes->get('_view');

            $viewId = $request->attributes->get($view . '_id');

            $this->eventDispatcher->dispatch(TheliaEvents::VIEW_CHECK, new ViewCheckEvent($view, $viewId));

            $content = $parser->render($view . '.html');

            if ($content instanceof Response) {
                $response = $content;
            } else {
                $response = new Response($content, $parser->getStatus() ?: 200);
            }
        } catch (ResourceNotFoundException $e) {
            throw new NotFoundHttpException();
        } catch (OrderException $e) {
            switch ($e->getCode()) {
                case OrderException::CART_EMPTY:
                    // Redirect to the cart template
                    $response = RedirectResponse::create($this->container->get('router.chainRequest')->generate($e->cartRoute, $e->arguments, Router::ABSOLUTE_URL));
                    break;
                case OrderException::UNDEFINED_DELIVERY:
                    // Redirect to the delivery choice template
                    $response = RedirectResponse::create($this->container->get('router.chainRequest')->generate($e->orderDeliveryRoute, $e->arguments, Router::ABSOLUTE_URL));
                    break;
            }
            if (null === $response) {
                throw $e;
            }
        }

        $event->setResponse($response);
    }
public function onKernelView ( GetResponseForControllerResultEvent $ event ) { $ parser = $ this -> container -> get ( 'thelia.parser' ) ; $ templateHelper = $ this -> container -> get ( 'thelia.template_helper' ) ; $ parser -> setTemplateDefinition ( $ templateHelper -> getActiveFrontTemplate ( ) , true ) ; $ request = $ this -> container -> get ( 'request_stack' ) -> getCurrentRequest ( ) ; $ response = null ; try { $ view = $ request -> attributes -> get ( '_view' ) ; $ viewId = $ request -> attributes -> get ( $ view . '_id' ) ; $ this -> eventDispatcher -> dispatch ( TheliaEvents :: VIEW_CHECK , new ViewCheckEvent ( $ view , $ viewId ) ) ; $ content = $ parser -> render ( $ view . '.html' ) ; if ( $ content instanceof Response ) { $ response = $ content ; } else { $ response = new Response ( $ content , $ parser -> getStatus ( ) ? : 200 ) ; } } catch ( ResourceNotFoundException $ e ) { throw new NotFoundHttpException ( ) ; } catch ( OrderException $ e ) { switch ( $ e -> getCode ( ) ) { case OrderException :: CART_EMPTY : // Redirect to the cart template $ response = RedirectResponse :: create ( $ this -> container -> get ( 'router.chainRequest' ) -> generate ( $ e -> cartRoute , $ e -> arguments , Router :: ABSOLUTE_URL ) ) ; break ; case OrderException :: UNDEFINED_DELIVERY : // Redirect to the delivery choice template $ response = RedirectResponse :: create ( $ this -> container -> get ( 'router.chainRequest' ) -> generate ( $ e -> orderDeliveryRoute , $ e -> arguments , Router :: ABSOLUTE_URL ) ) ; break ; } if ( null === $ response ) { throw $ e ; } } $ event -> setResponse ( $ response ) ; }
Launch the parser defined on the constructor and get the result.

The result is transform id needed into a Response object

@param \Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent $event
Launch the parser defined on the constructor and get the result .