Skip to content

Commit

Permalink
bug #23024 [EventDispatcher] Fix ContainerAwareEventDispatcher::hasLi…
Browse files Browse the repository at this point in the history
…steners(null) (nicolas-grekas)

This PR was merged into the 2.7 branch.

Discussion
----------

[EventDispatcher] Fix ContainerAwareEventDispatcher::hasListeners(null)

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Commits
-------

e7c4149 [EventDispatcher] Fix ContainerAwareEventDispatcher::hasListeners(null)
  • Loading branch information
fabpot committed Jun 1, 2017
2 parents 78c4a5f + e7c4149 commit 32f6534
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Expand Up @@ -105,7 +105,7 @@ public function removeListener($eventName, $listener)
public function hasListeners($eventName = null)
{
if (null === $eventName) {
return (bool) count($this->listenerIds) || (bool) count($this->listeners);
return $this->listenerIds || $this->listeners || parent::hasListeners();
}

if (isset($this->listenerIds[$eventName])) {
Expand Down
Expand Up @@ -56,6 +56,7 @@ public function testAddListener()
{
$this->dispatcher->addListener('pre.foo', array($this->listener, 'preFoo'));
$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::postFoo));
$this->assertCount(1, $this->dispatcher->getListeners(self::preFoo));
Expand Down

0 comments on commit 32f6534

Please sign in to comment.