Skip to content

Commit 29483df

Browse files
Fix documentation symfony notifier
Fix empty notification in ChatMessage when message customization
1 parent ec19f5e commit 29483df

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
@@ -658,7 +658,7 @@ and its ``asChatMessage()`` method::
658658
use Symfony\Component\Notifier\Message\ChatMessage;
659659
use Symfony\Component\Notifier\Notification\ChatNotificationInterface;
660660
use Symfony\Component\Notifier\Notification\Notification;
661-
use Symfony\Component\Notifier\Recipient\SmsRecipientInterface;
661+
use Symfony\Component\Notifier\Recipient\RecipientInterface;
662662

663663
class InvoiceNotification extends Notification implements ChatNotificationInterface
664664
{
@@ -671,10 +671,11 @@ and its ``asChatMessage()`` method::
671671

672672
public function asChatMessage(RecipientInterface $recipient, string $transport = null): ?ChatMessage
673673
{
674-
// Add a custom emoji if the message is sent to Slack
674+
// Add a custom subject and emoji if the message is sent to Slack
675675
if ('slack' === $transport) {
676-
return (new ChatMessage('You\'re invoiced '.$this->price.' EUR.'))
677-
->emoji('money');
676+
$this->subject('You\'re invoiced '.strval($this->price).' EUR.');
677+
$this->emoji("money");
678+
return ChatMessage::fromNotification($this);
678679
}
679680

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

0 commit comments

Comments
 (0)