AdminAlertManager
in package
Sends a single admin alert (admin bell, recipient = all administrators).
One shared place for "something happened that a person must resolve by hand" cases (a paid payment without activation, a complaint return pointing at a canceled invoice): look up the active type by key, then store a Notification.
Best effort: a missing type is skipped silently (returns false) and an error is only logged, because
an alert must never crash the process that sends it. $once allows at most one notification per
(type, target id), even a read one, until the read-notification retention deletes it.
Table of Contents
Constants
- LOG_CHANNEL : string = 'notifications'
Properties
- $connection : Connection
- $notificationManager : NotificationManager
- $notificationTypeManager : NotificationTypeManager
Methods
- __construct() : mixed
- send() : bool
- exists() : bool
- resolveTypeId() : int|null
Constants
LOG_CHANNEL
private
string
LOG_CHANNEL
= 'notifications'
Properties
$connection read-only
private
Connection
$connection
$notificationManager read-only
private
NotificationManager
$notificationManager
$notificationTypeManager read-only
private
NotificationTypeManager
$notificationTypeManager
Methods
__construct()
public
__construct(Connection $connection, NotificationManager $notificationManager, NotificationTypeManager $notificationTypeManager) : mixed
Parameters
- $connection : Connection
- $notificationManager : NotificationManager
- $notificationTypeManager : NotificationTypeManager
send()
public
send(string $typeKey, int $itemId, string $text[, bool $once = false ]) : bool
Parameters
- $typeKey : string
-
notification type key (
cms_system_notification_types.key) - $itemId : int
-
id of the target record (the bell link points to its admin page)
- $text : string
- $once : bool = false
-
true = nothing is sent when a notification for (type, target) already exists
Return values
bool —true = the notification was created
exists()
private
exists(int $typeId, int $itemId) : bool
Parameters
- $typeId : int
- $itemId : int
Return values
boolresolveTypeId()
private
resolveTypeId(string $typeKey) : int|null
Parameters
- $typeKey : string