當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Dispatcher::firing方法代碼示例

本文整理匯總了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);
 }
開發者ID:sethathay,項目名稱:PPBakery,代碼行數:35,代碼來源:EventCollector.php

示例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);
         }
     });
 }
開發者ID:itvisionsy,項目名稱:laravel-extras,代碼行數:11,代碼來源:ModelObserverServiceProvider.php

示例3: firing

 /**
  * Get the event that is currently firing.
  *
  * @return string 
  * @static 
  */
 public static function firing()
 {
     return \Illuminate\Events\Dispatcher::firing();
 }
開發者ID:satriashp,項目名稱:tour,代碼行數:10,代碼來源:_ide_helper.php


注:本文中的Illuminate\Events\Dispatcher::firing方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。