本文整理匯總了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));
}
}
示例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;
}