當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。