The PHP code:
<?php
echo 'The PHP code:<br />';
highlight_file(__FILE__);
require 
'../bootstrap-stubbles.php';
stubClassLoader::load('net::stubbles::events::events',
                      
'net::stubbles::ipo::request::stubWebRequest'
);
class 
ExampleListener extends stubBaseObject implements stubEventListener
{
    
/**
     * handles the event
     *
     * @param  stubEvent  $event  event that triggered this event listener
     */
    
public function handleEvent(stubEvent $event)
    {
        if (
$event->getName() == 'onRequestCreated' && $event->getContext() instanceof stubRequest) {
            echo 
'<br /><br />Received stubRequest.';
        } else {
            echo 
'<br /><br />Did not receive stubRequest.';
        }
    }

    
/**
     * returns true if listener should be removed after first notification or not
     *
     * @return  bool
     */
    
public function autoremove()
    {
        return 
true;
    }
}
class 
Bootstrap
{
    public static function 
main()
    {
        
// get an instance of the event dispatcher
        
$eventDispatcher stubEventDispatcher::getInstance();

        
$request = new stubWebRequest();
        
// we trigger the event before the listener is registered but the
        // fourth parameter says that the event should be queued and all
        // listeners registered for this event subsequently will be notified
        
$eventDispatcher->trigger('onRequestCreated'$request, array(), true);

        
// now we register the listener that will be notified instantly
        
$eventDispatcher->register(new ExampleListener(), 'onRequestCreated');
    }
}
Bootstrap::main();
?>


Received stubRequest.