コード例 #1
0
 public static function dispatchEvent(PhutilEvent $event)
 {
     $instance = self::getInstance();
     $listeners = idx($instance->listeners, $event->getType(), array());
     $global_listeners = idx($instance->listeners, PhutilEventType::TYPE_ALL, array());
     // Merge and deduplicate listeners (we want to send the event to each
     // listener only once, even if it satisfies multiple criteria for the
     // event).
     $listeners = array_merge($listeners, $global_listeners);
     $listeners = mpull($listeners, null, 'getListenerID');
     $profiler = PhutilServiceProfiler::getInstance();
     $profiler_id = $profiler->beginServiceCall(array('type' => 'event', 'kind' => $event->getType(), 'count' => count($listeners)));
     $caught = null;
     try {
         foreach ($listeners as $listener) {
             if ($event->isStopped()) {
                 // Do this first so if someone tries to dispatch a stopped event it
                 // doesn't go anywhere. Silly but less surprising.
                 break;
             }
             $listener->handleEvent($event);
         }
     } catch (Exception $ex) {
         $profiler->endServiceCall($profiler_id, array());
         throw $ex;
     }
     $profiler->endServiceCall($profiler_id, array());
 }
コード例 #2
0
 public function handleEvent(PhutilEvent $event)
 {
     switch ($event->getType()) {
         case PhabricatorEventType::TYPE_UI_DIDRENDERACTIONS:
             $this->handleActionsEvent($event);
             break;
     }
 }
コード例 #3
0
 public function handleEvent(PhutilEvent $event)
 {
     switch ($event->getType()) {
         case PhabricatorEventType::TYPE_UI_WILLRENDERPROPERTIES:
             $this->handlePropertyEvent($event);
             break;
     }
 }
コード例 #4
0
 public function handleEvent(PhutilEvent $event)
 {
     switch ($event->getType()) {
         case PhabricatorEventType::TYPE_UI_DIDRENDERHOVERCARD:
             $this->handleHovercardEvent($event);
             break;
     }
 }
コード例 #5
0
 public function handleEvent(PhutilEvent $event)
 {
     switch ($event->getType()) {
         case PhabricatorEventType::TYPE_EDGE_WILLEDITEDGES:
             return $this->handleWillEditEvent($event);
         case PhabricatorEventType::TYPE_EDGE_DIDEDITEDGES:
             return $this->handleDidEditEvent($event);
     }
 }
コード例 #6
0
 protected function addActionMenuItems(PhutilEvent $event, $items)
 {
     if ($event->getType() !== PhabricatorEventType::TYPE_UI_DIDRENDERACTIONS) {
         throw new Exception(pht('Not an action menu event!'));
     }
     if (!$items) {
         return;
     }
     if (!is_array($items)) {
         $items = array($items);
     }
     $event_actions = $event->getValue('actions');
     foreach ($items as $item) {
         $event_actions[] = $item;
     }
     $event->setValue('actions', $event_actions);
 }
コード例 #7
0
 public static function dispatchEvent(PhutilEvent $event)
 {
     $instance = self::getInstance();
     $listeners = idx($instance->listeners, $event->getType(), array());
     $global_listeners = idx($instance->listeners, PhutilEventType::TYPE_ALL, array());
     // Merge and deduplicate listeners (we want to send the event to each
     // listener only once, even if it satisfies multiple criteria for the
     // event).
     $listeners = array_merge($listeners, $global_listeners);
     $listeners = mpull($listeners, null, 'getListenerID');
     foreach ($listeners as $listener) {
         if ($event->isStopped()) {
             // Do this first so if someone tries to dispatch a stopped event it
             // doesn't go anywhere. Silly but less surprising.
             break;
         }
         $listener->handleEvent($event);
     }
 }
コード例 #8
0
 public function handleEvent(PhutilEvent $event)
 {
     switch ($event->getType()) {
         case PhutilDaemonHandle::EVENT_DID_LAUNCH:
             $this->handleLaunchEvent($event);
             break;
         case PhutilDaemonHandle::EVENT_DID_HEARTBEAT:
             $this->handleHeartbeatEvent($event);
             break;
         case PhutilDaemonHandle::EVENT_DID_LOG:
             $this->handleLogEvent($event);
             break;
         case PhutilDaemonHandle::EVENT_WILL_GRACEFUL:
             $this->handleGracefulEvent($event);
             break;
         case PhutilDaemonHandle::EVENT_WILL_EXIT:
             $this->handleExitEvent($event);
             break;
     }
 }