當前位置: 首頁>>代碼示例>>PHP>>正文


PHP EventManagerInterface::getEvents方法代碼示例

本文整理匯總了PHP中Zend\EventManager\EventManagerInterface::getEvents方法的典型用法代碼示例。如果您正苦於以下問題:PHP EventManagerInterface::getEvents方法的具體用法?PHP EventManagerInterface::getEvents怎麽用?PHP EventManagerInterface::getEvents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend\EventManager\EventManagerInterface的用法示例。


在下文中一共展示了EventManagerInterface::getEvents方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: attachWorkerListeners

 /**
  * @param EventManagerInterface $eventManager
  * @param StrategyPluginManager $listenerPluginManager
  * @param array $strategyConfig
  * @throws RuntimeException
  */
 protected function attachWorkerListeners(EventManagerInterface $eventManager, StrategyPluginManager $listenerPluginManager, array $strategyConfig = [])
 {
     foreach ($strategyConfig as $strategy => $options) {
         // no options given, name stored as value
         if (is_numeric($strategy) && is_string($options)) {
             $strategy = $options;
             $options = [];
         }
         if (!is_string($strategy) || !is_array($options)) {
             continue;
         }
         $priority = null;
         if (isset($options['priority'])) {
             $priority = $options['priority'];
             unset($options['priority']);
         }
         $listener = $listenerPluginManager->get($strategy, $options);
         if (!is_null($priority)) {
             $eventManager->attachAggregate($listener, $priority);
         } else {
             $eventManager->attachAggregate($listener);
         }
     }
     if (!in_array(WorkerEvent::EVENT_BOOTSTRAP, $eventManager->getEvents())) {
         throw new RuntimeException(sprintf("No worker strategy has been registered to respond to the '%s' event.", WorkerEvent::EVENT_BOOTSTRAP));
     }
 }
開發者ID:jackdpeterson,項目名稱:SlmQueue,代碼行數:33,代碼來源:WorkerFactory.php

示例2: getProfile

 protected function getProfile(EventManagerInterface $eventManager, $profile = null)
 {
     $profiles = $this->profiles;
     if (null === $profile) {
         $profile = $this->searchProfiles($eventManager->getIdentifiers());
     } elseif (is_scalar($profile)) {
         if (!array_key_exists($profile, $profiles)) {
             throw new \Exception("Profile '{$profile}' not found");
         }
         $profile = $profiles[$profile];
     }
     $profile = array_merge(array('name' => 'Event Manager', 'identifiers' => array(), 'events' => array(), 'map' => array()), $profile);
     if (empty($profile['events'])) {
         $profile['events'] = $eventManager->getEvents();
     }
     return $profile;
 }
開發者ID:sporkcode,項目名稱:sporktools,代碼行數:17,代碼來源:Events.php


注:本文中的Zend\EventManager\EventManagerInterface::getEvents方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。