Esempio n. 1
0
 /**
  * Convenience method to trigger this event.
  * We can set if the event propagation can be stopped. 
  * If no dispatcher is provided will use global dispatcher [Dispatcher::instance()](api/Dispatcher#instance)
  * 
  * @param boolean $allow_stop_propagation Arguments for this event
  * @param Dispatcher $dispatcher Arguments for this event
  */
 public function dispatch($allow_stop_propagation = FALSE, $dispatcher = NULL)
 {
     // print "Event::dispatch\n";
     $dispatcher = $dispatcher == NULL ? Dispatcher::instance() : $dispatcher;
     $dispatcher->dispatch_event($this, $allow_stop_propagation);
 }
Esempio n. 2
0
    };
    $handle1 = function ($e) use(&$result) {
        $result .= " IS";
    };
    $handle2 = function ($e) use(&$result) {
        $result .= " THE";
    };
    $handle3 = function ($e) use(&$result) {
        $result .= "RESULT";
    };
    Dispatcher::instance()->add_listener('render', $handle0, 0);
    Dispatcher::instance()->add_listener('render', $handle1, 1);
    Dispatcher::instance()->add_listener('render', $handle2, 2);
    Dispatcher::instance()->add_listener('render', $handle3, 3);
    $e = new Event('render');
    Dispatcher::instance()->dispatch_event($e);
    fu::equal($expected, $result, "We actually got:\n{$result}");
});
#############################################
# CoreListener:
#
#############################################
fu::test("CoreListener::TBD.", function () {
    // fu::expect_fail('CORELISTENER: TODO');
});
#############################################
# RUN IT!
# $ php -f tests/test_gdispatcher.php
#############################################
$exit = fu::run();
exit($exit);