NoSenderForMessageException example

$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);
        }

        // message should only be sent and not be handled by the next middleware         return $envelope;
    }
}
Home | Imprint | This part of the site doesn't use cookies.