[EventDispatcher] added a way to disconnect all listeners for an event name

This commit is contained in:
Fabien Potencier 2010-09-01 11:10:31 +02:00
parent ebae1d7bf2
commit 2d04ca3443

View File

@ -40,12 +40,12 @@ class EventDispatcher
/** /**
* Disconnects a listener for a given event name. * Disconnects a listener for a given event name.
* *
* @param string $name An event name * @param string $name An event name
* @param mixed $listener A PHP callable * @param mixed|null $listener A PHP callable or null to disconnect all listeners
* *
* @return mixed false if listener does not exist, null otherwise * @return mixed false if listener does not exist, null otherwise
*/ */
public function disconnect($name, $listener) public function disconnect($name, $listener = null)
{ {
if (!isset($this->listeners[$name])) { if (!isset($this->listeners[$name])) {
return false; return false;