Skip to content

Commit 4acb30b

Browse files
committed
[bundle] Extend EventDispatcher instead of container aware one.
fixes deprecation note.
1 parent 77124b6 commit 4acb30b

3 files changed

Lines changed: 9 additions & 16 deletions

File tree

‎pkg/enqueue-bundle/Events/ProxyEventDispatcher.php‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
namespace Enqueue\Bundle\Events;
44

5-
use Symfony\Component\DependencyInjection\ContainerInterface;
6-
use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
75
use Symfony\Component\EventDispatcher\Event;
6+
use Symfony\Component\EventDispatcher\EventDispatcher;
87
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
98

10-
class ProxyEventDispatcher extends ContainerAwareEventDispatcher
9+
class ProxyEventDispatcher extends EventDispatcher
1110
{
1211
/**
1312
* @var EventDispatcherInterface
@@ -20,14 +19,11 @@ class ProxyEventDispatcher extends ContainerAwareEventDispatcher
2019
private $asyncListener;
2120

2221
/**
23-
* @param ContainerInterface $container
2422
* @param EventDispatcherInterface $trueEventDispatcher
2523
* @param AsyncListener $asyncListener
2624
*/
27-
public function __construct(ContainerInterface $container, EventDispatcherInterface $trueEventDispatcher, AsyncListener $asyncListener)
25+
public function __construct(EventDispatcherInterface $trueEventDispatcher, AsyncListener $asyncListener)
2826
{
29-
parent::__construct($container);
30-
3127
$this->trueEventDispatcher = $trueEventDispatcher;
3228
$this->asyncListener = $asyncListener;
3329
}

‎pkg/enqueue-bundle/Resources/config/events.yml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ services:
1414
enqueue.events.event_dispatcher:
1515
class: 'Enqueue\Bundle\Events\ProxyEventDispatcher'
1616
arguments:
17-
- '@service_container'
1817
- '@event_dispatcher'
1918
- '@enqueue.events.async_listener'
2019

‎pkg/enqueue-bundle/Tests/Unit/Events/ProxyEventDispatcherTest.php‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,16 @@
66
use Enqueue\Bundle\Events\ProxyEventDispatcher;
77
use Enqueue\Test\ClassExtensionTrait;
88
use PHPUnit\Framework\TestCase;
9-
use Symfony\Component\DependencyInjection\Container;
10-
use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
119
use Symfony\Component\EventDispatcher\EventDispatcher;
1210
use Symfony\Component\EventDispatcher\GenericEvent;
1311

1412
class ProxyEventDispatcherTest extends TestCase
1513
{
1614
use ClassExtensionTrait;
1715

18-
public function testShouldBeSubClassOfContainerAwareEventDispatcher()
16+
public function testShouldBeSubClassOfEventDispatcher()
1917
{
20-
$this->assertClassExtends(ContainerAwareEventDispatcher::class, ProxyEventDispatcher::class);
18+
$this->assertClassExtends(EventDispatcher::class, ProxyEventDispatcher::class);
2119
}
2220

2321
public function testShouldSetSyncModeForGivenEventNameOnDispatchAsyncListenersOnly()
@@ -34,7 +32,7 @@ public function testShouldSetSyncModeForGivenEventNameOnDispatchAsyncListenersOn
3432
;
3533

3634
$trueEventDispatcher = new EventDispatcher();
37-
$dispatcher = new ProxyEventDispatcher(new Container(), $trueEventDispatcher, $asyncListenerMock);
35+
$dispatcher = new ProxyEventDispatcher($trueEventDispatcher, $asyncListenerMock);
3836

3937
$event = new GenericEvent();
4038
$dispatcher->dispatchAsyncListenersOnly('theEvent', $event);
@@ -51,7 +49,7 @@ public function testShouldCallAsyncEventButNotOtherOnDispatchAsyncListenersOnly(
5149
});
5250

5351
$asyncEventWasCalled = false;
54-
$dispatcher = new ProxyEventDispatcher(new Container(), $trueEventDispatcher, $this->createAsyncLisenerMock());
52+
$dispatcher = new ProxyEventDispatcher($trueEventDispatcher, $this->createAsyncLisenerMock());
5553
$dispatcher->addListener('theEvent', function () use (&$asyncEventWasCalled) {
5654
$this->assertInstanceOf(ProxyEventDispatcher::class, func_get_arg(2));
5755

@@ -76,7 +74,7 @@ public function testShouldCallOtherEventIfDispatchedFromAsyncEventOnDispatchAsyn
7674
});
7775

7876
$asyncEventWasCalled = false;
79-
$dispatcher = new ProxyEventDispatcher(new Container(), $trueEventDispatcher, $this->createAsyncLisenerMock());
77+
$dispatcher = new ProxyEventDispatcher($trueEventDispatcher, $this->createAsyncLisenerMock());
8078
$dispatcher->addListener('theEvent', function () use (&$asyncEventWasCalled) {
8179
$this->assertInstanceOf(ProxyEventDispatcher::class, func_get_arg(2));
8280

@@ -99,7 +97,7 @@ public function testShouldNotCallAsyncEventIfDispatchedFromOtherEventOnDispatchA
9997
func_get_arg(2)->dispatch('theOtherAsyncEvent');
10098
});
10199

102-
$dispatcher = new ProxyEventDispatcher(new Container(), $trueEventDispatcher, $this->createAsyncLisenerMock());
100+
$dispatcher = new ProxyEventDispatcher($trueEventDispatcher, $this->createAsyncLisenerMock());
103101
$dispatcher->addListener('theAsyncEvent', function () {
104102
func_get_arg(2)->dispatch('theOtherEvent');
105103
});

0 commit comments

Comments
 (0)