Example #1
0
 function testIndependentTriggers()
 {
     $manager = new Tiki_Event_Manager();
     $manager->bind('tiki.wiki.update', 'tiki.wiki.save');
     $manager->bind('tiki.wiki.save', 'tiki.save');
     $manager->bindPriority(10, 'tiki.save', array($this, 'callbackAdd'));
     $manager->bind('tiki.wiki.save', array($this, 'callbackMultiply'));
     $manager->bind('tiki.wiki.update', array($this, 'callbackMultiply'));
     $manager->bindPriority(5, 'tiki.test.foo', function () use($manager) {
         $manager->trigger('tiki.wiki.update');
     });
     $manager->trigger('tiki.test.foo');
     $this->assertEquals(1, $this->called);
 }
Example #2
0
 /**
  * Store the dirty flags at the end of the request and restore them when opening the
  * connection within a single user session so that if a modification requires re-indexing,
  * the next page load will wait until indexing is done to show the results.
  */
 function persistDirty(Tiki_Event_Manager $events)
 {
     if (isset($_SESSION['elastic_search_dirty'])) {
         $this->dirty = $_SESSION['elastic_search_dirty'];
         unset($_SESSION['elastic_search_dirty']);
     }
     // Before the HTTP request is closed
     $events->bind('tiki.process.redirect', function () {
         $_SESSION['elastic_search_dirty'] = $this->dirty;
     });
 }
Example #3
0
 function bind(Tiki_Event_Manager $manager, Math_Formula_Runner $runner)
 {
     foreach ($this->ruleSets as $eventName => $ruleSet) {
         $manager->bind($eventName, new Tiki_Event_Customizer_Executor($ruleSet, $runner));
     }
 }
Example #4
0
 /**
  * Bind all events required to process notifications.
  * One event is bound per active event type to collect the
  * notifications to be sent out. A final event is sent out on
  * shutdown to process the queued notifications.
  */
 function bindEvents(Tiki_Event_Manager $events)
 {
     $events->bind('tiki.process.shutdown', function () {
         $this->finalEvent();
     });
     $db = TikiDb::get();
     $list = $db->fetchAll('SELECT DISTINCT event FROM tiki_user_monitors', null, -1, -1, TikiDb::ERR_NONE);
     // Ignore errors to avoid locking out users
     if ($list) {
         foreach ($list as $row) {
             $event = $row['event'];
             $events->bind($event, function ($args, $originalEvent) use($event) {
                 $this->handleEvent($args, $originalEvent, $event);
             });
         }
     }
 }