Ejemplo n.º 1
0
 /**
  * This function dispatches an event to all registered plugins.
  * @param PluginEvent $event Object holding all event properties
  * @param string|array $target Optional name of plugin to fire the event on
  * 
  * @return PluginEvent
  */
 public function dispatchEvent(PluginEvent $event, $target = array())
 {
     $eventName = $event->getEventName();
     if (is_string($target)) {
         $target = array($target);
     }
     if (isset($this->subscriptions[$eventName])) {
         foreach ($this->subscriptions[$eventName] as $subscription) {
             if (!$event->isStopped() && (empty($target) || in_array(get_class($subscription[0]), $target))) {
                 $subscription[0]->setEvent($event);
                 call_user_func($subscription);
             }
         }
     }
     return $event;
 }