CoolCMS API

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

Properties

Methods

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
bool

resolveTypeId()

private resolveTypeId(string $typeKey) : int|null
Parameters
$typeKey : string
Return values
int|null
On this page

Search results