Skip to content

Commit

Permalink
gracefully handle missing event dispatchers
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Dec 6, 2019
1 parent 56fac41 commit 214b6bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Expand Up @@ -39,7 +39,11 @@ class SendMessageMiddleware implements MiddlewareInterface
public function __construct(SendersLocatorInterface $sendersLocator, EventDispatcherInterface $eventDispatcher = null)
{
$this->sendersLocator = $sendersLocator;
$this->eventDispatcher = LegacyEventDispatcherProxy::decorate($eventDispatcher);

if (null !== $eventDispatcher) {
$this->eventDispatcher = LegacyEventDispatcherProxy::decorate($eventDispatcher);
}

$this->logger = new NullLogger();
}

Expand Down
6 changes: 5 additions & 1 deletion src/Symfony/Component/Messenger/Worker.php
Expand Up @@ -52,7 +52,11 @@ public function __construct(array $receivers, MessageBusInterface $bus, array $r
$this->receivers = $receivers;
$this->bus = $bus;
$this->retryStrategies = $retryStrategies;
$this->eventDispatcher = LegacyEventDispatcherProxy::decorate($eventDispatcher);

if (null !== $eventDispatcher) {
$this->eventDispatcher = LegacyEventDispatcherProxy::decorate($eventDispatcher);
}

$this->logger = $logger;
}

Expand Down

0 comments on commit 214b6bb

Please sign in to comment.