Generates a response from a page.

@param View        $view
@param string|null $layout

@return Response
438941
public function renderPage($view, $layout = null)
    {
        $event = new PageMenuContextualEvent($view);

        //Set currentView and dispatch victoire.on_render_page event with this currentView
        $pageRenderEvent = new PageRenderEvent($view);
        $this->eventDispatcher->dispatch('victoire.on_render_page', $pageRenderEvent);
        $this->currentViewHelper->setCurrentView($view);

        //Build WidgetMap
        $this->widgetMapBuilder->build($view, true);

        //Populate widgets with their data
        $this->widgetDataWarmer->warm($this->entityManager, $view);

        //Dispatch contextual event regarding page type
        if (in_array($view->getType(), ['business_page', 'virtual_business_page'])) {
            //Dispatch also an event with the Business entity name
            $eventName = 'victoire_core.page_menu.contextual';
            if (!$view->getId()) {
                $eventName = 'victoire_core.business_template_menu.contextual';
                $event = new PageMenuContextualEvent($view->getTemplate());
            }
            $this->eventDispatcher->dispatch($eventName, $event);
            $type = $view->getBusinessEntityId();
        } else {
            $type = $view->getType();
        }

        $eventName = 'victoire_core.'.$type.'_menu.contextual';
        $this->eventDispatcher->dispatch($eventName, $event);

        if (null === $layout) {
            //Determine which layout to use
            $layout = $this->guessBestLayoutForView($view);
        }
        $globalConfig = $this->entityManager->getRepository(GlobalConfig::class)->findLast() ?: new GlobalConfig();

        //Create the response
        $response = $this->container->get('templating')->renderResponse('VictoireCoreBundle:Layout:'.$layout.'.html.twig', [
            'globalConfig'                    => $globalConfig,
            'victoire_i18n_available_locales' => $this->availableLocales,
            'victoire_twig_responsive'        => $this->twigResponsive,
            'view'                            => $view,
        ]);

        return $response;
    }
813526
public function settingsAction(Request $request, View $view)
    {
        $pageSeo = $view->getSeo() ?: new PageSeo();
        $form = $this->createSettingsForm($pageSeo, $view);

        $form->handleRequest($request);

        $response = $this->getNotPersistedSettingsResponse(
            $form,
            $view,
            $request->query->get('novalidate', false)
        );

        return new JsonResponse($response);
    }
825003
private function createContentWithLayout($layout, $fragment)
    {
        // Create and append $fragment variable to the shared view stack
        $this->variables[self::TEMPLATE_PARAM_FRAGMENT_VAR_NAME] = $this->createFileContent($fragment);

        return $this->createFileContent($layout);
    }
1056184
private function generateView($view)
    {
        return $this->indenter
            ->indent(view('scaffold-interface::template.views.'.$this->parser->getTemplate().'.'.$view,
                ['parser' => $this->parser, 'dataSystem' => $this->dataSystem])->render());
    }
1204096
public function renderView($viewPath = null, $data = [], $layout = null)
    {
        $renderedView = $this->view->renderView($viewPath, $data, $layout);
        return $renderedView;
    }
1247508
public function handle($request, Closure $next, $theme = null, $layout = null)
    {
        if(isset($theme)) Theme::uses($theme);
        if(isset($layout)) Theme::layout($layout);

        return $next($request);
       
/*
        $response = $next($request);
        
        $originalContent = $response->getOriginalContent();

        if(!is_string($originalContent)) {
            $view_name = $originalContent->getName();
            
            $data = $originalContent->getData();
        } else {
            $view_name = $response->exception->getTrace()[0]['args'][0];
        }
        

        return $theme->scope($view_name, $data)->render();
*/
    }
7594
public function render($view = null)
    {
        if ($this->hasChild() && ! $this->hasClassProperty($class = config('navigation.class.has_child', 'treeview'))) {
            $this->setHtmlAttribute('class', $class);
        }

        $data = $this->toArray();

        if (! is_null($view)) {
            return view($view, $data)->render();
        }

        return app('sleeping_owl.template')->view('_partials.navigation.page', $data)->render();
    }
681522
public function render($view = null)
    {
        if (is_null($view) and ! isset($this->templatePaths[$this->defaultLanguage])) {
            return '';
        }
        $return   = (is_null($view)) ? view($this->templatePaths[$this->defaultLanguage], $this->predefinedVariables) : view($view, $this->predefinedVariables);
        $adapter  = app(VariablesAdapter::class);
        $rendered = $adapter->fill($return->__toString());
        preg_match_all('/\[\[(.*?)\]\]/', $rendered, $matches);
        if (isset($matches[0]) && isset($matches[1])) {
            foreach ($matches[0] as $index => $variable) {
                $rendered = str_replace($variable, '{{ ' . $matches[1][$index] . ' }}', $rendered);
            }
            $twig = new Twig_Environment(new Twig_Loader_String());
            return $twig->render($rendered, $this->predefinedVariables);
        }

        return $rendered;
    }
1020423
protected function render(string $view, array $parameters = [], Response $response = null): Response
    {
        if ($this->container->has('templating')) {
            @trigger_error('Using the "templating" service is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);

            $content = $this->container->get('templating')->render($view, $parameters);
        } elseif ($this->container->has('twig')) {
            $content = $this->container->get('twig')->render($view, $parameters);
        } else {
            throw new \LogicException('You can not use the "render" method if the Templating Component or the Twig Bundle are not available. Try running "composer require symfony/twig-bundle".');
        }

        if (null === $response) {
            $response = new Response();
        }

        $response->setContent($content);

        return $response;
    }
809472
private function render($view, array $parameters = [])
    {
        $response = new LegacyResponse();
        $response->setContent($this->templateEngine->render($view, $parameters));

        return $response;
    }
765381
protected function _getFormView($view = null)
    {
        if (empty($view) && Arr::in($this->request->getParam('action'), $this->_formActions)) {
            $view = $this->_findViewByRequest();
        }

        return $view;
    }
585206
protected function render($view)
    {
        $view = parent::render($view);
        if (!\Staq\Util::isStack($view, 'Stack\\View')) {
            $page = new \Stack\View;
            $page['content'] = $view;
            $view = $page;
        }
        return $view->render();
    }
2680
public function renderJsonAction($view, $layout): ServiceResponse
    {
        $layout = $this->getLayout($layout);
        if ($this->RequestHandler) {
            // Make sure the view is rendered as HTML, even if it is an AJAX request
            // jsonActionResponse() will make sure the JSON response is rendered correctly
            $this->RequestHandler->renderAs($this, 'ajax');
            $this->RequestHandler->ext = 'html';
        }
        $response = parent::render($view, $layout);

        return $this->jsonActionResponse($response);
    }
898520
public function render($view, array $parameters = array(), Response $response = null)
    {
        if (!isset($response)) {
            $response = new Response();
        }

        $response->setContent($this->getTemplateEngine()->render($view, $parameters));

        return $response;
    }
340409
public function renderResponse($view, $params = [])
    {
        /** @var \DevGroup\AdminUtils\controllers\BaseController $context */
        $context = $this instanceof Action ? $this->controller : $this;
        if (Yii::$app->request->isAjax === true) {
            Yii::$app->response->format = Response::FORMAT_JSON;

            $content = $context->renderAjax($view, $params);
            return new AjaxResponse($content, false, Yii::$app->session->getAllFlashes(true));
        } else {
            return $context->render($view, $params);
        }
    }
210014
public function displayAndHandle(Request $request, $locationId, $viewType, $layout = false, array $params = array())
    {
        $parameters = $this->collectInformation($request, $locationId);

        $params += $parameters;

        $response = $this->container
            ->get('ez_content')
            ->viewLocation(
                $locationId,
                $viewType,
                $layout,
                $params
            );

        $response->setPrivate();

        return $response;
    }
296898
protected function processView($action, View $view)
    {
        $this->getRestEventDispatcher()->dispatch(
            RestEvents::VIEW,
            $event = new ViewEvent($this->resource, $action, $view)
        );

        return $this->handleView($event->getView());
    }