Skip to content

Commit d38cd0e

Browse files
committed
Merge remote-tracking branch 'upstream/7.3' into 7.3
* upstream/7.3: Minor tweak Messenger: custom consumer name with systemd Minor tweaks [Mailer] Mention the SentMessageEvent and FailedMessageEvent in the debug section [Form] Update enum.rst: Adding `choice_label` Minor tweak [Messenger] Add a tip about using `make:messenger-middleware`
2 parents b87ec8b + c69676a commit d38cd0e

File tree

3 files changed

+46
-7
lines changed

3 files changed

+46
-7
lines changed

mailer.rst

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,8 @@ Catch that exception to recover from the error or to display some message::
876876
// error message or try to resend the message
877877
}
878878

879+
.. _mailer-debugging-emails:
880+
879881
Debugging Emails
880882
----------------
881883

@@ -885,6 +887,10 @@ provides access to the original message (``getOriginalMessage()``) and to some
885887
debug information (``getDebug()``) such as the HTTP calls done by the HTTP
886888
transports, which is useful to debug errors.
887889

890+
You can also access :class:`Symfony\\Component\\Mailer\\SentMessage` by listening
891+
to the :ref:`SentMessageEvent <mailer-sent-message-event>` and retrieve ``getDebug()``
892+
by listening to the :ref:`FailedMessageEvent <mailer-failed-message-event>`.
893+
888894
.. note::
889895

890896
If your code used :class:`Symfony\\Component\\Mailer\\MailerInterface`, you
@@ -1753,24 +1759,26 @@ and their priorities:
17531759
17541760
$ php bin/console debug:event-dispatcher "Symfony\Component\Mailer\Event\MessageEvent"
17551761
1762+
.. _mailer-sent-message-event:
1763+
17561764
SentMessageEvent
17571765
~~~~~~~~~~~~~~~~
17581766

17591767
**Event Class**: :class:`Symfony\\Component\\Mailer\\Event\\SentMessageEvent`
17601768

17611769
``SentMessageEvent`` allows you to act on the :class:`Symfony\\Component\\\Mailer\\\SentMessage`
1762-
class to access the original message (``getOriginalMessage()``) and some debugging
1763-
information (``getDebug()``) such as the HTTP calls made by the HTTP transports,
1764-
which is useful for debugging errors::
1770+
class to access the original message (``getOriginalMessage()``) and some
1771+
:ref:`debugging information <mailer-debugging-emails>` (``getDebug()``) such as
1772+
the HTTP calls made by the HTTP transports, which is useful for debugging errors::
17651773

17661774
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
17671775
use Symfony\Component\Mailer\Event\SentMessageEvent;
17681776

17691777
public function onMessage(SentMessageEvent $event): void
17701778
{
1771-
$message = $event->getMessage();
1779+
$message $event->getMessage();
17721780

1773-
// do something with the message
1781+
// do something with the message (e.g. get its id)
17741782
}
17751783

17761784
Execute this command to find out which listeners are registered for this event
@@ -1780,20 +1788,28 @@ and their priorities:
17801788
17811789
$ php bin/console debug:event-dispatcher "Symfony\Component\Mailer\Event\SentMessageEvent"
17821790
1791+
.. _mailer-failed-message-event:
1792+
17831793
FailedMessageEvent
17841794
~~~~~~~~~~~~~~~~~~
17851795

17861796
**Event Class**: :class:`Symfony\\Component\\Mailer\\Event\\FailedMessageEvent`
17871797

1788-
``FailedMessageEvent`` allows acting on the initial message in case of a failure::
1798+
``FailedMessageEvent`` allows acting on the initial message in case of a failure
1799+
and some :ref:`debugging information <mailer-debugging-emails>` (``getDebug()``)
1800+
such as the HTTP calls made by the HTTP transports, which is useful for debugging errors::
17891801

17901802
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
17911803
use Symfony\Component\Mailer\Event\FailedMessageEvent;
1804+
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
17921805

17931806
public function onMessage(FailedMessageEvent $event): void
17941807
{
17951808
// e.g you can get more information on this error when sending an email
1796-
$event->getError();
1809+
$error = $event->getError();
1810+
if ($error instanceof TransportExceptionInterface) {
1811+
$error->getDebug();
1812+
}
17971813

17981814
// do something with the message
17991815
}

messenger.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,8 @@ directory. For example, you can create a new ``messenger-worker.service`` file.
880880
881881
[Service]
882882
ExecStart=php /path/to/your/app/bin/console messenger:consume async --time-limit=3600
883+
# for Redis, set a custom consumer name for each instance
884+
Environment="MESSENGER_CONSUMER_NAME=symfony-%n-%i"
883885
Restart=always
884886
RestartSec=30
885887
@@ -2932,6 +2934,11 @@ and a different instance will be created per bus.
29322934
$bus->middleware()->id('App\Middleware\AnotherMiddleware');
29332935
};
29342936
2937+
.. tip::
2938+
2939+
If you have installed the MakerBundle, you can use the ``make:messenger-middleware``
2940+
command to bootstrap the creation your own messenger middleware.
2941+
29352942
.. _middleware-doctrine:
29362943

29372944
Middleware for Doctrine

reference/forms/types/enum.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,22 @@ Inherited Options
9494

9595
These options inherit from the :doc:`ChoiceType </reference/forms/types/choice>`:
9696

97+
.. include:: /reference/forms/types/options/choice_attr.rst.inc
98+
99+
.. include:: /reference/forms/types/options/choice_filter.rst.inc
100+
101+
.. include:: /reference/forms/types/options/choice_label.rst.inc
102+
103+
.. include:: /reference/forms/types/options/choice_loader.rst.inc
104+
105+
.. include:: /reference/forms/types/options/choice_name.rst.inc
106+
107+
.. include:: /reference/forms/types/options/choice_translation_domain_enabled.rst.inc
108+
109+
.. include:: /reference/forms/types/options/choice_translation_parameters.rst.inc
110+
111+
.. include:: /reference/forms/types/options/choice_value.rst.inc
112+
97113
.. include:: /reference/forms/types/options/error_bubbling.rst.inc
98114

99115
.. include:: /reference/forms/types/options/error_mapping.rst.inc

0 commit comments

Comments
 (0)