$senders =
$this->sendersLocator->
getSenders($envelope);
$senders = \
is_array($senders) ?
$senders :
iterator_to_array($senders);
foreach ($senders as $alias =>
$sender) { if (null !==
$this->eventDispatcher &&
$shouldDispatchEvent) { $event =
new SendMessageToTransportsEvent($envelope,
$senders);
$this->eventDispatcher->
dispatch($event);
$envelope =
$event->
getEnvelope();
$shouldDispatchEvent = false;
} $this->logger?->
info('Sending message {class} with {alias} sender using {sender}',
$context +
['alias' =>
$alias, 'sender' =>
$sender::
class]);
$envelope =
$sender->
send($envelope->
with(new SentStamp($sender::
class, \
is_string($alias) ?
$alias : null
)));
} if (!
$this->allowNoSenders && !
$sender) { throw new NoSenderForMessageException(sprintf('No sender for message "%s".',
$context['class'
]));
} } if (null ===
$sender) { return $stack->
next()->
handle($envelope,
$stack);
}