示例#1
0
 /**
  * Fixes the event stop time.
  *
  * @param \Es\Events\EventInterface $event The event
  */
 public function captureStop(EventInterface $event)
 {
     $time = microtime(true);
     $eventName = $event->getName();
     if ($eventName && isset($this->timers[$eventName])) {
         $this->timers[$eventName]['stop'] = $time;
         return;
     }
     $this->timers[$this->index]['stop'] = $time;
 }
示例#2
0
 /**
  * Gets the triggers for the currently event.
  *
  * @param EventInterface $event The event
  *
  * @return array
  */
 protected function getTriggers(EventInterface $event)
 {
     $eventName = $event->getName();
     $eventClass = get_class($event);
     $search = [];
     if (isset($this->events[$eventName])) {
         $search[] = $this->events[$eventName];
     }
     if (isset($this->events[$eventClass])) {
         $search[] = $this->events[$eventClass];
     }
     $parent = $event;
     while ($parent = get_parent_class($parent)) {
         if (isset($this->events[$parent])) {
             $search[] = $this->events[$parent];
         }
     }
     if (empty($search)) {
         return $search;
     }
     $triggers = call_user_func_array('array_merge_recursive', $search);
     krsort($triggers);
     return call_user_func_array('array_merge', $triggers);
 }