当前位置: 首页>>代码示例>>PHP>>正文


PHP Controller::renderView方法代码示例

本文整理汇总了PHP中Symfony\Bundle\FrameworkBundle\Controller\Controller::renderView方法的典型用法代码示例。如果您正苦于以下问题:PHP Controller::renderView方法的具体用法?PHP Controller::renderView怎么用?PHP Controller::renderView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Bundle\FrameworkBundle\Controller\Controller的用法示例。


在下文中一共展示了Controller::renderView方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: renderStructure

 /**
  * 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);
     }
 }
开发者ID:sulu,项目名称:sulu,代码行数:35,代码来源:WebsiteController.php

示例2: renderView

 /**
  * 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);
 }
开发者ID:Silwereth,项目名称:core,代码行数:14,代码来源:AbstractController.php

示例3: renderView

 public function renderView($view, array $parameters = array())
 {
     return parent::renderView($view, $parameters);
 }
开发者ID:symfony,项目名称:symfony,代码行数:4,代码来源:ControllerTest.php

示例4: testRenderViewTemplating

 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'));
 }
开发者ID:neartux,项目名称:visitayucatan2.0,代码行数:11,代码来源:ControllerTest.php

示例5: renderView

 /**
  * {@inheritdoc}
  */
 public function renderView($view, array $parameters = [])
 {
     return parent::renderView($view, $this->getTemplateAttributes($parameters));
 }
开发者ID:alexander-schranz,项目名称:sulu-website-user-bundle,代码行数:7,代码来源:AbstractController.php


注:本文中的Symfony\Bundle\FrameworkBundle\Controller\Controller::renderView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。