Skip to content

Commit e4c6ad2

Browse files
committed
Add possibility to pass event dispatcher to EventDrivenCommandGenerator
1 parent 60cc56f commit e4c6ad2

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/EventDrivenCommandGenerator.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,17 @@
1919

2020
final class EventDrivenCommandGenerator extends CommandGenerator
2121
{
22-
private EventDispatcherInterface $eventDispatcher;
2322
private \DateTimeImmutable $timestamp;
2423

25-
public function __construct(SchemaInterface $schema, ContainerInterface $container)
26-
{
27-
$listenerProvider = new ListenerProvider($schema, $container);
28-
29-
$this->eventDispatcher = new Dispatcher($listenerProvider);
24+
public function __construct(
25+
SchemaInterface $schema,
26+
ContainerInterface $container,
27+
private ?EventDispatcherInterface $eventDispatcher = null
28+
) {
29+
if ($eventDispatcher === null) {
30+
$listenerProvider = new ListenerProvider($schema, $container);
31+
$this->eventDispatcher = new Dispatcher($listenerProvider);
32+
}
3033
}
3134

3235
protected function storeEntity(ORMInterface $orm, Tuple $tuple, bool $isNew): ?CommandInterface

0 commit comments

Comments
 (0)