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


PHP EventManager::getSharedManager方法代码示例

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


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

示例1: setUp

 public function setUp()
 {
     $this->varnishOptions = new VarnishOptions();
     $this->varnishOptions->setCacheEnabled(true);
     $this->listener = new InjectCacheHeaderListener($this->varnishOptions);
     $this->listener->setLayoutUpdater(new LayoutUpdater());
     $this->eventManager = new EventManager(new SharedEventManager());
     $this->eventManager->getSharedManager()->clearListeners(InjectCacheHeaderListener::class);
     $this->attachStrategy(DefaultStrategy::class, 100);
     $this->listener->setEventManager($this->eventManager);
     $this->createMvcEvent();
 }
开发者ID:hummer2k,项目名称:convarnish,代码行数:12,代码来源:InjectCacheHeaderListenerTest.php

示例2: setupExceptionLogging

 /**
  * 1. Registers Sentry as exception handler
  * 2. Replaces the default ExceptionStrategy so Exception that are caught by Zend Framework can still be logged
  *
  * @param MvcEvent $event
  */
 protected function setupExceptionLogging(MvcEvent $event)
 {
     // Register Sentry as exception handler for exception that bubble up to the top
     $this->zendSentry->registerExceptionHandler($this->config['zend-sentry']['call-existing-exception-handler']);
     // Replace the default ExceptionStrategy with ZendSentry's strategy
     if ($event->getApplication()->getServiceManager()->has('HttpExceptionStrategy')) {
         /** @var $exceptionStrategy ExceptionStrategy */
         $exceptionStrategy = $event->getApplication()->getServiceManager()->get('HttpExceptionStrategy');
         $exceptionStrategy->detach($this->eventManager);
     }
     // Check if script is running in console
     $exceptionStrategy = PHP_SAPI == 'cli' ? new SentryConsoleStrategy() : new SentryHttpStrategy();
     $exceptionStrategy->attach($this->eventManager);
     $exceptionStrategy->setDisplayExceptions($this->config['zend-sentry']['display-exceptions']);
     $exceptionStrategy->setDefaultExceptionMessage($this->config['zend-sentry'][PHP_SAPI == 'cli' ? 'default-exception-console-message' : 'default-exception-message']);
     $ravenClient = $this->ravenClient;
     // Attach an exception listener for the ZendSentry exception strategy, can be triggered from anywhere else too
     $this->eventManager->getSharedManager()->attach('*', 'logException', function ($event) use($ravenClient) {
         /** @var $event MvcEvent */
         $exception = $event->getParam('exception');
         $tags = $event->getParam('tags', array());
         $eventID = $ravenClient->captureException($exception, array('tags' => $tags));
         return $eventID;
     });
 }
开发者ID:cloud-solutions,项目名称:zend-sentry,代码行数:31,代码来源:Module.php

示例3: testAttach

 public function testAttach()
 {
     $eventManager = new EventManager();
     $eventManager->getSharedManager()->clearListeners('ConLayout\\Updater\\LayoutUpdater');
     $this->listener->attach($eventManager);
     $listeners = $eventManager->getSharedManager()->getListeners('ConLayout\\Updater\\LayoutUpdater', 'getLayoutStructure.pre');
     $this->assertCount(1, $listeners);
 }
开发者ID:adamdyson,项目名称:ConLayout,代码行数:8,代码来源:LayoutUpdateListenerTest.php

示例4: index12Action

 public function index12Action()
 {
     $eventHost = new EventManager();
     $shareEventManager = $eventHost->getSharedManager();
     $shareEventManager->attach("emOne", "eventOne", function ($e) {
         echo "<h3 style='color:red;font-weight:bold'>eventManagerOne - eventOne - Do 1</h3>";
     });
     $shareEventManager->attach(array("emTwo", "emThree"), "eventNew", function ($e) {
         echo "<h3 style='color:red;font-weight:bold'>eventManagerOne - eventNew - Do 1</h3>";
     });
     $eventManager = new EventManager(array("emOne", "emThree"));
     //$eventManager->setSharedManager($shareEventManager);<---không cần thiết xem lại action 10
     $eventManager->trigger("eventOne");
     $eventManager->trigger("eventNew");
     $eventManager = new EventManager("emTwo");
     //$eventManager->setSharedManager($shareEventManager);<---không cần thiết xem lại action 10
     $eventManager->trigger("eventNew");
     return false;
 }
开发者ID:trongle,项目名称:zend-2,代码行数:19,代码来源:EventController.php


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