Ejemplo n.º 1
0
 /**
  * Publishes an event to all the listeners listening to the specified event for the specified resource
  *
  * @param w2p_System_Event $event
  * @return Dispatcher
  */
 public function publish(w2p_System_Event $event)
 {
     $resourceName = $event->getResourceName();
     $eventName = $event->getEventName();
     //Loop through all the wildcard handlers
     if (isset($this->_listeners['*']['*'])) {
         foreach ($this->_listeners['*']['*'] as $listener) {
             $listener->publish($event);
         }
     }
     //Dispatch wildcard Resources
     //These are events that are published no matter what the resource
     if (isset($this->_listeners['*'])) {
         foreach ($this->_listeners['*'] as $event => $listeners) {
             if ($event == $eventName) {
                 foreach ($listeners as $listener) {
                     $listener->publish($event);
                 }
             }
         }
     }
     //Dispatch wildcard Events
     //these are listeners that are dispatched for a certain resource, despite the event
     if (isset($this->_listeners[$resourceName]['*'])) {
         foreach ($this->_listeners[$resourceName]['*'] as $listener) {
             $listener->publish($event);
         }
     }
     //Dispatch to a certain resource event
     if (isset($this->_listeners[$resourceName][$eventName])) {
         foreach ($this->_listeners[$resourceName][$eventName] as $listener) {
             $listener->publish($event);
         }
     }
     return $this;
 }
Ejemplo n.º 2
0
 public function __construct($resourceName, $eventName, $data = null)
 {
     parent::__construct($resourceName, $eventName, $data);
     trigger_error(get_class($this) . " has been deprecated in v3.1 and will be removed by v4.0. Please use " . get_parent_class($this) . " instead.", E_USER_NOTICE);
 }
Ejemplo n.º 3
0
 public function publish(w2p_System_Event $event)
 {
     $hook = substr($event->getEventName(), 0, -5);
     switch ($hook) {
         case 'preStore':
         case 'postStore':
         case 'preCreate':
         case 'postCreate':
         case 'preUpdate':
         case 'postCreate':
         case 'preUpdate':
         case 'postUpdate':
         case 'preLoad':
         case 'postLoad':
         case 'preDelete':
         case 'postDelete':
             $this->{'hook_' . $hook}();
             break;
         default:
             //do nothing
     }
     //error_log("{$event->resourceName} published {$event->eventName} with id: " . $this->{$this->_tbl_key});
 }