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


PHP Application::events方法代码示例

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


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

示例1: testEventManagerIsLazyLoaded

 public function testEventManagerIsLazyLoaded()
 {
     $app = new Application();
     $events = $app->events();
     $this->assertInstanceOf('Zend\\EventManager\\EventCollection', $events);
     $this->assertInstanceOf('Zend\\EventManager\\EventManager', $events);
 }
开发者ID:rafalwrzeszcz,项目名称:zf2,代码行数:7,代码来源:ApplicationTest.php

示例2: testFinishShouldRunEvenIfDispatchEventReturnsResponse

 /**
  * @group ZF2-171
  */
 public function testFinishShouldRunEvenIfDispatchEventReturnsResponse()
 {
     $app = new Application();
     $response = $app->getResponse();
     $events = $app->events();
     $events->clearListeners('route');
     $events->attach('dispatch', function ($e) use($response) {
         return $response;
     }, 100);
     $token = new stdClass();
     $events->attach('finish', function ($e) use($token) {
         $token->foo = 'bar';
     });
     $app->run();
     $this->assertTrue(isset($token->foo));
     $this->assertEquals('bar', $token->foo);
 }
开发者ID:navtis,项目名称:xerxes-pazpar2,代码行数:20,代码来源:ApplicationTest.php

示例3: setupView

 /**
  * Sets up the view integration
  *
  * Pulls the View object and PhpRenderer strategy from the locator, and 
  * attaches the former to the latter. Then attaches the 
  * DefaultRenderingStrategy to the application event manager.
  * 
  * @param  Application $application 
  * @return void
  */
 protected function setupView($application)
 {
     // Basic view strategy
     $locator = $application->getLocator();
     $events = $application->events();
     $staticEvents = StaticEventManager::getInstance();
     $view = $locator->get('Zend\\View\\View');
     $phpRendererStrategy = $locator->get('Zend\\View\\Strategy\\PhpRendererStrategy');
     $defaultViewStrategy = $locator->get('Zend\\Mvc\\View\\DefaultRenderingStrategy');
     $view->events()->attachAggregate($phpRendererStrategy);
     $events->attachAggregate($defaultViewStrategy);
     // Error strategies
     $noRouteStrategy = $locator->get('Zend\\Mvc\\View\\RouteNotFoundStrategy');
     $exceptionStrategy = $locator->get('Zend\\Mvc\\View\\ExceptionStrategy');
     $events->attachAggregate($noRouteStrategy);
     $events->attachAggregate($exceptionStrategy);
     // Template/ViewModel listeners
     $arrayListener = $locator->get('Zend\\Mvc\\View\\CreateViewModelFromArrayListener');
     $injectTemplateListener = $locator->get('Zend\\Mvc\\View\\InjectTemplateListener');
     $injectViewModelListener = $locator->get('Zend\\Mvc\\View\\InjectViewModelListener');
     $staticEvents->attach('Zend\\Stdlib\\Dispatchable', 'dispatch', array($arrayListener, 'createViewModelFromArray'), -80);
     $staticEvents->attach('Zend\\Stdlib\\Dispatchable', 'dispatch', array($injectTemplateListener, 'injectTemplate'), -90);
     $events->attach('dispatch.error', array($injectViewModelListener, 'injectViewModel'), -100);
     $staticEvents->attach('Zend\\Stdlib\\Dispatchable', 'dispatch', array($injectViewModelListener, 'injectViewModel'), -100);
     // Inject MVC Event with view model
     $mvcEvent = $application->getMvcEvent();
     $viewModel = $mvcEvent->getViewModel();
     $viewModel->setTemplate($defaultViewStrategy->getLayoutTemplate());
     // Inject MVC Event view model as root view model
     $renderer = $phpRendererStrategy->getRenderer();
     $modelHelper = $renderer->plugin('view_model');
     $modelHelper->setRoot($viewModel);
 }
开发者ID:navtis,项目名称:xerxes-pazpar2,代码行数:43,代码来源:Bootstrap.php


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