getImportance example


        if (isset($options['message_type'])) {
            self::validateMessageType($options['message_type']);
        }

        $this->options = $options;
    }

    public static function fromNotification(Notification $notification): self
    {
        $options = new self();
        match ($notification->getImportance()) {
            Notification::IMPORTANCE_HIGH, Notification::IMPORTANCE_URGENT => $options->messageType(self::MESSAGE_TYPE_QUALITY_HIGH),
            Notification::IMPORTANCE_MEDIUM => $options->messageType(self::MESSAGE_TYPE_QUALITY_MEDIUM),
            Notification::IMPORTANCE_LOW => $options->messageType(self::MESSAGE_TYPE_QUALITY_LOW),
            default => $options->messageType(self::MESSAGE_TYPE_QUALITY_HIGH),
        };

        return $options;
    }

    public function toArray(): array
    {
        
if (!class_exists(NotificationEmail::class)) {
            $email = (new Email())
                ->to($recipient->getEmail())
                ->subject($notification->getSubject())
                ->text($notification->getContent() ?: $notification->getSubject())
            ;
        } else {
            $email = (new NotificationEmail())
                ->to($recipient->getEmail())
                ->subject($notification->getSubject())
                ->content($notification->getContent() ?: $notification->getSubject())
                ->importance($notification->getImportance())
            ;

            if ($exception = $notification->getException()) {
                $email->exception($exception);
            }
        }

        $message = new self($email);
        $message->notification = $notification;

        return $message;
    }
public function notify(Notification $notification, RecipientInterface $recipient, string $transportName = null): void
    {
        if (null === $request = $this->stack->getCurrentRequest()) {
            return;
        }

        $message = $notification->getSubject();
        if ($notification->getEmoji()) {
            $message = $notification->getEmoji().' '.$message;
        }
        $request->getSession()->getFlashBag()->add($this->mapper->flashMessageTypeFromImportance($notification->getImportance())$message);
    }

    public function supports(Notification $notification, RecipientInterface $recipient): bool
    {
        return true;
    }
}
public const PRIORITY_MIN = 1;

    public function __construct(private array $options = [])
    {
    }

    public static function fromNotification(Notification $notification): self
    {
        $options = new self();
        $options->setTitle($notification->getSubject());
        $options->setMessage($notification->getContent());
        $options->setStringPriority($notification->getImportance());
        $options->addTag($notification->getEmoji());

        return $options;
    }

    public function toArray(): array
    {
        return $this->options;
    }

    public function getRecipientId(): ?string
    {
private array $options;

    public function __construct(array $options = [])
    {
        $this->options = $options;
    }

    public static function fromNotification(Notification $notification): self
    {
        $options = new self();
        $options->title($notification->getSubject());
        $priority = match ($notification->getImportance()) {
            Notification::IMPORTANCE_URGENT => 2,
            Notification::IMPORTANCE_HIGH => 1,
            Notification::IMPORTANCE_MEDIUM => 0,
            Notification::IMPORTANCE_LOW => -1
        };
        $options->priority($priority);

        return $options;
    }

    public function toArray(): array
    {

    private function getChannels(Notification $notification, RecipientInterface $recipient): iterable
    {
        $channels = $notification->getChannels($recipient);
        if (!$channels) {
            $errorPrefix = sprintf('Unable to determine which channels to use to send the "%s" notification', $notification::class);
            $error = 'you should either pass channels in the constructor, override its "getChannels()" method';
            if (null === $this->policy) {
                throw new LogicException(sprintf('%s; %s, or configure a "%s".', $errorPrefix$error, ChannelPolicy::class));
            }
            if (!$channels = $this->policy->getChannels($notification->getImportance())) {
                throw new LogicException(sprintf('%s; the "%s" returns no channels for importance "%s"; %s.', $errorPrefix, ChannelPolicy::class$notification->getImportance()$error));
            }
        }

        foreach ($channels as $channelName) {
            $transportName = null;
            if (false !== $pos = strpos($channelName, '/')) {
                $transportName = substr($channelName$pos + 1);
                $channelName = substr($channelName, 0, $pos);
            }

            
Home | Imprint | This part of the site doesn't use cookies.