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


PHP ViewModel::addChild方法代码示例

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


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

示例1: 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

示例2: runControllerAction

 /**
  * @param $controllerName
  * @param $action
  * @param array $params
  * @return string|\Zend\Stdlib\ResponseInterface
  * @throws \Exception
  */
 public function runControllerAction($controllerName, $action, $params = array())
 {
     $this->event->getRouteMatch()->setParam('controller', $controllerName)->setParam('action', $action);
     foreach ($params as $key => $value) {
         $this->event->getRouteMatch()->setParam($key, $value);
     }
     $serviceManager = $this->event->getApplication()->getServiceManager();
     $controllerManager = $serviceManager->get('ControllerLoader');
     /** @var AbstractActionController $controller */
     $controller = $controllerManager->get($controllerName);
     $controller->setEvent($this->event);
     $result = $controller->dispatch($this->event->getRequest());
     if ($result instanceof Response) {
         return $result;
     }
     /** @var ViewManager $viewManager */
     $viewManager = $serviceManager->get('ViewManager');
     $renderingStrategy = $viewManager->getMvcRenderingStrategy();
     $this->event->setViewModel($result);
     /** @var ViewModel $result */
     if (!$result->terminate()) {
         $layout = new ViewModel();
         $layoutTemplate = $renderingStrategy->getLayoutTemplate();
         $layout->setTemplate($layoutTemplate);
         $layout->addChild($result);
         $this->event->setViewModel($layout);
     }
     $response = $renderingStrategy->render($this->event);
     return $response;
 }
开发者ID:steffendietz,项目名称:MaglLegacyApplication,代码行数:37,代码来源:ControllerService.php

示例3: testInjectTagsHeader

 public function testInjectTagsHeader()
 {
     $tag = InjectTagsHeaderListener::OPTION_CACHE_TAGS;
     $event = new MvcEvent();
     $response = new Response();
     $event->setResponse($response);
     $layout = new ViewModel();
     $child1 = new ViewModel();
     $child1->setOption($tag, ['tag1', 'tag2']);
     $layout->addChild($child1);
     $child2 = new ViewModel();
     $child21 = new ViewModel();
     $child21->setOption($tag, ['tag3', null]);
     $child2->addChild($child21);
     $layout->addChild($child2);
     $child3 = new ViewModel();
     $child3->setOption('esi', ['ttl' => 120]);
     $child3->setOption($tag, 'tag4');
     $layout->addChild($child3);
     $event->setViewModel($layout);
     $this->listener->injectTagsHeader($event);
     $this->assertSame(['tag1', 'tag2', 'tag3'], $this->listener->getCacheTags());
     $headers = $response->getHeaders();
     $this->assertEquals('tag1,tag2,tag3', $headers->get(VarnishService::VARNISH_HEADER_TAGS)->getFieldValue());
 }
开发者ID:hummer2k,项目名称:convarnish,代码行数:25,代码来源:InjectTagsHeaderListenerTest.php

示例4: indexAction

 public function indexAction()
 {
     $view = new ViewModel();
     $username = $this->params()->fromPost('username');
     $password = $this->params()->fromPost('password');
     if (empty($username) && empty($password)) {
         $session = new Container('user_session');
         $pattern = $session->offsetGet('session_status');
         if (!empty($pattern)) {
             $adminContent = new ViewModel(array('posts' => $this->formatTargetPosts($this->postService->findAllPosts('', 'php'), true)));
             $adminContent->setTemplate('template/content/adminContent.phtml');
             $view->addChild($adminContent, '_admin_content');
             return $view;
         } else {
             echo "<h1>Forbidden No Session stored!</h1>\r\n                    <button id=\"retry_1\" type=\"button\" class=\"btn btn-success\">To login Site</button>";
         }
     } else {
         $result = $this->postService->userMapping($username, $password);
         if ($result) {
             $this->sessionAction($username);
             $adminContent = new ViewModel(array('posts' => $this->formatTargetPosts($this->postService->findAllPosts('', 'php'), true)));
             //
             $adminContent->setTemplate('template/content/adminContent.phtml');
             $view->addChild($adminContent, '_admin_content');
             //        TODO: Implement Admin Content.
         } else {
             $error_message = new ViewModel(array());
             $error_message->setTemplate('template/error/error_admin_login.phtml');
             $view->addChild($error_message, '_error_message');
         }
         return $view;
     }
 }
开发者ID:fatalerrortan,项目名称:Zend_Blog,代码行数:33,代码来源:AdminController.php

示例5: __invoke

 public function __invoke($dataView, $layout)
 {
     $dashboard = new ViewModel();
     $dashboard->setTemplate('dashboard/view');
     $sidebar = new ViewModel();
     $sidebar->setTemplate('dashboard/sidebar');
     $dashboard->addChild($sidebar, 'sidebar');
     $dashboard->addChild($dataView, 'data');
     $layout->addChild($dashboard, 'content');
     return $dashboard;
 }
开发者ID:JonathanConner,项目名称:SocialNet,代码行数:11,代码来源:DashboardBuilder.php

示例6: render

 /**
  * Render the provided model.
  *
  * @param ModelInterface $model
  * @return string
  */
 public function render(ModelInterface $model)
 {
     if ($this->layout && !$model->terminate()) {
         $this->layout->addChild($model);
         $model = $this->layout;
     }
     // hack, force ZendView to return its output instead of triggering an event
     // see: http://mateusztymek.pl/blog/using-standalone-zend-view
     $model->setOption('has_parent', true);
     return $this->zendView->render($model);
 }
开发者ID:mtymek,项目名称:blast-view,代码行数:17,代码来源:View.php

示例7: articleAction

 public function articleAction()
 {
     $id = $this->params()->fromQuery('id');
     $view = new ViewModel();
     $sidebarView = new ViewModel(array('newposts' => $this->formatTargetPosts($this->postService->findAllPosts(0), false)));
     $sidebarView->setTemplate('template/sidebar/sidebar_post.phtml');
     $view->addChild($sidebarView, '_sidebarView');
     $article = new ViewModel(array('article' => $this->postService->findPost($id)));
     $article->setTemplate('template/content/article.phtml');
     $view->addChild($article, '_article');
     return $view;
 }
开发者ID:fatalerrortan,项目名称:Zend_Blog,代码行数:12,代码来源:PostsController.php

示例8: serviceAction

 public function serviceAction()
 {
     $serviceName = strtolower($this->params()->fromRoute('service'));
     $format = strtolower($this->params()->fromRoute('format'));
     $runChecks = $this->params()->fromQuery('run', true);
     if (in_array($format, array(self::XML, self::RICH))) {
         throw new Exception\UnexpectedValueException(sprintf('Format "%s" is currently not supported', $format));
     }
     try {
         $service = new Model\Service($serviceName);
     } catch (Model\Exception\BadModelCallException $e) {
         return $this->notFoundAction();
     }
     $this->_setNewRelic($service);
     $content = $this->_getContentView($service, $format, $runChecks);
     if ($format === self::JSON) {
         $data = $content->getVariables();
         unset($data->service);
         $view = new ViewModel\JsonModel($data);
         Json\Json::$useBuiltinEncoderDecoder = true;
     } else {
         $view = new ViewModel\ViewModel();
         $view->addChild($content, 'content');
         $view->service = $service;
         $view->format = $format;
     }
     return $view;
 }
开发者ID:sullenboom,项目名称:sla-healthcheck,代码行数:28,代码来源:RunnerController.php

示例9: indexAction

 public function indexAction()
 {
     $sm = $this->getServiceLocator();
     $userService = $sm->get('Stjornvisi\\Service\\User');
     $conferenceService = $sm->get('Stjornvisi\\Service\\Conference');
     /** @var $conferenceService \Stjornvisi\Service\Conference */
     $authService = new AuthenticationService();
     //CONFERENCE FOUND
     //  an conference with this ID was found
     if (($conference = $conferenceService->get($this->params()->fromRoute('id', 0), $authService->hasIdentity() ? $authService->getIdentity()->id : null)) != false) {
         $groupIds = array_map(function ($i) {
             return $i->id;
         }, $conference->groups);
         //TODO don't use $_POST
         //TODO send registration mail
         if ($this->request->isPost()) {
             $conferenceService->registerUser($conference->id, $this->params()->fromPost('email', ''), 1, $this->params()->fromPost('name', ''));
             $this->getEventManager()->trigger('notify', $this, array('action' => 'Stjornvisi\\Notify\\Attend', 'data' => (object) array('conference_id' => $conference->id, 'type' => 1, 'recipients' => (object) array('id' => null, 'name' => $this->params()->fromPost('name', ''), 'email' => $this->params()->fromPost('email', '')))));
             return new ViewModel(array('logged_in' => $authService->hasIdentity(), 'register_message' => true, 'conference' => $conference, 'related' => $conferenceService->getRelated($groupIds), 'attendees' => $userService->getByConference($conference->id), 'access' => $userService->getTypeByGroup($authService->hasIdentity() ? $authService->getIdentity()->id : null, $groupIds)));
         } else {
             $conferenceView = new ViewModel(array('conference' => $conference, 'register_message' => false, 'logged_in' => $authService->hasIdentity(), 'access' => $userService->getTypeByGroup($authService->hasIdentity() ? $authService->getIdentity()->id : null, $groupIds), 'attendees' => $userService->getByConference($conference->id)));
             $conferenceView->setTemplate('stjornvisi/conference/partials/index-conference');
             $asideView = new ViewModel(array('access' => $userService->getTypeByGroup($authService->hasIdentity() ? $authService->getIdentity()->id : null, $groupIds), 'conference' => $conference, 'related' => null));
             $asideView->setTemplate('stjornvisi/conference/partials/index-aside');
             $mainView = new ViewModel();
             $mainView->addChild($conferenceView, 'conference')->addChild($asideView, 'aside');
             return $mainView;
         }
         //NOT FOUND
         //  todo 404
     } else {
         var_dump('404');
     }
 }
开发者ID:bix0r,项目名称:Stjornvisi,代码行数:34,代码来源:ConferenceController.php

示例10: indexAction

 public function indexAction()
 {
     /**
      * @var \DDD\Service\Cubilis\Connection $cubilisConnectionService
      * @var General $apartmentGeneralService
      */
     $cubilisConnectionService = $this->getServiceLocator()->get('service_cubilis_connection');
     $apartmentGeneralService = $this->getServiceLocator()->get('service_apartment_general');
     $cubilisDetails = $apartmentGeneralService->getCubilisDetailsAsArray($this->apartmentId);
     $form = new CubilisConnection($this->url()->fromRoute('apartment/channel-connection/save', ['apartment_id' => $this->apartmentId]));
     $form->prepare();
     $form->populateValues($cubilisDetails);
     $formTemplate = 'form-templates/cubilis-connection';
     $viewModelForm = new ViewModel();
     $viewModelForm->setVariables(['form' => $form]);
     $viewModelForm->setTemplate($formTemplate);
     $rates = $apartmentGeneralService->getRoomRates($this->apartmentId);
     $rateConnections = $cubilisConnectionService->getCubilisTypes($this->apartmentId, $rates);
     $urlLinkRates = $this->url()->fromRoute('apartment/channel-connection/link', ['apartment_id' => $this->apartmentId]);
     $apartmentOTAService = $this->getServiceLocator()->get('service_apartment_ota_distribution');
     $apartmentOTAList = $apartmentOTAService->getOTAList($this->apartmentId);
     $partnerList = $apartmentOTAService->getPartnerList();
     $hasApartmentConnectionRole = false;
     $auth = $this->getServiceLocator()->get('library_backoffice_auth');
     if ($auth->hasRole(Roles::ROLE_APARTMENT_CONNECTION)) {
         $hasApartmentConnectionRole = true;
     }
     $viewModel = new ViewModel();
     $viewModel->setVariables(['apartmentId' => $this->apartmentId, 'apartmentStatus' => $this->apartmentStatus, 'rateConnections' => $rateConnections, 'rates' => $rates, 'urlLinkRates' => $urlLinkRates, 'cubilisDetails' => $cubilisDetails, 'apartmentOTAList' => $apartmentOTAList, 'partnerList' => $partnerList, 'OTAStatus' => Objects::getOTADistributionStatusList(), 'isCubilisConnecter' => $hasApartmentConnectionRole]);
     // child view to render form
     $viewModel->addChild($viewModelForm, 'formOutput');
     $viewModel->setTemplate('apartment/channel-connection/index');
     return $viewModel;
 }
开发者ID:arbi,项目名称:MyCode,代码行数:34,代码来源:ChannelConnection.php

示例11: setChildViews

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

示例12: indexAction

 /**
  * @return \Zend\View\Model\ViewModel
  */
 public function indexAction()
 {
     /**
      * @var \DDD\Service\Apartment\General $apartmentGeneralService
      */
     $apartmentGeneralService = $this->getServiceLocator()->get('service_apartment_general');
     $form = $this->getForm();
     $form->prepare();
     $generalInfo = false;
     if ($this->apartmentId) {
         $generalInfo = $apartmentGeneralService->getApartmentGeneral($this->apartmentId);
         $form->populateValues(['id' => $this->apartmentId, 'apartment_name' => $generalInfo['name'], 'status' => $generalInfo['status'], 'room_count' => $generalInfo['room_count'], 'square_meters' => $generalInfo['square_meters'], 'max_capacity' => $generalInfo['max_capacity'], 'bedrooms' => $generalInfo['bedroom_count'], 'bathrooms' => $generalInfo['bathroom_count'], 'chekin_time' => date('H:i', strtotime($generalInfo['check_in'])), 'chekout_time' => date('H:i', strtotime($generalInfo['check_out'])), 'general_description_textline' => $generalInfo['general_descr'], 'general_description' => $generalInfo['general_description']]);
     } else {
         // Pre-filled default values when adding apartment
         $form->populateValues(['chekin_time' => '15:00', 'chekout_time' => '11:00']);
     }
     // passing form and map to the view
     $viewModelForm = new ViewModel();
     $viewModelForm->setVariables(['form' => $form, 'date_created' => isset($generalInfo['create_date']) ? $generalInfo['create_date'] : '', 'apartmentStatus' => $this->apartmentStatus]);
     $viewModelForm->setTemplate('form-templates/general');
     $viewModel = new ViewModel();
     $viewModel->setVariables(['apartment' => $generalInfo, 'apartmentId' => $this->apartmentId, 'apartmentStatus' => $this->apartmentStatus]);
     // child view to render form
     $viewModel->addChild($viewModelForm, 'formOutput');
     $viewModel->setTemplate('apartment/general/index');
     return $viewModel;
 }
开发者ID:arbi,项目名称:MyCode,代码行数:30,代码来源:General.php

示例13: indexAction

 public function indexAction()
 {
     $data = $this->params()->fromPost();
     $vm = new ViewModel(array('postForm' => $this->postForm, 'data' => $data));
     $vm->setTemplate('market/post/index.phtml');
     if ($this->getRequest()->isPost()) {
         $this->postForm->setData($data);
         if ($this->postForm->isValid()) {
             if (isset($data['cityCode'])) {
                 $data['cityCode'] = $this->worldCityAreaCodesTable->getCodeById($data['cityCode']);
             }
             if ($this->listingsTable->addPosting($data)) {
                 $this->flashMessenger()->addMessage("Dados postados com sucesso.");
             } else {
                 $this->flashMessenger()->addMessage("Houve um problema ao inserir os dados do formulário.");
             }
             return $this->redirect()->toRoute('home');
         } else {
             $invalidView = new ViewModel();
             $invalidView->setTemplate('market/post/invalid.phtml');
             $invalidView->addChild($vm, 'main');
             return $invalidView;
         }
     }
     return $vm;
 }
开发者ID:lohmuller,项目名称:OnlineMarket,代码行数:26,代码来源:PostController.php

示例14: indexAction

 public function indexAction()
 {
     $this->_mainParam["data"]["id"] = $this->params("id");
     $display = $this->params("display", "list");
     $viewModel = new ViewModel();
     //view chính
     $bookView = new ViewModel();
     //view -hiện danh sách book
     $bookView->setTemplate('shop/category/' . $display);
     //CATEGORY INFO
     $categoryItem = $this->getTable()->getItem($this->_mainParam["data"]);
     if (empty($categoryItem)) {
         $this->redirect()->toRoute("shopRoute/default", array("controller" => "notice", "action" => "no-data"));
     }
     //BREADCRUMB
     $listBreadcumb = $this->getTable()->listItem($categoryItem, array("task" => "list-breadcrumb"));
     //LISTBOOK BY CATEGORY
     $catIDs = $this->getTable()->listItem($categoryItem, array("task" => "list-id-category"));
     $this->_mainParam["catIDs"] = $catIDs;
     $bookTable = $this->getServiceLocator()->get("shopBookTable");
     $listBook = $bookTable->listItem($this->_mainParam, array("task" => "list-book-by-category"));
     $totalItem = $bookTable->countItem($catIDs, array("task" => "count-book"));
     $viewModel->addChild($bookView, "list_book_category");
     $bookView->setVariables(array("listBook" => $listBook));
     $viewModel->setVariables(array("categoryItem" => $categoryItem, "listBreadcumb" => $listBreadcumb, "paginator" => \ZendVN\Paginator\Paginator::createPagination($totalItem, $this->_configPaginator), "displayType" => $display, "paramSetting" => $this->_mainParam));
     return $viewModel;
 }
开发者ID:trongle,项目名称:book_zend2,代码行数:27,代码来源:CategoryController.php

示例15: listAction

 public function listAction()
 {
     $grid = $this->seoGrid;
     $grid->execute();
     $view = new ViewModel();
     $view->addChild($grid->getResponse(), 'grid');
     $view->setVariable('addSeoForm', $this->seoForm);
     return $view;
 }
开发者ID:nsenkevich,项目名称:seo,代码行数:9,代码来源:SeoController.php


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