本文整理汇总了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();
}
示例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;
});
}
示例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);
}
示例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;
}