renderView() protected method

Returns a rendered view.
protected renderView ( string $view, array $parameters = [] ) : string
$view string The view name
$parameters array An array of parameters to pass to the view
return string The rendered view
Example #1
0
 /**
  * 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
  */
 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);
         } else {
             $content = parent::renderView($viewTemplate, $data);
         }
         return new Response($content);
     } catch (InvalidArgumentException $e) {
         // template not found
         throw new HttpException(406, 'Error encountered when rendering content', $e);
     }
 }
Example #2
0
 /**
  * Returns a rendered view.
  * 
  * @param string $view
  *            The view name
  * @param array $parameters
  *            An array of parameters to pass to the view
  * @return string The rendered view
  */
 public function renderView($view, array $parameters = array())
 {
     $parameters = $this->decorateTranslator($parameters);
     return parent::renderView($view, $parameters);
 }
Example #3
0
 public function renderView($view, array $parameters = array())
 {
     return parent::renderView($view, $parameters);
 }
 public function testRenderViewTemplating()
 {
     $templating = $this->getMock('Symfony\\Bundle\\FrameworkBundle\\Templating\\EngineInterface');
     $templating->expects($this->once())->method('render')->willReturn('bar');
     $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $container->expects($this->at(0))->method('has')->willReturn(true);
     $container->expects($this->at(1))->method('get')->will($this->returnValue($templating));
     $controller = new Controller();
     $controller->setContainer($container);
     $this->assertEquals('bar', $controller->renderView('foo'));
 }
 /**
  * {@inheritdoc}
  */
 public function renderView($view, array $parameters = [])
 {
     return parent::renderView($view, $this->getTemplateAttributes($parameters));
 }