From 71ff91826d1113dc981c5687a8629714cc00cee5 Mon Sep 17 00:00:00 2001 From: matthieudelmas <95386861+matthieudelmas@users.noreply.github.com> Date: Wed, 22 Jun 2022 12:38:15 +0200 Subject: [PATCH] Fix documentation symfony notifier Fix empty notification in ChatMessage when message customization --- notifier.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/notifier.rst b/notifier.rst index d015af8e94b..b6a76ad86a1 100644 --- a/notifier.rst +++ b/notifier.rst @@ -697,7 +697,7 @@ and its ``asChatMessage()`` method:: use Symfony\Component\Notifier\Message\ChatMessage; use Symfony\Component\Notifier\Notification\ChatNotificationInterface; use Symfony\Component\Notifier\Notification\Notification; - use Symfony\Component\Notifier\Recipient\SmsRecipientInterface; + use Symfony\Component\Notifier\Recipient\RecipientInterface; class InvoiceNotification extends Notification implements ChatNotificationInterface { @@ -710,10 +710,11 @@ and its ``asChatMessage()`` method:: public function asChatMessage(RecipientInterface $recipient, string $transport = null): ?ChatMessage { - // Add a custom emoji if the message is sent to Slack + // Add a custom subject and emoji if the message is sent to Slack if ('slack' === $transport) { - return (new ChatMessage('You\'re invoiced '.$this->price.' EUR.')) - ->emoji('money'); + $this->subject('You\'re invoiced '.strval($this->price).' EUR.'); + $this->emoji("money"); + return ChatMessage::fromNotification($this); } // If you return null, the Notifier will create the ChatMessage