Exemplo n.º 1
0
 /**
  * _registerListeners
  * This is called when you install or enable an addon.
  * It goes through all of the events an addon listens to and addons them to the triggers.
  *
  * @uses GetEventListeners
  * @uses InterspireEvent::listenerRegister
  * @uses InterspireEventException
  *
  * @return Void Doesn't return anything.
  * @throws Throws an InterspireEventException if an event can't be registered. The error and code come from InterspireEventException.
  */
 private function _registerListeners()
 {
     $listeners = $this->GetEventListeners();
     foreach ($listeners as $listener) {
         try {
             InterspireEvent::listenerRegister($listener['eventname'], $listener['trigger_details'], $listener['trigger_file']);
         } catch (Exception $e) {
             throw new Interspire_Addons_Exception($e->getMessage(), Interspire_Addons_Exception::DatabaseError);
         }
     }
 }
 /**
  * RegisterEventListeners
  * Loads all the event listeners used in the system as listed in com/install/events.php.
  *
  * @throws InterspireEventException
  *
  * @return Void Does not return anything.
  */
 public static function RegisterEventListeners()
 {
     require IEM_PATH . '/install/listeners.php';
     foreach ($listeners as $listener) {
         if (!isset($listener[2])) {
             $listener[2] = null;
         }
         list($event, $function, $file) = $listener;
         if (strpos($function, '::') !== false) {
             $function = explode('::', $function);
         }
         if (!InterspireEvent::listenerExists($event, $function, $file)) {
             InterspireEvent::listenerRegister($event, $function, $file);
         }
     }
     // Add IEM_MARKER which will mark the integrity of the listener
     InterspireEvent::eventCreate('IEM_MARKER');
 }
Exemplo n.º 3
0
 /**
  * listen
  * Register a listener to "listen" to this event
  * @param String|Array $listener Listener function
  * @param String|NULL $file File to be included before executing the function (OPTIONAL, dafault = NULL)
  * @param Integer $priority Priority of the listener (1 to 100) (OPTIONAL, default = 50)
  * @return Void Returns nothing
  */
 public function listen($listener, $file = null, $priority = 50)
 {
     if (empty($this->_eventName)) {
         // This peice of code will never be reached if the class has been constructed properly
         die('Please specify the "_eventName" property first in order to use this function');
     }
     return InterspireEvent::listenerRegister($this->_eventName, $listener, $file, $priority);
 }