CoolCMS API

OrderPresenter extends BasePresenter
in package

FinalYes

Cancels unpaid orders and generates missing invoices.

Lock and token come from the base class (cron.eshop.order.expire / cron.eshop.order.cancel-unpaid / cron.eshop.order.invoice, see App\Core\Base\Cron\BasePresenter).

URL: /cron/eshop/order/expire?token=xxx runs OrderManager::expireUnpaid(): unpaid orders past reservation_expires_at move to the EXPIRED state. Run often, e.g. every 15 minutes. URL: /cron/eshop/order/cancel-unpaid?token=xxx runs OrderManager::cancelUnpaid(): orders left in WAITING-ON-PAYMENT for 30 days since creation move to EXPIRED and the customer gets its e-mail. URL: /cron/eshop/order/invoice?token=xxx runs OrderManager::runInvoiceCatchup(): a watermark reconcile of invoiced_status that catches up invoices missed after a fail-soft failure of step 10 in OrderTransitionManager. Run it after the expiration so it does not catch up orders that should have expired.

Table of Contents

Properties

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

Methods

__construct()  : mixed
actionCancelUnpaid()  : void
Frequency: daily (the period is counted in days).
actionExpire()  : void
Frequency: hourly.
actionInvoice()  : void
Frequency: every 15 minutes.
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).

Properties

$operationRunner

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

public OperationRunner $operationRunner
Attributes
#[Inject]

Methods

actionCancelUnpaid()

Frequency: daily (the period is counted in days).

public actionCancelUnpaid() : void
Attributes
#[CronJob]
$frequency: 'daily:05:20'
$outbound: true

actionExpire()

Frequency: hourly.

public actionExpire() : void
Attributes
#[CronJob]
$frequency: 'every:60'
$outbound: true

actionInvoice()

Frequency: every 15 minutes.

public actionInvoice() : void
Attributes
#[CronJob]
$frequency: 'every:15'
$outbound: true

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