WorkflowDispatchTrait uses trait:short
Workflow dispatch helpers for controllers.
Resolves the current kingdom from the authenticated member's branch hierarchy and includes it as workflow event context.
Table of Contents
Methods
- findWorkflowDefinitionBySlug() : WorkflowDefinition|null
- Find a workflow definition by slug.
- dispatchWorkflowEvent() : void
- Fire a workflow event without fallback. Silently logs on failure.
- dispatchWorkflowOrFail() : array<int, mixed>
- Dispatch to the workflow engine and fail when no active definition is available.
- extractContextValue() : mixed
- Extract a matching value from the workflow context or its nested payload arrays.
- extractNumericContextValue() : int|null
- Extract a numeric value from top-level or nested workflow context arrays.
- extractStringContextValue() : string|null
- Extract a string value from top-level or nested workflow context arrays.
- resolveBranchIdFromContextMember() : int|null
- Resolve a branch ID from member identifiers carried in workflow context.
- resolveKingdomId() : int|null
- Resolve the kingdom ID from the authenticated member or workflow context.
- resolveKingdomIdFromBranch() : int|null
- Walk the branch parent chain to find the kingdom-type ancestor.
- findActiveDefinition() : WorkflowDefinition|null
- Find an active workflow definition by slug.
- getWorkflowDefinitionsTable() : WorkflowDefinitionsTable
- Get the WorkflowDefinitions table instance.
Methods
findWorkflowDefinitionBySlug()
Find a workflow definition by slug.
public
findWorkflowDefinitionBySlug(string $slug) : WorkflowDefinition|null
Parameters
- $slug : string
-
Workflow definition slug
Return values
WorkflowDefinition|nulldispatchWorkflowEvent()
Fire a workflow event without fallback. Silently logs on failure.
protected
dispatchWorkflowEvent(TriggerDispatcher $dispatcher, string $triggerEvent, array<string|int, mixed> $context) : void
Includes kingdom context from the authenticated user.
Parameters
- $dispatcher : TriggerDispatcher
-
Workflow trigger dispatcher
- $triggerEvent : string
-
Event name for the workflow engine
- $context : array<string|int, mixed>
-
Event data / context for the workflow
dispatchWorkflowOrFail()
Dispatch to the workflow engine and fail when no active definition is available.
protected
dispatchWorkflowOrFail(TriggerDispatcher $dispatcher, string $slug, string $triggerEvent, array<string|int, mixed> $context) : array<int, mixed>
Resolves the current kingdom from the authenticated user's branch hierarchy and includes it in the dispatch context.
Parameters
- $dispatcher : TriggerDispatcher
-
Workflow trigger dispatcher
- $slug : string
-
Workflow definition slug
- $triggerEvent : string
-
Event name for the workflow engine
- $context : array<string|int, mixed>
-
Event data / context for the workflow
Return values
array<int, mixed>extractContextValue()
Extract a matching value from the workflow context or its nested payload arrays.
protected
extractContextValue(array<string, mixed> $context, array<int, string> $keys) : mixed
Parameters
- $context : array<string, mixed>
-
Workflow trigger context.
- $keys : array<int, string>
-
Keys to search for.
extractNumericContextValue()
Extract a numeric value from top-level or nested workflow context arrays.
protected
extractNumericContextValue(array<string, mixed> $context, array<int, string> $keys) : int|null
Parameters
- $context : array<string, mixed>
-
Workflow trigger context.
- $keys : array<int, string>
-
Keys to search for.
Return values
int|nullextractStringContextValue()
Extract a string value from top-level or nested workflow context arrays.
protected
extractStringContextValue(array<string, mixed> $context, array<int, string> $keys) : string|null
Parameters
- $context : array<string, mixed>
-
Workflow trigger context.
- $keys : array<int, string>
-
Keys to search for.
Return values
string|nullresolveBranchIdFromContextMember()
Resolve a branch ID from member identifiers carried in workflow context.
protected
resolveBranchIdFromContextMember(array<string, mixed> $context) : int|null
Supports both direct member IDs and member public IDs from public forms.
Parameters
- $context : array<string, mixed>
-
Workflow trigger context.
Return values
int|nullresolveKingdomId()
Resolve the kingdom ID from the authenticated member or workflow context.
protected
resolveKingdomId([array<string, mixed> $context = [] ]) : int|null
Authenticated requests still prefer the actor's branch ancestry. Anonymous requests can derive kingdom from explicit branch or member identifiers in the workflow context so public forms can dispatch to kingdom-specific flows.
Parameters
- $context : array<string, mixed> = []
-
Workflow trigger context.
Return values
int|null —Kingdom branch ID, or null if unavailable
resolveKingdomIdFromBranch()
Walk the branch parent chain to find the kingdom-type ancestor.
protected
resolveKingdomIdFromBranch(int $branchId) : int|null
Parameters
- $branchId : int
-
Starting branch ID
Return values
int|null —Kingdom branch ID, or null if no kingdom found
findActiveDefinition()
Find an active workflow definition by slug.
private
findActiveDefinition(string $slug) : WorkflowDefinition|null
Parameters
- $slug : string
-
Workflow definition slug
Return values
WorkflowDefinition|nullgetWorkflowDefinitionsTable()
Get the WorkflowDefinitions table instance.
private
getWorkflowDefinitionsTable() : WorkflowDefinitionsTable