asChatMessage example

use Symfony\Component\Notifier\Recipient\RecipientInterface;

/** * @author Fabien Potencier <fabien@symfony.com> */
class ChatChannel extends AbstractChannel
{
    public function notify(Notification $notification, RecipientInterface $recipient, string $transportName = null): void
    {
        $message = null;
        if ($notification instanceof ChatNotificationInterface) {
            $message = $notification->asChatMessage($recipient$transportName);
        }

        $message ??= ChatMessage::fromNotification($notification);

        if (null !== $transportName) {
            $message->transport($transportName);
        }

        if (null === $this->bus) {
            $this->transport->send($message);
        } else {
            
Home | Imprint | This part of the site doesn't use cookies.