KMP PHP API Reference

WorkflowEngineInterface

Contract for the workflow execution engine.

Provides methods to start, resume, cancel workflows and dispatch triggers.

Table of Contents

Methods

cancelHumanTask()  : ServiceResult
Cancel a pending human task.
cancelWorkflow()  : ServiceResult
Cancel a running or waiting workflow instance.
completeHumanTask()  : ServiceResult
Complete a pending human task and resume the workflow.
dispatchTrigger()  : array<string|int, ServiceResult>
Dispatch a trigger event and start any matching workflows.
fireIntermediateApprovalActions()  : ServiceResult
Fire actions connected to an approval node's on_each_approval port.
getInstanceState()  : array<string|int, mixed>|null
Get the current state of a workflow instance.
resumeWorkflow()  : ServiceResult
Resume a waiting workflow instance from a specific node output.
startWorkflow()  : ServiceResult
Start a new workflow instance from a definition slug.

Methods

cancelHumanTask()

Cancel a pending human task.

public cancelHumanTask(int $taskId[, string|null $reason = null ]) : ServiceResult
Parameters
$taskId : int

Workflow task ID

$reason : string|null = null

Optional cancellation reason

Return values
ServiceResult

cancelWorkflow()

Cancel a running or waiting workflow instance.

public cancelWorkflow(int $instanceId[, string|null $reason = null ]) : ServiceResult
Parameters
$instanceId : int

The workflow instance ID

$reason : string|null = null

Optional cancellation reason

Return values
ServiceResult

completeHumanTask()

Complete a pending human task and resume the workflow.

public completeHumanTask(int $taskId, array<string|int, mixed> $formData, int $completedBy) : ServiceResult
Parameters
$taskId : int

Workflow task ID

$formData : array<string|int, mixed>

Submitted form data

$completedBy : int

Member ID completing the task

Return values
ServiceResult

dispatchTrigger()

Dispatch a trigger event and start any matching workflows.

public dispatchTrigger(string $eventName[, array<string|int, mixed> $eventData = [] ][, int|null $triggeredBy = null ]) : array<string|int, ServiceResult>
Parameters
$eventName : string

The event name to match against triggers

$eventData : array<string|int, mixed> = []

Data associated with the event

$triggeredBy : int|null = null

Member ID who triggered the event

Return values
array<string|int, ServiceResult>

Results for each started workflow

fireIntermediateApprovalActions()

Fire actions connected to an approval node's on_each_approval port.

public fireIntermediateApprovalActions(int $instanceId, string $nodeId, array<string|int, mixed> $approvalData[, string $outputPort = 'on_each_approval' ]) : ServiceResult

Called after a non-final approval is recorded (serial pick-next or parallel). Executes intermediate actions without finalizing the approval node. The approval node remains in WAITING state with its execution log unchanged.

Parameters
$instanceId : int

The workflow instance ID

$nodeId : string

The approval node ID

$approvalData : array<string|int, mixed>

Approval progress data (approverId, decision, comment, nextApproverId)

$outputPort : string = 'on_each_approval'

Approval node output port to follow

Return values
ServiceResult

getInstanceState()

Get the current state of a workflow instance.

public getInstanceState(int $instanceId) : array<string|int, mixed>|null
Parameters
$instanceId : int

The workflow instance ID

Return values
array<string|int, mixed>|null

Instance state array or null if not found

resumeWorkflow()

Resume a waiting workflow instance from a specific node output.

public resumeWorkflow(int $instanceId, string $nodeId, string $outputPort[, array<string|int, mixed> $additionalData = [] ]) : ServiceResult
Parameters
$instanceId : int

The workflow instance ID

$nodeId : string

The node to resume from

$outputPort : string

The output port to follow

$additionalData : array<string|int, mixed> = []

Extra data to merge into context

Return values
ServiceResult

startWorkflow()

Start a new workflow instance from a definition slug.

public startWorkflow(string $workflowSlug[, array<string|int, mixed> $triggerData = [] ][, int|null $startedBy = null ][, string|null $entityType = null ][, int|null $entityId = null ]) : ServiceResult
Parameters
$workflowSlug : string

The workflow definition slug

$triggerData : array<string|int, mixed> = []

Data passed by the trigger event

$startedBy : int|null = null

Member ID who initiated the workflow

$entityType : string|null = null

Optional entity type this workflow operates on

$entityId : int|null = null

Optional entity ID this workflow operates on

Return values
ServiceResult

Contains instanceId on success

On this page

Search results