While I was building Duct Frameworks server side with PHP5 I realized I needed some kind of event support for it.
So I created similar approach that ActionScript uses. You can download the class with example from here.
Hopefully this comes in handy for someone else also.
Here is simple example also:
<?php
class mother extends events_observable
{
public function __construct()
{
parent::__construct();
$this->addEventListener(events_event::ONCONSTRUCT, events::delegate($this, 'on_object_constructed'));
}
public function on_object_constructed($target, $args)
{
echo "{$target->name} has born.";
}
}
class child extends events_observable
{
public $name;
public function __construct($name)
{
parent::__construct();
$this->name = $name;
$this->dispatchEvent(new events_event(events_event::ONCONSTRUCT, $this));
}
}
$mother = new mother();
$child = new child('Jack');
?>
