disconnect() public method

Disconnects all listeners for the given event name.
public disconnect ( string $name )
$name string An event name
Ejemplo n.º 1
0
 public function testGetHasListeners()
 {
     $dispatcher = new EventDispatcher();
     $this->assertFalse($dispatcher->hasListeners('foo'), '->hasListeners() returns false if the event has no listener');
     $dispatcher->connect('foo', 'listenToFoo');
     $this->assertEquals(true, $dispatcher->hasListeners('foo'), '->hasListeners() returns true if the event has some listeners');
     $dispatcher->disconnect('foo', 'listenToFoo');
     $this->assertFalse($dispatcher->hasListeners('foo'), '->hasListeners() returns false if the event has no listener');
     $dispatcher->connect('bar', 'listenToBar');
     $this->assertEquals(array('listenToBar'), $dispatcher->getListeners('bar'), '->getListeners() returns an array of listeners connected to the given event name');
     $this->assertEquals(array(), $dispatcher->getListeners('foobar'), '->getListeners() returns an empty array if no listener are connected to the given event name');
 }
Ejemplo n.º 2
0
 /**
  * {@inheritDoc}
  */
 public function unregister(EventDispatcher $dispatcher)
 {
     $dispatcher->disconnect('core.response', array($this, 'write'));
 }
Ejemplo n.º 3
0
 /**
  * {@inheritDoc}
  */
 public function unregister(EventDispatcher $dispatcher)
 {
     $dispatcher->disconnect('core.exception', array($this, 'handleException'));
 }