NotificationSender
class NotificationSender
Traits
Constants
| FAILED_EVENT_DISPATCHED_CONTEXT_KEY |
The context key for tracking whether a NotificationFailed event was already dispatched. Holds a boolean while a notification-channel attempt is active and is absent otherwise. 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 marks an active attempt when its channel dispatches NotificationFailed before throwing. |
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 21
mixed
withLocale(string|null $locale, Closure $callback)
Run the callback with the given locale.
in
ReadsClassAttributes at line 17
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 46
protected mixed
extractAttributeValue(object $instance)
Extract the value from an attribute instance.
in
ReadsClassAttributes at line 58
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 74
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 51
__construct(ChannelManager $manager, Dispatcher $bus, Dispatcher $events, string|null $locale = null)
Create a new notification sender instance.
at line 62
void
send(mixed $notifiables, mixed $notification)
Send the given notification to the given notifiable entities.
at line 75
void
sendNow(mixed $notifiables, mixed $notification, array|null $channels = null)
Send the given notification immediately.
at line 101
protected string|null
preferredLocale(mixed $notifiable, mixed $notification)
Get the notifiable's preferred locale for the notification.
at line 115
protected void
sendToNotifiable(mixed $notifiable, string $id, mixed $notification, string $channel)
Send the given notification to the given notifiable via a channel.
at line 185
protected bool
shouldSendNotification(mixed $notifiable, mixed $notification, string $channel)
Determine if the notification can be sent.
at line 205
protected void
queueNotification(mixed $notifiables, mixed $notification)
Queue the given notification instances.
at line 286
protected array|Collection
formatNotifiables(mixed $notifiables)
Format the notifiables into a Collection / array if necessary.