本文整理汇总了PHP中Zend\EventManager\EventManager::getEvents方法的典型用法代码示例。如果您正苦于以下问题:PHP EventManager::getEvents方法的具体用法?PHP EventManager::getEvents怎么用?PHP EventManager::getEvents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\EventManager\EventManager
的用法示例。
在下文中一共展示了EventManager::getEvents方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getListeners
/**
* {@inheritDoc}
*/
public function getListeners($eventName = null)
{
if (is_null($eventName)) {
$listeners = array();
foreach ($this->eventManager->getEvents() as $eventName) {
$listeners[$eventName] = $this->getListeners($eventName);
}
return $listeners;
}
return $this->eventManager->getListeners($eventName)->toArray();
}
示例2: index05Action
public function index05Action()
{
$eventManagerOne = new \Zend\EventManager\EventManager();
$eventManagerTwo = new \Zend\EventManager\EventManager();
$eventManagerOne->attach("eventOne", function () {
echo "<h3 style='color:red;font-weight:bold'>eventManagerOne - eventOne - Do 1</h3>";
});
$eventManagerOne->attach("eventOne", function () {
echo "<h3 style='color:red;font-weight:bold'>eventManagerOne - eventOne - Do 2</h3>";
});
$eventManagerOne->attach("eventTwo", function () {
echo "<h3 style='color:red;font-weight:bold'>eventManagerOne - eventTwo - Do 2</h3>";
});
$eventManagerTwo->attach("eventOne", function () {
echo "<h3 style='color:red;font-weight:bold'>eventManagerTwo - evenOne - Do 1</h3>";
});
$eventManagerTwo->attach("eventOne", function () {
echo "<h3 style='color:red;font-weight:bold'>eventManagerTwo - evenOne - Do 2</h3>";
});
// echo "<pre style='font-weight:bold'>";
// print_r($eventManagerOne->getEvents());
// echo "</pre>";
$eventManagerTwo->trigger("eventOne");
$listEventOne = $eventManagerOne->getEvents();
echo "<pre style='font-weight:bold'>";
print_r($listEventOne);
echo "</pre>";
return false;
}
示例3: getEventsFromEventManager
/**
* Retrieve a list of event names from an event manager.
*
* @param EventManager $events
* @return string[]
*/
private function getEventsFromEventManager(EventManager $events)
{
return $events->getEvents();
}