CoolCMS API

NotificationPresenter extends BasePresenter
in package

FinalYes

Detaches orphaned admin notifications from their target (the target record, such as an order, user or payment, no longer exists).

The notification is not deleted, only its target reference (id) is nulled. Deletion through the ORM detaches immediately via NotificationTargetDetachSubscriber; this job cleans up deletions outside the ORM (raw SQL, DB cascades). It is triggered only by the "detach orphans" button in the overview and by this cron, never on page render.

URL: /cron/system/notification/clean-orphans?token=xxx

A second job, /cron/system/notification/purge-read?token=xxx[&days=N], deletes read notifications older than N days: ?days, else the setting notification.readRetentionDays (group 1), else 90 days. It never deletes unread ones.

Frequency: daily. clean-orphans guards itself to run at most once per GUARD_TTL seconds, so it is safe to hook into a more frequent cron; purge-read has no such guard.

Table of Contents

Constants

GUARD_NAME  : string = 'notification.orphans.lastRun'
Lock row remembering the last run (`cms_cron_locks`) — deliberately never released.
GUARD_TTL  : int = 72000
20 h, not 24 h: a daily crontab fires a few seconds "earlier" than the previous run finished, so a 24 h guard would skip every other day.

Properties

$cronLockManager  : CronLockManager
$operationRunner  : OperationRunner
Boundary of one cron action (see {@see self::tryCall()}).
$settingContext  : SettingContext
$settingManager  : SettingManager
$debugMode  : bool
$productionMode  : bool
$notificationManager  : NotificationManager
$orphanCleaner  : NotificationOrphanCleaner

Methods

__construct()  : mixed
actionCleanOrphans()  : void
actionPurgeRead()  : void
releaseLock()  : void
Releases the lock at most once; called by both `shutdown()` and the PHP shutdown function.
sendResponse()  : void
setConfigParameters()  : void
shutdown()  : void
startup()  : void
isSameSiteRequest()  : bool
Tells whether the request comes from the own site (Nette SameSite cookie); protects GET actions with a side effect.
sendError()  : never
sendSkipped()  : never
Reports that the job did only part of the work and the next call finishes the rest (e.g. a reindex done in chunks).
sendSuccess()  : never
tryCall()  : bool
Runs the `action<Action>()` method as one operation (transitional).
resolveReadRetentionDays()  : int

Constants

GUARD_NAME

Lock row remembering the last run (`cms_cron_locks`) — deliberately never released.

private string GUARD_NAME = 'notification.orphans.lastRun'

GUARD_TTL

20 h, not 24 h: a daily crontab fires a few seconds "earlier" than the previous run finished, so a 24 h guard would skip every other day.

private int GUARD_TTL = 72000

Properties

$operationRunner

Boundary of one cron action (see {@see self::tryCall()}).

public OperationRunner $operationRunner
Attributes
#[Inject]

Methods

actionPurgeRead()

public actionPurgeRead([int|null $days = null ]) : void
Parameters
$days : int|null = null
Attributes
#[CronJob]
$frequency: 'daily:04:35'
$outbound: false

releaseLock()

Releases the lock at most once; called by both `shutdown()` and the PHP shutdown function.

public releaseLock() : void

sendResponse()

public sendResponse(Response $response) : void
Parameters
$response : Response

setConfigParameters()

public setConfigParameters([bool $debugMode = false ][, bool $productionMode = false ]) : void
Parameters
$debugMode : bool = false
$productionMode : bool = false

shutdown()

public shutdown(Response $response) : void
Parameters
$response : Response

isSameSiteRequest()

Tells whether the request comes from the own site (Nette SameSite cookie); protects GET actions with a side effect.

protected isSameSiteRequest() : bool

getHttpRequest() returns the IRequest interface, while isSameSite() exists only on Nette\Http\Request.

Return values
bool

sendError()

protected sendError(string $message[, int $code = 500 ]) : never
Parameters
$message : string
$code : int = 500
Return values
never

sendSkipped()

Reports that the job did only part of the work and the next call finishes the rest (e.g. a reindex done in chunks).

protected sendSkipped(string $reason[, array<string, mixed> $data = [] ]) : never

The scheduler does not record skipped as a run, so the job stays due and is called again on the next tick.

Parameters
$reason : string
$data : array<string, mixed> = []
Return values
never

sendSuccess()

protected sendSuccess([array<string|int, mixed> $data = [] ]) : never
Parameters
$data : array<string|int, mixed> = []
Return values
never

tryCall()

Runs the `action<Action>()` method as one operation (transitional).

protected tryCall(string $method, array<string, mixed> $params) : bool

Cron has no internalAction*(): its actions call the Api managers directly, so without this in scoped mode nothing would ever empty the unit of work of a cron run. The boundary is the action only; startup() (settings, token, lock) stays outside like the startup of an Api request. A cron action ends with AbortException from send*(), which is a regular end: the outcome comes from the response (ok succeeded, skipped unknown — possibly a part of a batch was done, error failed). Render and signal methods are not wrapped (cron presenters have none).

Parameters
$method : string
$params : array<string, mixed>
Return values
bool
On this page

Search results