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


PHP View::setTemplate方法代码示例

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


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

示例1: includeJSFilesAction

 /**
  * Render js inclusion for create.js and dependencies and bootstrap code.
  *
  * THe hallo editor is bundled with create.js and available automatically.
  * To use aloha, you need to download the zip, as explained in step 8 of
  * the README.
  *
  * @param string $editor the name of the editor to load, currently hallo and aloha are supported
  */
 public function includeJSFilesAction($editor = 'hallo')
 {
     if ($this->securityContext && false === $this->securityContext->isGranted($this->requiredRole)) {
         return new Response('');
     }
     // We could inject a list of names to template mapping for this
     // to allow adding other editors without changing this bundle
     $view = new View();
     switch ($editor) {
         case 'hallo':
             if ($this->coffee) {
                 $view->setTemplate('SymfonyCmfCreateBundle::includecoffeefiles-hallo.html.twig');
             } else {
                 $view->setTemplate('SymfonyCmfCreateBundle::includejsfiles-hallo.html.twig');
             }
             break;
         case 'aloha':
             $view->setTemplate('SymfonyCmfCreateBundle::includejsfiles-aloha.html.twig');
             break;
         default:
             throw new \InvalidArgumentException("Unknown editor '{$editor}' requested");
     }
     $view->setData(array('cmfCreateStanbolUrl' => $this->stanbolUrl, 'cmfCreateImageUploadEnabled' => (bool) $this->imageClass));
     return $this->viewHandler->handle($view);
 }
开发者ID:notsentient,项目名称:CreateBundle,代码行数:34,代码来源:JsloaderController.php

示例2: testSetTemplateTemplateFormat

 /**
  * @expectedException \InvalidArgumentException
  */
 public function testSetTemplateTemplateFormat()
 {
     $view = new View();
     $view->setTemplate('foo');
     $this->assertEquals('foo', $view->getTemplate());
     $view->setTemplate($template = new TemplateReference());
     $this->assertEquals($template, $view->getTemplate());
     $view->setTemplate(array());
 }
开发者ID:LamaDelRay,项目名称:test_symf,代码行数:12,代码来源:ViewTest.php

示例3: indexAction

 /**
  * @Route("/")
  */
 public function indexAction()
 {
     $view = new View();
     $view->setFormat('html');
     $view->setTemplate('TastdCoreBundle:Default:index.html.twig');
     return $view;
 }
开发者ID:oriodesign,项目名称:tastd-backend-demo,代码行数:10,代码来源:DefaultController.php

示例4: newUserAction

 /**
  * @ApiDoc(
  *  section="Admin/Users",
  *  description="Display the creation form of the user",
  *  input="AppBundle\Controller\Admin\Form\UserFormType",
  *  output="AppBundle\Controller\Admin\AdminUserController",
  * )
  */
 public function newUserAction()
 {
     $user = new User();
     $form = $this->getUserForm($user, 'post_user', 'POST');
     $view = new View($form);
     $view->setTemplate('AppBundle:User:add.html.twig');
     return $this->handleView($view);
 }
开发者ID:Hemric,项目名称:rentitapi,代码行数:16,代码来源:AdminUserController.php

示例5: getView

 public function getView($msg, $code)
 {
     $data1 = new Response($msg, $code);
     $view = new View($data1);
     $view->setTemplate('AppBundle:message.html.twig');
     $view->setTemplateVar('data');
     return $view;
 }
开发者ID:Hemric,项目名称:rentitapi,代码行数:8,代码来源:Raiponce.php

示例6: renderResponse

 protected function renderResponse($contentTemplate, $params)
 {
     if ($this->viewHandler) {
         $view = new View($params);
         $view->setTemplate($contentTemplate);
         return $this->viewHandler->handle($view);
     }
     return $this->templating->renderResponse($contentTemplate, $params);
 }
开发者ID:symfony-cmf,项目名称:blog-bundle,代码行数:9,代码来源:BlogController.php

示例7: getClaimedByUserAction

 /**
  * @ApiDoc(
  *  section="Claims",
  *  description="Display the claimed requests of a user",
  *  output="AppBundle\Controller\ClaimController",
  *  parameters={
  *      {"name"="id", "dataType"="integer", "required"=true, "description"="The user's id"}
  *  }
  * )
  */
 public function getClaimedByUserAction($id)
 {
     $rep = $this->getDoctrine()->getRepository('AppBundle:Claim');
     $claims = $rep->findClaimedByUser($id);
     $view = new View($claims, 200);
     $view->setTemplate('AppBundle:Claim:claimed.html.twig');
     $view->setTemplateVar('claimeds');
     return $this->handleView($view);
 }
开发者ID:Hemric,项目名称:rentitapi,代码行数:19,代码来源:ClaimController.php

示例8: converterAction

 /**
  * alternatively use class="LiipHelloBundle:Article", but this has a bit more overhead
  *
  * @ParamConverter("article", class="Liip\HelloBundle\Document\Article")
  */
 public function converterAction(Article $article = null)
 {
     $view = new View();
     $view->setTemplate(new TemplateReference('LiipHelloBundle', 'Hello', 'index'));
     $name = $article ? 'found: ' . $article->getTitle() : 'No found';
     $view->setData(array('name' => $name));
     $viewHandler = $this->container->get('my_view');
     return $viewHandler->handle($view);
 }
开发者ID:nashidgit,项目名称:LiipHelloBundle,代码行数:14,代码来源:PHPCRController.php

示例9: getCategoryItemsAction

 /**
  * @ApiDoc(
  *  section="Categories",
  *  description="Display the creation form of categories",
  *  output="AppBundle\Controller\CategoryController",
  *  parameters={
  *      {"name"="cat", "dataType"="string", "required"=true, "description"="Category's name"},
  *  }
  * )
  */
 public function getCategoryItemsAction($cat)
 {
     $rep = $this->getDoctrine()->getRepository('AppBundle:Category');
     $category = $rep->findForItem($cat);
     $view = new View($category);
     $view->setTemplate('AppBundle:Category:items.html.twig');
     $view->setTemplateVar('items');
     //dump($view);die();
     return $this->handleView($view);
 }
开发者ID:Hemric,项目名称:rentitapi,代码行数:20,代码来源:CategoryController.php

示例10: editContenidoAction

 public function editContenidoAction($id)
 {
     $em = $this->getDoctrine()->getManager();
     $contenido = $em->getRepository('EtsiSiteBundle:Contenido')->find($id);
     $data = $this->getForm($contenido);
     $view = new View($data);
     $view->setTemplate('EtsiSiteBundle:Form:newContenido.html.twig');
     $view->setFormat('html');
     return $this->get('fos_rest.view_handler')->handle($view);
 }
开发者ID:astrakel,项目名称:web,代码行数:10,代码来源:ContenidosController.php

示例11: editSeccionAction

 public function editSeccionAction($id)
 {
     $em = $this->getDoctrine()->getManager();
     $seccion = $em->getRepository('EtsiSiteBundle:Seccion')->find($id);
     $data = $this->getForm($seccion);
     $view = new View($data);
     $view->setTemplate('EtsiSiteBundle:Form:newSeccion.html.twig');
     $view->setFormat('html');
     return $this->get('fos_rest.view_handler')->handle($view);
 }
开发者ID:astrakel,项目名称:web,代码行数:10,代码来源:SeccionesController.php

示例12: indexAction

 /**
  * Lists all Article entities.
  *
  */
 public function indexAction()
 {
     //echo phpinfo(); die;
     $em = $this->getDoctrine()->getManager();
     $entities = $em->getRepository('MwRestBundle:Article')->findAll();
     $view = new View();
     $view->setData($entities);
     $view->setTemplateVar('entities');
     $view->setTemplate('MwRestBundle:Article:index.html.twig');
     return $this->container->get('fos_rest.view_handler')->handle($view);
 }
开发者ID:BBinsse,项目名称:test,代码行数:15,代码来源:ArticleController.php

示例13: includeJSFilesAction

 /**
  * Render js for VIE and a semantic editor.
  *
  * Hallo is a submodule of this bundle and available after right after you
  * followed the installation instructions.
  * To use aloha, you need to download the zip, as explained in step 8 of
  * the README.
  *
  * @param string $editor the name of the editor to load, currently hallo and aloha are supported
  */
 public function includeJSFilesAction($editor = 'hallo')
 {
     // We could inject a list of names to template mapping for this
     // to allow adding other editors without changing this bundle
     $view = new View();
     switch ($editor) {
         case 'hallo':
             if ($this->coffee) {
                 $view->setTemplate('LiipVieBundle::includecoffeefiles-hallo.html.twig');
             } else {
                 $view->setTemplate('LiipVieBundle::includejsfiles-hallo.html.twig');
             }
             break;
         case 'aloha':
             $view->setTemplate('LiipVieBundle::includejsfiles-aloha.html.twig');
             break;
         default:
             throw new \InvalidArgumentException("Unknown editor '{$editor}' requested");
     }
     return $this->viewHandler->handle($view);
 }
开发者ID:richardmiller,项目名称:LiipVieBundle,代码行数:31,代码来源:VieController.php

示例14: setTemplate

 /**
  * Sets template to use for the encoding
  *
  * @param string|TemplateReference $template template to be used in the encoding
  *
  * @throws \InvalidArgumentException if the template is neither a string nor an instance of TemplateReference
  */
 public function setTemplate($template)
 {
     if (!(is_string($template) || $template instanceof TemplateReference || $template instanceof Template)) {
         throw new \InvalidArgumentException('The template should be a string or extend TemplateReference');
     }
     if (!is_string($template) && $template instanceof Template) {
         $this->setTemplate($template->getTemplate());
     } else {
         parent::setTemplate($template);
     }
     return $this;
 }
开发者ID:WeavingTheWeb,项目名称:devobs,代码行数:19,代码来源:View.php

示例15: editUserAction

 /**
  * @ApiDoc(
  *  section="Users",
  *  description="Display the update form of the user",
  *  input="AppBundle\Controller\Form\UserFormType",
  *  output="AppBundle\Controller\UserController",
  *  parameters={
  *      {"name"="id", "dataType"="integer", "required"=true, "description"="The user id"}
  *  },
  *  statusCodes={
  *       403="Returned when user will modify another one (Forbidden)",
  *       404="Returned when user wants modify a ghost (Not found)"
  *  }
  * )
  */
 public function editUserAction($id)
 {
     // Here we check if the user is authorized to continue ...
     $sameUser = $this->get('check_auth')->sameUser($id, $this->getUser());
     if (!$sameUser) {
         throw new HttpException(403, 'forbidden !');
     }
     $rep = $this->getDoctrine()->getRepository('AppBundle:User');
     $user = $rep->find($id);
     if (!$user) {
         throw new HttpException(404, 'this user doesn\'t exist');
     }
     $form = $this->getForm($user, 'put_user', 'PUT', array('id' => $id));
     $form->remove('plainPassword');
     $view = new View($form);
     $view->setTemplate('AppBundle:User:edit.html.twig');
     return $this->handleView($view);
 }
开发者ID:Hemric,项目名称:rentitapi,代码行数:33,代码来源:UserController.php


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