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