NotificationSender
class NotificationSender
Traits
Constants
| FAILED_EVENT_DISPATCHED_CONTEXT_KEY |
The context key for tracking whether a NotificationFailed event was already dispatched. Used to prevent double-dispatching when a channel's send() method internally dispatches NotificationFailed and then throws. Stored in coroutine-local Context rather than an instance property because the event dispatcher is process-global in Swoole — a per-instance listener would leak into the persistent $listeners array. The boot-time listener (registered in NotificationServiceProvider) sets this flag; sendToNotifiable() resets it before each attempt. |
Methods
Get a configuration value from an attribute, falling back to a property.
Extract the value from an attribute instance.
Get an instance of the given attribute class from the target class or its parents.
Determine if a property declared on a child class overrides an inherited attribute.
Create a new notification sender instance.
Send the given notification to the given notifiable entities.
Send the given notification immediately.
Get the notifiable's preferred locale for the notification.
Send the given notification to the given notifiable via a channel.
Determine if the notification can be sent.
Queue the given notification instances.
Format the notifiables into a Collection / array if necessary.
Details
in
Localizable at line 15
mixed
withLocale(string|null $locale, Closure $callback)
Run the callback with the given locale.
in
ReadsClassAttributes at line 15
protected mixed
getAttributeValue(object $target, string $attributeClass, string|null $property = null, mixed $default = null)
Get a configuration value from an attribute, falling back to a property.
in
ReadsClassAttributes at line 44
protected mixed
extractAttributeValue(object $instance)
Extract the value from an attribute instance.
in
ReadsClassAttributes at line 54
protected object|null
getAttributeInstance(object $target, string $attributeClass, ReflectionClass|null $declaringClass = null)
Get an instance of the given attribute class from the target class or its parents.
in
ReadsClassAttributes at line 70
protected bool
propertyOverridesAttribute(object $target, ReflectionClass $reflection, string|null $property, ReflectionClass $attributeDeclaringClass)
Determine if a property declared on a child class overrides an inherited attribute.
at line 50
__construct(ChannelManager $manager, Dispatcher $bus, Dispatcher $events, string|null $locale = null)
Create a new notification sender instance.
at line 61
void
send(mixed $notifiables, mixed $notification)
Send the given notification to the given notifiable entities.
at line 74
void
sendNow(mixed $notifiables, mixed $notification, array|null $channels = null)
Send the given notification immediately.
at line 100
protected string|null
preferredLocale(mixed $notifiable, mixed $notification)
Get the notifiable's preferred locale for the notification.
at line 114
protected void
sendToNotifiable(mixed $notifiable, string $id, mixed $notification, string $channel)
Send the given notification to the given notifiable via a channel.
at line 162
protected bool
shouldSendNotification(mixed $notifiable, mixed $notification, string $channel)
Determine if the notification can be sent.
at line 182
protected void
queueNotification(mixed $notifiables, mixed $notification)
Queue the given notification instances.
at line 263
protected array|Collection
formatNotifiables(mixed $notifiables)
Format the notifiables into a Collection / array if necessary.