本文整理汇总了PHP中Illuminate\Events\Dispatcher::firing方法的典型用法代码示例。如果您正苦于以下问题:PHP Dispatcher::firing方法的具体用法?PHP Dispatcher::firing怎么用?PHP Dispatcher::firing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Events\Dispatcher
的用法示例。
在下文中一共展示了Dispatcher::firing方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: subscribe
public function subscribe(Dispatcher $events)
{
$events->listen('eloquent.*', function ($model) use($events) {
$event = array_get(explode(".", array_get(explode(":", $events->firing()), 0)), 1);
$file = app_path('observers/' . get_class($model) . 'Observer.php');
if (file_exists($file)) {
$class = get_class($model) . "Observer";
return (new $class())->fire($event, $model);
}
});
}
示例3: firing
/**
* Get the event that is currently firing.
*
* @return string
* @static
*/
public static function firing()
{
return \Illuminate\Events\Dispatcher::firing();
}