From d9fd6a7617cb2d520addf38e38cb371be67f1dc1 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 12 Dec 2019 11:13:37 +0100 Subject: [PATCH 1/3] [Messenger] Added a missing class import --- components/messenger.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/components/messenger.rst b/components/messenger.rst index ba7acf6da49..fa4b4a7d81b 100644 --- a/components/messenger.rst +++ b/components/messenger.rst @@ -163,6 +163,7 @@ Instead of dealing directly with the messages in the middleware you receive the Hence you can inspect the envelope content and its stamps, or add any:: use App\Message\Stamp\AnotherStamp; + use Symfony\Component\Messenger\Envelope; use Symfony\Component\Messenger\Middleware\MiddlewareInterface; use Symfony\Component\Messenger\Middleware\StackInterface; use Symfony\Component\Messenger\Stamp\ReceivedStamp; From 70503a75fbdc998bd7344131dca329e2f48c2ac1 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 12 Dec 2019 15:54:02 +0100 Subject: [PATCH 2/3] [Messenger] Minor tweaks for the main Messenger article --- messenger.rst | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/messenger.rst b/messenger.rst index 533482d957e..ad8732691b5 100644 --- a/messenger.rst +++ b/messenger.rst @@ -50,9 +50,10 @@ serialized:: .. _messenger-handler: -A message handler is a PHP callable, the recommended way to create it is to create a class that -implements ``MessageHandlerInterface`` and has an ``__invoke()`` method that's -type-hinted with the message class (or a message interface):: +A message handler is a PHP callable, the recommended way to create it is to +create a class that implements :class:`Symfony\\Component\\Messenger\\Handler\\MessageHandlerInterface` +and has an ``__invoke()`` method that's type-hinted with the message class (or a +message interface):: // src/MessageHandler/SmsNotificationHandler.php namespace App\MessageHandler; @@ -111,7 +112,7 @@ Transports: Async/Queued Messages By default, messages are handled as soon as they are dispatched. If you want to handle a message asynchronously, you can configure a transport. A transport is capable of sending messages (e.g. to a queueing system) and then -:ref:`receiving them via a worker`. Messenger supports +:ref:`receiving them via a worker `. Messenger supports :ref:`multiple transports `. .. note:: @@ -503,7 +504,7 @@ different messages to them. For example: # queue_name is specific to the doctrine transport queue_name: high - # for amqp send to a separate exchange then queue + # for AMQP send to a separate exchange then queue #exchange: # name: high #queues: @@ -1240,7 +1241,7 @@ Envelopes & Stamps ~~~~~~~~~~~~~~~~~~ A message can be any PHP object. Sometimes, you may need to configure something -extra about the message - like the way it should be handled inside Amqp or adding +extra about the message - like the way it should be handled inside AMQP or adding a delay before the message should be handled. You can do that by adding a "stamp" to your message:: @@ -1294,8 +1295,8 @@ for each bus looks like this: .. note:: - These middleware names are actually shortcuts names. The real service ids - are prefixed with ``messenger.middleware.``. + These middleware names are actually shortcut names. The real service ids + are prefixed with ``messenger.middleware.`` (e.g. ``messenger.middleware.handle_message``). The middleware are executed when the message is dispatched but *also* again when a message is received via the worker (for messages that were sent to a transport From 403cc509d3823b3cefd56fa9bc4019f3f0c1b223 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 12 Dec 2019 17:50:44 +0100 Subject: [PATCH 3/3] [Mailer] Minor tweaks in the mailer docs --- mailer.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mailer.rst b/mailer.rst index aecb585eb87..4d54c3bef00 100644 --- a/mailer.rst +++ b/mailer.rst @@ -121,7 +121,9 @@ and create an :class:`Symfony\\Component\\Mime\\Email` object:: ->text('Sending emails is fun again!') ->html('

See Twig integration for better HTML integration!

'); - $mailer->send($email); + /** @var Symfony\Component\Mailer\SentMessage $sentEmail */ + $sentEmail = $mailer->send($email); + // $messageId = $sentEmail->getMessageId(); // ... } @@ -157,7 +159,8 @@ both strings or address objects:: Instead of calling ``->from()`` *every* time you create a new email, you can create an :doc:`event subscriber ` and listen to the - ``MessageEvent::class`` event to set the same ``From`` email to all messages. + :class:`Symfony\\Component\\Mailer\\Event\\MessageEvent` event to set the + same ``From`` email to all messages. Multiple addresses are defined with the ``addXXX()`` methods::