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