notify() 공개 메소드

Notifies all listeners of a given event.
public notify ( Symfony\Component\EventDispatcher\Event $event ) : Symfony\Component\EventDispatcher\Event
$event Symfony\Component\EventDispatcher\Event An Event instance
리턴 Symfony\Component\EventDispatcher\Event The Event instance
예제 #1
0
 public function testNotify()
 {
     $listener = new Listener();
     $dispatcher = new EventDispatcher();
     $dispatcher->connect('foo', array($listener, 'listenToFoo'));
     $dispatcher->connect('foo', array($listener, 'listenToFooBis'));
     $e = $dispatcher->notify($event = new Event(new \stdClass(), 'foo'));
     $this->assertEquals('listenToFoolistenToFooBis', $listener->getValue(), '->notify() notifies all registered listeners in order');
     $listener->reset();
     $dispatcher = new EventDispatcher();
     $dispatcher->connect('foo', array($listener, 'listenToFooBis'));
     $dispatcher->connect('foo', array($listener, 'listenToFoo'));
     $dispatcher->notify(new Event(new \stdClass(), 'foo'));
     $this->assertEquals('listenToFooBislistenToFoo', $listener->getValue(), '->notify() notifies all registered listeners in order');
 }