KMP PHP API Reference

WorkflowApprovalDeadlineTask extends Task
in package
uses ServicesTrait

Checks for expired workflow approvals and resumes their workflows.

Finds all PENDING approvals past their deadline, marks them EXPIRED, and resumes the workflow on the 'expired' output port.

Schedule via cron: bin/cake queue add WorkflowApprovalDeadline

Table of Contents

Properties

$costs  : int
Activate this if you want cost management per server to avoid server overloading.
$QueuedJobs  : QueuedJobsTable
$queueModelClass  : string
$rate  : int
Rate limiting per worker in seconds.
$retries  : int|null
Retry transient workflow resume failures.
$timeout  : int|null
Timeout for run, after which the Task is reassigned to a new worker.
$unique  : bool
Prevent parallel execution of this task.
$container  : ContainerInterface|null
$io  : Io
$logger  : LoggerInterface|null

Methods

__construct()  : mixed
run()  : void
Scan for expired approvals, process escalation config, and resume workflows.
setContainer()  : void
taskName()  : string
getService()  : T
dispatchExpiredApprovalEvent()  : void
Notify domain integrations that an approval deadline expired.
parseExtendedDeadline()  : DateTime
Parse a deadline extension string into a future DateTime.
processEscalation()  : bool
Process escalation actions defined in the approval's escalation_config JSON.
reassignPendingApproval()  : void
Reassign an approval while holding the same row lock used by responses.
transitionAndResume()  : WorkflowApproval|null
Atomically transition an approval and resume its workflow.

Properties

$costs

Activate this if you want cost management per server to avoid server overloading.

public int $costs = 0

Expensive tasks (CPU, memory, ...) can have 1...100 points here, with higher points preventing a similar cost intensive task to be fetched on the same server in parallel. Smaller ones can easily still be processed on the same server if some an expensive one is running.

$queueModelClass

public string $queueModelClass = 'Queue.QueuedJobs'

$rate

Rate limiting per worker in seconds.

public int $rate = 0

Activate this if you want to stretch the processing of a specific task per worker.

$container

protected ContainerInterface|null $container = null

$logger

protected LoggerInterface|null $logger = null

Methods

__construct()

public __construct([Io|null $io = null ][, LoggerInterface|null $logger = null ]) : mixed
Parameters
$io : Io|null = null

IO

$logger : LoggerInterface|null = null

run()

Scan for expired approvals, process escalation config, and resume workflows.

public run(array<string, mixed> $data, int $jobId) : void
Parameters
$data : array<string, mixed>

Unused for scheduled runs

$jobId : int

The id of the QueuedJob entity

setContainer()

public setContainer(ContainerInterface $container) : void
Parameters
$container : ContainerInterface

taskName()

public static taskName() : string
Tags
throws
InvalidArgumentException
Return values
string

getService()

protected getService(T> $id) : T
Parameters
$id : T>

Classname or identifier of the service you want to retrieve

Tags
template
throws
ContainerExceptionInterface
NotFoundExceptionInterface
Return values
T

parseExtendedDeadline()

Parse a deadline extension string into a future DateTime.

private parseExtendedDeadline(string $deadline) : DateTime
Parameters
$deadline : string
Return values
DateTime

processEscalation()

Process escalation actions defined in the approval's escalation_config JSON.

private processEscalation(WorkflowApproval $approval, array<string|int, mixed> $escalationConfig, Table $approvalsTable, WorkflowEngineInterface $engine) : bool

Supported actions:

  • "auto_approve": Marks approval as approved and resumes on 'approved' port
  • "auto_reject": Marks approval as rejected and resumes on 'rejected' port
  • "reassign": Updates approver_config, extends deadline, keeps pending
  • "notify": Logs notification targets (integration point for mailer)
Parameters
$approval : WorkflowApproval
$escalationConfig : array<string|int, mixed>
$approvalsTable : Table
$engine : WorkflowEngineInterface
Return values
bool

True if escalation was fully handled, false to fall through to default expiry

reassignPendingApproval()

Reassign an approval while holding the same row lock used by responses.

private reassignPendingApproval(WorkflowApproval $approval, array<string|int, mixed> $newConfig, DateTime $deadline, Table $approvalsTable) : void
Parameters
$approval : WorkflowApproval
$newConfig : array<string|int, mixed>
$deadline : DateTime
$approvalsTable : Table

transitionAndResume()

Atomically transition an approval and resume its workflow.

private transitionAndResume(WorkflowApproval $approval, string $status, string $outputPort, array<string|int, mixed> $resumeData, Table $approvalsTable, WorkflowEngineInterface $engine) : WorkflowApproval|null
Parameters
$approval : WorkflowApproval
$status : string
$outputPort : string
$resumeData : array<string|int, mixed>
$approvalsTable : Table
$engine : WorkflowEngineInterface
Return values
WorkflowApproval|null

Updated approval, or null when already handled

On this page

Search results