src/Sulu/Bundle/WebsiteBundle/Controller/WebsiteController.php
protected function renderStructure(
        StructureInterface $structure,
        $attributes = [],
        $preview = false,
        $partial = false
    ) {
        // extract format twig file
        if (!$preview) {
            $request = $this->getRequest();
            $requestFormat = $request->getRequestFormat();
        } else {
            $requestFormat = 'html';
        }

        $viewTemplate = $structure->getView() . '.' . $requestFormat . '.twig';

        try {
            // get attributes to render template
            $data = $this->getAttributes($attributes, $structure, $preview);

            // if partial render only content block else full page
            if ($partial) {
                $content = $this->renderBlock(
                    $viewTemplate,
                    'content',
                    $data
                );
            } elseif ($preview) {
                $content = $this->renderPreview(
                    $viewTemplate,
                    $data
                );
            } else {
                $content = $this->renderView(
                    $viewTemplate,
                    $data
                );
            }

            $response = new Response($content);

            if (!$preview && $this->getCacheTimeLifeEnhancer()) {
                $this->getCacheTimeLifeEnhancer()->enhance($response, $structure);
            }

            return $response;
        } catch (InvalidArgumentException $e) {
            // template not found
            throw new HttpException(406, 'Error encountered when rendering content', $e);
        }
    }
protected function renderStructure(
        StructureInterface $structure,
        $attributes = [],
        $preview = false,
        $partial = false
    ) {
        // extract format twig file
        if (!$preview) {
            $request = $this->getRequest();
            $requestFormat = $request->getRequestFormat();
        } else {
            $requestFormat = 'html';
        }

        $viewTemplate = $structure->getView() . '.' . $requestFormat . '.twig';

        try {
            // get attributes to render template
            $data = $this->getAttributes($attributes, $structure, $preview);

            // if partial render only content block else full page
            if ($partial) {
                $content = $this->renderBlock(
                    $viewTemplate,
                    'content',
                    $data
                );
            } elseif ($preview) {
                $content = $this->renderPreview(
                    $viewTemplate,
                    $data
                );
            } else {
                $content = $this->renderView(
                    $viewTemplate,
                    $data
                );
            }

            $response = new Response($content);

            if (!$preview && $this->getCacheTimeLifeEnhancer()) {
                $this->getCacheTimeLifeEnhancer()->enhance($response, $structure);
            }

            return $response;
        } catch (InvalidArgumentException $e) {
            // template not found
            throw new HttpException(406, 'Error encountered when rendering content', $e);
        }
    }
protected function renderStructure ( StructureInterface $ structure , $ attributes = [ ] , $ preview = false , $ partial = false ) { // extract format twig file if ( ! $ preview ) { $ request = $ this -> getRequest ( ) ; $ requestFormat = $ request -> getRequestFormat ( ) ; } else { $ requestFormat = 'html' ; } $ viewTemplate = $ structure -> getView ( ) . '.' . $ requestFormat . '.twig' ; try { // get attributes to render template $ data = $ this -> getAttributes ( $ attributes , $ structure , $ preview ) ; // if partial render only content block else full page if ( $ partial ) { $ content = $ this -> renderBlock ( $ viewTemplate , 'content' , $ data ) ; } elseif ( $ preview ) { $ content = $ this -> renderPreview ( $ viewTemplate , $ data ) ; } else { $ content = $ this -> renderView ( $ viewTemplate , $ data ) ; } $ response = new Response ( $ content ) ; if ( ! $ preview && $ this -> getCacheTimeLifeEnhancer ( ) ) { $ this -> getCacheTimeLifeEnhancer ( ) -> enhance ( $ response , $ structure ) ; } return $ response ; } catch ( InvalidArgumentException $ e ) { // template not found throw new HttpException ( 406 , 'Error encountered when rendering content' , $ e ) ; } }
Returns a rendered structure.

@param StructureInterface $structure The structure, which has been loaded for rendering
@param array $attributes Additional attributes, which will be passed to twig
@param bool $preview Defines if the site is rendered in preview mode
@param bool $partial Defines if only the content block of the template should be rendered

@return Response
Returns a rendered structure .