CoolCMS API

ElasticWatchManager
in package

FinalYes

Orchestrates e-mail alerting over the ES integration.

Runs the pure checks EsMonitor::check() and, if after deduplication at least one issue is due for sending (shouldAlert), sends one summary e-mail (not one per issue).

A plain class without a Doctrine entity (like FileSystemManager). It lives in the Api layer, not Core, because it needs EmailManager (SendEmailTrait); Core does not know Api.

Called by the thin action ElasticPresenter::actionWatch(). Fail-open: an e-mail send error is only logged (channel elasticsearch); the monitor report is returned anyway, so the cron never fails because of e-mail.

Table of Contents

Constants

SETTINGS_GROUP  : mixed = 1
SETTINGS_KEY  : mixed = 'email.address'

Properties

$emailManager  : EmailManager
$esMonitor  : EsMonitor
$settingContext  : SettingContext

Methods

__construct()  : mixed
watch()  : array{issues: list, data: array, emailSent: bool}
buildAlertBody()  : string
safeHtml()  : string
`sendEmailFromText()` renders the body through the Latte `StringLoader` (`email.latte`, see `SendEmailTrait::setTemplate()`), so raw `{`/`}` (e.g. JSON in an ES error message wrapped in `$issue['message']`) would break template parsing. HTML-escape first, then hide the Latte-significant braces too.
sendAlertEmail()  : bool

Constants

Properties

Methods

watch()

public watch() : array{issues: list, data: array, emailSent: bool}
Return values
array{issues: list, data: array, emailSent: bool}

buildAlertBody()

private buildAlertBody(string $host, array<int, array{type: string, source: ?string, message: string, shouldAlert: bool}> $issues) : string
Parameters
$host : string
$issues : array<int, array{type: string, source: ?string, message: string, shouldAlert: bool}>
Return values
string

safeHtml()

`sendEmailFromText()` renders the body through the Latte `StringLoader` (`email.latte`, see `SendEmailTrait::setTemplate()`), so raw `{`/`}` (e.g. JSON in an ES error message wrapped in `$issue['message']`) would break template parsing. HTML-escape first, then hide the Latte-significant braces too.

private safeHtml(string $text) : string
Parameters
$text : string
Return values
string

sendAlertEmail()

private sendAlertEmail(array<int, array{type: string, source: ?string, message: string, shouldAlert: bool}> $issues) : bool
Parameters
$issues : array<int, array{type: string, source: ?string, message: string, shouldAlert: bool}>
Return values
bool
On this page

Search results