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


PHP ViewModel::setTemplate方法代码示例

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


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

示例1: indexAction

 public function indexAction()
 {
     $entity = $this->getEntity();
     if (!$entity) {
         $this->getResponse()->setStatusCode(404);
         return false;
     }
     $type = $this->moduleOptions->getType($entity->getType()->getName());
     if ($type->hasComponent('redirect')) {
         /* @var $redirect RedirectOptions */
         $redirect = $type->getComponent('redirect');
         foreach ($entity->getChildren('link', $redirect->getToType()) as $child) {
             if (!$child->isTrashed() && $child->hasCurrentRevision()) {
                 return $this->redirect()->toRoute('uuid/get', ['uuid' => $child->getId()]);
             }
         }
     }
     $model = new ViewModel(['entity' => $entity]);
     $model->setTemplate('entity/page/default');
     if ($this->params('isXmlHttpRequest', false)) {
         $model->setTemplate('entity/view/default');
     }
     $this->layout('layout/3-col');
     if (!$entity->hasCurrentRevision()) {
         $this->layout('layout/2-col');
         $model->setTemplate('entity/page/pending');
     }
     return $model;
 }
开发者ID:andreas-serlo,项目名称:athene2,代码行数:29,代码来源:PageController.php

示例2: processAction

 public function processAction()
 {
     if (!$this->request->isPost()) {
         return $this->redirect()->toRoute('register');
     }
     $post = $this->request->getPost();
     $form = $this->getServiceLocator()->get('RegisterForm');
     $form->setData($post);
     if (!$form->isValid()) {
         $model = new ViewModel(array('error' => 'There were one or more isues with your submission. Please correct them as
 indicated below.', 'form' => $form));
         $model->setTemplate('user/register/register');
         return $model;
     }
     $data = $form->getData();
     if ($this->checkIfNotRegistered($data)) {
         // Create user
         $this->createUser($form->getData());
         return $this->redirect()->toRoute('register', array('action' => 'confirm'));
     } else {
         $model = new ViewModel(array('error' => 'You are already registered', 'form' => $form));
         $model->setTemplate('user/register/register');
         return $model;
     }
 }
开发者ID:qlarin,项目名称:sls-repository,代码行数:25,代码来源:RegisterController.php

示例3: editarAction

 public function editarAction()
 {
     //definindo variaveis
     $request = $this->getRequest();
     $id = $this->Params('id');
     $serviceGrupo = $this->getServiceLocator()->get('security-service-grupo');
     $form = new Grupo();
     $dadosGrupo = $this->getEm('Security\\Entity\\Grupo')->find($id)->toArray();
     $form->setData($dadosGrupo);
     // definindo acao conforme method da request
     if ($request->isPost()) {
         $form->setInputFilter(new \Security\Filter\Grupo());
         $data = $request->getPost()->toArray();
         $form->setData($data);
         if ($form->isValid()) {
             if ($serviceGrupo->update($data, 'Security\\Entity\\Grupo', $id)) {
                 $this->flashMessenger()->addSuccessMessage('Dados editados com sucesso!');
                 return $this->redirect()->toUrl($this->getUrlFromSubfolderApplication('/security/grupo'));
             } else {
                 $this->flashMessenger()->addErrorMessage('Ocorreu algum erro ao editar os dados!');
                 return $this->redirect()->toRoute(array('controller' => 'grupo', 'action' => 'editar'));
             }
         }
     }
     $view = new ViewModel(array('form' => $form));
     $view->setTemplate('security/grupo/form.phtml');
     return $view;
 }
开发者ID:ericoautocad,项目名称:module-security-zf2,代码行数:28,代码来源:GrupoController.php

示例4: updateAction

 public function updateAction()
 {
     $request = $this->getRequest();
     $recipe = $this->readService->findById($this->params('id'));
     if (false === $this->authorizationService->isGranted('recipe.manage', $recipe)) {
         throw new UnauthorizedException('Insufficient Permissions');
     }
     $viewModel = new ViewModel();
     $viewModel->setTemplate('recipe/update');
     $viewModel->setVariables(['form' => $this->form]);
     $this->form->bind($recipe);
     if ($request->isPost()) {
         $this->form->setData($request->getPost());
         if ($this->form->isValid()) {
             try {
                 $this->writeService->save($this->form->getData());
                 $this->flashMessenger()->addSuccessMessage('Rezept erfolgreich aktualisiert');
                 $this->redirect()->toRoute('recipe/read/update', ['id' => $this->params('id')]);
             } catch (\Exception $e) {
                 var_dump($e->getMessage());
             }
         }
     }
     $this->layout('layout/backend');
     return $viewModel;
 }
开发者ID:Indigo1337,项目名称:c4d,代码行数:26,代码来源:Update.php

示例5: saveAction

 public function saveAction()
 {
     $form = $this->getForm();
     $request = $this->getRequest();
     $id = $this->params('id');
     if ($request->isPost()) {
         $data = $request->getPost();
         $form->setData($data);
         $kart = new Kart();
         $form->setInputFilter($kart->getInputFilter());
         if ($form->isValid()) {
             try {
                 $kart->exchangeArray($form->getData());
                 $this->serviceLocator->get('karts')->save($kart->getArrayCopy());
             } catch (\Exception $e) {
             }
             return $this->redirect()->toRoute('application/default', ['controller' => 'kart']);
         }
     } elseif ($id) {
         $kartData = $this->serviceLocator->get('karts')->findById($id);
         $form->setData($kartData);
     }
     $viewModel = new ViewModel();
     $viewModel->setVariables(['form' => $form]);
     $viewModel->setTemplate('application/kart/form.phtml');
     return $viewModel;
 }
开发者ID:kaiocesar,项目名称:kart,代码行数:27,代码来源:KartController.php

示例6: setChildViews

 protected function setChildViews(ViewModel $view_page)
 {
     $view_menu = new ViewModel();
     $view_menu->setTemplate('setting/common/menu');
     $view_page->addChild($view_menu, 'menu');
     return $view_page;
 }
开发者ID:lpj0017,项目名称:easypay,代码行数:7,代码来源:BaseSettingController.php

示例7: processAction

 public function processAction()
 {
     if (!$this->request->isPost()) {
         return $this->redirect()->toRoute('zfcadmin/cmspages/settings');
     }
     try {
         $settingsEntity = new \Base\Entity\Settings();
         $post = $this->request->getPost();
         $form = $this->getServiceLocator()->get('FormElementManager')->get('CmsSettings\\Form\\PageForm');
         $form->setData($post);
         if (!$form->isValid()) {
             // Get the record by its id
             $viewModel = new ViewModel(array('error' => true, 'form' => $form));
             $viewModel->setTemplate('cms-settings/page/index');
             return $viewModel;
         }
         $data = $form->getData();
         // Cleanup the custom settings
         $this->recordService->cleanup('Cms');
         foreach ($data as $parameter => $value) {
             if ($parameter == "submit") {
                 continue;
             }
             $settingsEntity->setModule('Cms');
             $settingsEntity->setParameter($parameter);
             $settingsEntity->setValue($value);
             $this->recordService->save($settingsEntity);
             // Save the data in the database
         }
         $this->flashMessenger()->setNamespace('success')->addMessage($this->translator->translate('The information have been saved.'));
     } catch (\Exception $e) {
         $this->flashMessenger()->setNamespace('error')->addMessage($e->getMessage());
     }
     return $this->redirect()->toRoute('zfcadmin/cmspages/settings');
 }
开发者ID:eotg1910,项目名称:shineisp2,代码行数:35,代码来源:PageController.php

示例8: renderEmail

 public function renderEmail($template = 'message', $emailOptions = array())
 {
     $emailOptions = array_merge($this->defaultEmailOptions, $emailOptions);
     $layout = new ViewModel($emailOptions);
     if ($this->html) {
         if ($this->resolver->resolve("email/" . $this->templateGroup . "/layout")) {
             $layout->setTemplate("email/" . $this->templateGroup . "/layout");
         } elseif ($this->resolver->resolve("email/default/layout")) {
             $layout->setTemplate("email/default/layout");
         } else {
             throw new \Exception("neither " . "email/" . $this->templateGroup . "/layout" . ' or ' . "email/default/layout" . ' is available', 1);
         }
     } else {
         if ($this->resolver->resolve("email/" . $this->templateGroup . "/layout_plain")) {
             $layout->setTemplate("email/" . $this->templateGroup . "/layout_plain");
         } elseif ($this->resolver->resolve("email/default/layout_plain")) {
             $layout->setTemplate("email/default/layout_plain");
         } else {
             throw new \Exception("neither " . "email/" . $this->templateGroup . "/layout_plain" . ' or ' . "email/default/layout_plain" . ' is available', 1);
         }
     }
     $contentView = null;
     if ($this->resolver->resolve("email/" . $this->templateGroup . "/" . $template)) {
         $contentView = $this->viewRender->render("email/" . $this->templateGroup . "/" . $template, $emailOptions);
     } elseif ($this->resolver->resolve("email/default/" . $template)) {
         $contentView = $this->viewRender->render("email/default/" . $template, $emailOptions);
     } else {
         throw new \Exception("neither " . "email/" . $this->templateGroup . "/" . $template . ' or ' . "email/default/" . $template . ' is available', 1);
     }
     $layout->setVariable("content", $contentView);
     $content = $this->viewRender->render($layout);
     //replace domain with url
     $content = str_replace('{{domain}}', 'http://' . $emailOptions['domain'], $content);
     return $content;
 }
开发者ID:CasasoftCH,项目名称:casamodules,代码行数:35,代码来源:EmailService.php

示例9: resetAction

 public function resetAction()
 {
     $viewModel = new ViewModel();
     $this->getUserService();
     $email = $this->params()->fromPost("email", false);
     if ($email) {
         $viewModel->setTemplate("chatter/account/reset");
         $this->userService->sendPasswordEmail($email);
         $viewModel->setVariable($submitted, true);
     } else {
         $uuid = $this->params()->fromPost("uuid", false);
         $password = $this->params()->fromPost("password", false);
         if ($uuid && $password) {
             $viewModel->setTemplate("chatter/account/savedpass");
             $this->userService->resetPassword($uuid, $password);
         } else {
             $uuid = $this->params()->fromQuery("uuid", false);
             if ($uuid) {
                 $viewModel->setVariable("uuid", $uuid);
                 $viewModel->setTemplate("chatter/account/newpass");
             } else {
                 $viewModel->setTemplate("chatter/account/reset");
             }
         }
     }
     return $viewModel;
 }
开发者ID:galaco,项目名称:chatter,代码行数:27,代码来源:AccountController.php

示例10: onBootstrap

 public function onBootstrap(EventInterface $e)
 {
     // Récupération des erreurs en ajoutant un callback qui affiche l'erreur coté serveur
     $application = $e->getTarget();
     $event = $application->getEventManager();
     $event->attach(MvcEvent::EVENT_DISPATCH_ERROR, function (MvcEvent $e) {
         error_log('DISPATCH_ERROR : ' . $e->getError());
         error_log($e->getControllerClass() . ' ' . $e->getController());
     });
     $event->attach(MvcEvent::EVENT_RENDER_ERROR, function (MvcEvent $e) {
         error_log('RENDER_ERROR : ' . $e->getError());
     });
     $event->attach(MvcEvent::EVENT_RENDER, function (MvcEvent $e) {
         $services = $e->getApplication()->getServiceManager();
         $session = $services->get('session');
         $rightViewModel = new ViewModel();
         if (!isset($session->user)) {
             $form = $services->get('MiniModule\\Form\\Authentification');
             $formUser = $services->get('MiniModule\\Form\\NewUser');
             $rightViewModel->setVariables(array('form' => $form, 'newUserForm' => $formUser));
             $rightViewModel->setTemplate('layout/form-auth');
         } else {
             $rightViewModel->setVariables(array('user' => $session->user));
             $rightViewModel->setTemplate('layout/info-auth');
         }
         $view = $e->getViewModel();
         // c'est le viewModel qui contient le layout (top viewModel)
         $view->addChild($rightViewModel, 'formulaireAuth');
     });
 }
开发者ID:sanPgut,项目名称:SupportCoursZF2,代码行数:30,代码来源:Module.php

示例11: indexAction

 function indexAction()
 {
     $this->init();
     $layoutViewModel = $this->layout();
     $progress = new ViewModel(['step' => 2]);
     $progress->setTemplate('application/progress');
     $layoutViewModel->addChild($progress, 'progress');
     $user = \bootstrap::getInstance()->getUser();
     $staffSelector = $this->staffSelector(true, $this->params('service'));
     if (!is_null($staffSelector->getValue('staff'))) {
         $this->staff_selection = $staffSelector->getValue('staff');
     } else {
         $this->staff_selection = $this->listStaff($this->params()->fromQuery('service'));
     }
     $this->viewParams = $this->viewParams + ['staffSelector' => $staffSelector, 'therapist_id' => $this->params()->fromQuery('staff'), 'service' => $this->params('service')];
     $this->renderCalendar($this->viewParams);
     /** Display controls to toggle between week & calendar views */
     $this->viewParams['mode'] = $this->params('mode');
     $viewModel = new ViewModel($this->viewParams);
     $viewModel->setTemplate('application/calendar-mode-chooser');
     //return $viewModel;
     $viewModel = new ViewModel($this->viewParams);
     if ($this->params('mode') == 'week') {
         /** Display the week view */
         $viewModel->setTemplate('week-choose');
     } else {
         /** Display the calendar */
         $viewModel->setTemplate('application/calendar-choose');
     }
     return $viewModel;
 }
开发者ID:mustafakarali,项目名称:application,代码行数:31,代码来源:CalendarController.php

示例12: setUp

 public function setUp()
 {
     $this->viewModel = new ViewModel();
     $this->viewModel->setTemplate('test/template');
     $viewModelHelper = $this->getMockBuilder(ViewModelHelper::class)->setMethods(['getCurrent'])->getMock();
     $viewModelHelper->expects($this->any())->method('getCurrent')->willReturn($this->viewModel);
     $this->view = $this->getMockBuilder(View::class)->setMethods(['viewModel', 'translate', 'partial', 'url'])->getMock();
     $this->view->expects($this->any())->method('viewModel')->willReturn($viewModelHelper);
     $this->helper = new Helper();
     $this->helper->setView($this->view);
 }
开发者ID:cross-solution,项目名称:yawik,代码行数:11,代码来源:ApplyButtonsTest.php

示例13: indexAction

 public function indexAction()
 {
     $viewModel = new ViewModel();
     // just check if the user is logged in...
     $auth = $this->getServiceLocator()->get('auth');
     if ($auth->hasIdentity()) {
         $viewModel->setTemplate('application/index/index');
     } else {
         $viewModel->setTemplate('application/index/index-notloggedin');
     }
     return $viewModel;
 }
开发者ID:spoorey,项目名称:hangman,代码行数:12,代码来源:IndexController.php

示例14: landingAction

 public function landingAction()
 {
     // $vars['galleries'] =
     // $this->getEntityManager()->getRepository('Application\Entity\Gallery')->findAll();
     //$dir = __DIR__ . "/../../../../../public/_images/_galerias/" . strtoupper ( $this->getEvent ()->getRouteMatch ()->getParam ( 'galeria' ) ) . "";
     //$files = scandir ( $dir );
     // print_r ( $files );
     $viewModel = new ViewModel();
     $viewModel->setTemplate("projects/landing");
     switch ($this->getEvent()->getRouteMatch()->getParam('section')) {
         case "tec":
             $vars['imagen_back'] = 'images/st.png';
             break;
         case "pic":
             $vars['imagen_back'] = 'images/banco2.png';
             break;
         case "tipv":
             $vars['imagen_back'] = 'images/innivaciones.jpg';
             break;
         case "ptm":
             $vars['imagen_back'] = 'images/ptm.png';
             break;
         default:
             $viewModel->setTemplate("error/index");
             break;
     }
     if ($this->getEvent()->getRouteMatch()->getParam('id') != "") {
         if ($this->getEvent()->getRouteMatch()->getParam('galeria') == "") {
             $sx = $this->getEntityManager()->getRepository('Backend\\Entity\\Section')->findOneBy(array('descripcion' => strtoupper($this->getEvent()->getRouteMatch()->getParam('section'))));
             $gx = $this->getEntityManager()->getRepository('Backend\\Entity\\Gallery')->findBy(array('id_section' => $sx->getId(), 'visible' => 1));
             $slug = $gx[0]->getSlug();
         } else {
             $slug = $this->getEvent()->getRouteMatch()->getParam('galeria');
         }
         $section = $this->getEntityManager()->getRepository('Backend\\Entity\\Section')->findOneBy(array('descripcion' => strtoupper($this->getEvent()->getRouteMatch()->getParam('section')), 'visible' => 1));
         $galeria = $this->getEntityManager()->getRepository('Backend\\Entity\\Gallery')->findOneBy(array('slug' => $slug, 'visible' => 1));
         $vars["galeria_loaded"] = $galeria->getDescripcion();
         if (count($galeria) > 0) {
             $g = $this->getEntityManager()->getRepository('Backend\\Entity\\Gallery')->findBy(array('id_section' => $section->getId(), 'visible' => 1));
             $i = $this->getEntityManager()->getRepository('Backend\\Entity\\Item')->findBy(array('id_gallery' => $galeria->getId(), 'visible' => 1));
             $viewModel->setTemplate("projects/gallery");
             $vars["id"] = $this->getEvent()->getRouteMatch()->getParam('id');
             $vars["secciones"] = $g;
             $vars["items"] = $i;
         } else {
             $viewModel->setTemplate("error/404");
         }
     }
     $vars["section"] = $this->getEvent()->getRouteMatch()->getParam('section');
     $vars["galeria"] = $this->getEvent()->getRouteMatch()->getParam('galeria');
     $viewModel->setVariables($vars);
     return $viewModel;
 }
开发者ID:tineo,项目名称:webapoyopublicitario,代码行数:53,代码来源:ProjectsController.php

示例15: __invoke

 /**
  * add template to action view
  *
  * @param string $layoutName
  * @return ViewModel
  */
 public function __invoke($layoutName)
 {
     $view = new ViewModel();
     switch ($layoutName) {
         case 'profile':
             $view->setTemplate('layout/profile');
             break;
         case 'booking':
             $view->setTemplate('layout/booking');
     }
     $view->setVariable('controllerName', $this->getControllerName());
     return $view;
 }
开发者ID:jkhaled,项目名称:docdz,代码行数:19,代码来源:LayoutHelper.php


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