Esempio n. 1
0
  public function getEventListener($event_name)
  {
    if ( ! isset($this->_event_listeners[$event_name]) )
      $this->_event_listeners[$event_name] = new SplObjectStorage();
    return $this->_event_listeners[$event_name];
  }
}

class Foo
{
  use EventDispatcher;
}


$foo = new Foo;

$f = function($data) {
  var_dump($data);
};

$foo->addEventListener('bar', $f);

$foo->notify('bar', array('a' => 'b'));
$foo->notify('none');

$foo->removeEventListener('bar', $f);
$foo->notify('bar');

$foo->addEventListener('bar', 'count');