Skip to content

Commit 71ff918

Browse files
matthieudelmasjaviereguiluz
authored andcommitted
Fix documentation symfony notifier
Fix empty notification in ChatMessage when message customization
1 parent 6a36b23 commit 71ff918

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

notifier.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ and its ``asChatMessage()`` method::
697697
use Symfony\Component\Notifier\Message\ChatMessage;
698698
use Symfony\Component\Notifier\Notification\ChatNotificationInterface;
699699
use Symfony\Component\Notifier\Notification\Notification;
700-
use Symfony\Component\Notifier\Recipient\SmsRecipientInterface;
700+
use Symfony\Component\Notifier\Recipient\RecipientInterface;
701701

702702
class InvoiceNotification extends Notification implements ChatNotificationInterface
703703
{
@@ -710,10 +710,11 @@ and its ``asChatMessage()`` method::
710710

711711
public function asChatMessage(RecipientInterface $recipient, string $transport = null): ?ChatMessage
712712
{
713-
// Add a custom emoji if the message is sent to Slack
713+
// Add a custom subject and emoji if the message is sent to Slack
714714
if ('slack' === $transport) {
715-
return (new ChatMessage('You\'re invoiced '.$this->price.' EUR.'))
716-
->emoji('money');
715+
$this->subject('You\'re invoiced '.strval($this->price).' EUR.');
716+
$this->emoji("money");
717+
return ChatMessage::fromNotification($this);
717718
}
718719

719720
// If you return null, the Notifier will create the ChatMessage

0 commit comments

Comments
 (0)