本文整理汇总了PHP中Illuminate\Events\Dispatcher::getListeners方法的典型用法代码示例。如果您正苦于以下问题:PHP Dispatcher::getListeners方法的具体用法?PHP Dispatcher::getListeners怎么用?PHP Dispatcher::getListeners使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Events\Dispatcher
的用法示例。
在下文中一共展示了Dispatcher::getListeners方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onWildcardEvent
public function onWildcardEvent()
{
$name = $this->events->firing();
$time = microtime(true);
// Get the arguments passed to the event
$params = $this->prepareParams(func_get_args());
// Find all listeners for the current event
foreach ($this->events->getListeners($name) as $i => $listener) {
// Check if it's an object + method name
if (is_array($listener) && count($listener) > 1 && is_object($listener[0])) {
list($class, $method) = $listener;
// Skip this class itself
if ($class instanceof static) {
continue;
}
// Format the listener to readable format
$listener = get_class($class) . '@' . $method;
// Handle closures
} elseif ($listener instanceof \Closure) {
$reflector = new \ReflectionFunction($listener);
// Skip our own listeners
if ($reflector->getNamespaceName() == 'Barryvdh\\Debugbar') {
continue;
}
// Format the closure to a readable format
$filename = ltrim(str_replace(base_path(), '', $reflector->getFileName()), '/');
$listener = $reflector->getName() . ' (' . $filename . ':' . $reflector->getStartLine() . '-' . $reflector->getEndLine() . ')';
} else {
// Not sure if this is possible, but to prevent edge cases
$listener = $this->formatVar($listener);
}
$params['listeners.' . $i] = $listener;
}
$this->addMeasure($name, $time, $time, $params);
}
示例2: getListeners
/**
* Get all of the listeners for a given event name.
*
* @param string $eventName
* @return array
* @static
*/
public static function getListeners($eventName)
{
return \Illuminate\Events\Dispatcher::getListeners($eventName);
}