[EventDispatcher] Fix ContainerAwareEventDispatcher::hasListeners(null)
This commit is contained in:
parent
78c4a5ff43
commit
e7c4149e78
@ -105,7 +105,7 @@ class ContainerAwareEventDispatcher extends EventDispatcher
|
|||||||
public function hasListeners($eventName = null)
|
public function hasListeners($eventName = null)
|
||||||
{
|
{
|
||||||
if (null === $eventName) {
|
if (null === $eventName) {
|
||||||
return (bool) count($this->listenerIds) || (bool) count($this->listeners);
|
return $this->listenerIds || $this->listeners || parent::hasListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($this->listenerIds[$eventName])) {
|
if (isset($this->listenerIds[$eventName])) {
|
||||||
|
@ -56,6 +56,7 @@ abstract class AbstractEventDispatcherTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->dispatcher->addListener('pre.foo', array($this->listener, 'preFoo'));
|
$this->dispatcher->addListener('pre.foo', array($this->listener, 'preFoo'));
|
||||||
$this->dispatcher->addListener('post.foo', array($this->listener, 'postFoo'));
|
$this->dispatcher->addListener('post.foo', array($this->listener, 'postFoo'));
|
||||||
|
$this->assertTrue($this->dispatcher->hasListeners());
|
||||||
$this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
|
$this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
|
||||||
$this->assertTrue($this->dispatcher->hasListeners(self::postFoo));
|
$this->assertTrue($this->dispatcher->hasListeners(self::postFoo));
|
||||||
$this->assertCount(1, $this->dispatcher->getListeners(self::preFoo));
|
$this->assertCount(1, $this->dispatcher->getListeners(self::preFoo));
|
||||||
|
Reference in New Issue
Block a user