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


PHP EventInterface::getViewModel方法代码示例

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


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

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

示例2: onBootstrap

 /**
  * Listen to the bootstrap event.
  *
  * @param EventInterface|MvcEvent $e
  *
  * @return array|void
  */
 public function onBootstrap(EventInterface $e)
 {
     if (!$e instanceof MvcEvent) {
         return;
     }
     $currentRouteName = $this->getCurrentRouteName($e->getApplication()->getServiceManager());
     $e->getViewModel()->setVariables(['__currentRouteName' => $currentRouteName]);
 }
开发者ID:noiselabs,项目名称:zf-debug-utils,代码行数:15,代码来源:Module.php

示例3: renderLayoutSegments

 /**
  * Listen to the "render" event and render additional layout segments
  *
  * @param  MvcEvent $e
  *
  * @return null
  */
 public function renderLayoutSegments(EventInterface $e)
 {
     // get view Model
     $viewModel = $e->getViewModel();
     /* @var $viewModel ViewModel */
     // only for normal View Models
     if (!$viewModel instanceof JsonModel) {
         // add an additional header segment to layout
         $header = new ViewModel();
         $header->setTemplate('layout/header');
         $viewModel->addChild($header, 'header');
         // add an additional footer segment to layout
         $footer = new ViewModel();
         $footer->setTemplate('layout/footer');
         $viewModel->addChild($footer, 'footer');
     }
     // return response
     return $e->getResponse();
 }
开发者ID:huanhuashengling,项目名称:ipc2013-testing,代码行数:26,代码来源:ApplicationListener.php

示例4: renderLayoutSegments

 /**
  * Listen to the "render" event and render additional layout segments
  *
  * @param  MvcEvent $e
  * @return null
  */
 public function renderLayoutSegments(EventInterface $e)
 {
     // get view Model
     $viewModel = $e->getViewModel();
     /* @var $viewModel ViewModel */
     // add an additional header segment to layout
     $header = new ViewModel();
     $header->setTemplate('layout/header');
     $viewModel->addChild($header, 'header');
     // add an additional sidebar segment to layout
     $sidebar = new ViewModel();
     $sidebar->setTemplate('layout/sidebar');
     $viewModel->addChild($sidebar, 'sidebar');
     // add an additional footer segment to layout
     $footer = new ViewModel();
     $footer->setTemplate('layout/footer');
     $viewModel->addChild($footer, 'footer');
     // return response
     return $e->getResponse();
 }
开发者ID:andreaszobl,项目名称:software,代码行数:26,代码来源:ApplicationListener.php

示例5: onBootstrap

 /**
  *
  * @param MvcEvent|EventInterface $e
  * @return array|void
  */
 public function onBootstrap(Event $e)
 {
     $application = $e->getApplication();
     $serviceManager = $application->getServiceManager();
     $eventManager = $application->getEventManager();
     $request = $serviceManager->get('Request');
     if (!$request instanceof Request) {
         return;
     }
     /* @var $options ModuleOptions */
     $options = $serviceManager->get(ModuleOptions::class);
     $listeners = $options->getListeners();
     foreach ($listeners as $listener => $isEnabled) {
         if ($isEnabled) {
             $serviceManager->get($listener)->attach($eventManager);
         }
     }
     $serviceManager->get(LayoutInterface::class)->setRoot($e->getViewModel());
     if ($options->isDebug()) {
         $this->attachDebugger($serviceManager);
     }
 }
开发者ID:hummer2k,项目名称:conlayout,代码行数:27,代码来源:Module.php

示例6: setMenu

 /**
  * Hook to inject the main menu
  *
  * This is invoked by the "render" event.
  *
  * @param \Zend\Mvc\MvcEvent $e MVC event
  */
 public function setMenu(\Zend\EventManager\EventInterface $e)
 {
     $e->getViewModel()->menu = 'Console\\Navigation\\MainMenu';
 }
开发者ID:hschletz,项目名称:braintacle,代码行数:11,代码来源:Module.php


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