Skip to content

Commit

Permalink
Merge branch '4.4' into 5.0
Browse files Browse the repository at this point in the history
* 4.4:
  [Mailer] Minor tweaks in the mailer docs
  [Messenger] Minor tweaks for the main Messenger article
  [Messenger] Added a missing class import
  • Loading branch information
OskarStark committed Dec 14, 2019
2 parents 5da0ab4 + 4d42897 commit 8ab22b1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
1 change: 1 addition & 0 deletions components/messenger.rst
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,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;
Expand Down
7 changes: 5 additions & 2 deletions mailer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ and create an :class:`Symfony\\Component\\Mime\\Email` object::
->text('Sending emails is fun again!')
->html('<p>See Twig integration for better HTML integration!</p>');

$mailer->send($email);
/** @var Symfony\Component\Mailer\SentMessage $sentEmail */
$sentEmail = $mailer->send($email);
// $messageId = $sentEmail->getMessageId();

// ...
}
Expand Down Expand Up @@ -156,7 +158,8 @@ both strings or address objects::

Instead of calling ``->from()`` *every* time you create a new email, you can
create an :doc:`event subscriber </event_dispatcher>` 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::

Expand Down
17 changes: 9 additions & 8 deletions messenger.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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-worker>`. Messenger supports
:ref:`receiving them via a worker <messenger-worker>`. Messenger supports
:ref:`multiple transports <messenger-transports-config>`.

.. note::
Expand Down Expand Up @@ -498,7 +499,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:
Expand Down Expand Up @@ -1229,7 +1230,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::

Expand Down Expand Up @@ -1283,8 +1284,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
Expand Down

0 comments on commit 8ab22b1

Please sign in to comment.