RecommendationApprovalProcessService
in package
uses
LocatorAwareTrait
Bridges award recommendation approval process config to workflow runtime state.
Table of Contents
Properties
Methods
- __construct() : mixed
- advanceProcess() : ServiceResult
- Advance the run projection after a workflow approval node resolves.
- buildStepOutput() : array<string, mixed>
- Build workflow action output for one step.
- completedStepKeys() : array<int, string>
- Return stable keys for approval gates already completed in this run.
- isFinalApprovalStep() : bool|null
- Determine whether an approval belongs to the last configured step of its award approval process.
- resolveConfiguredApproverIds() : array<string|int, int>
- Dynamic workflow approval callback for configured award approval steps.
- startProcess() : ServiceResult
- Start or reuse an approval run for the current workflow instance.
- approvalApproverConfig() : array<string, mixed>
- Build the dynamic approver resolver config.
- approverIds() : array<string|int, int>
- Resolve approver IDs for a process step.
- assertRunUsesRecommendationProcess() : void
- Reject stale runs before creating or advancing approval steps until synchronization upgrades them.
- configuredStep() : ApprovalProcessStep|null
- Rehydrate a configured approval target from workflow approval config.
- excludePriorApprovalResponders() : array<string|int, int>
- Remove members who have already responded to a prior approval in this workflow instance.
- findStepIndex() : int|null
- Find a step index by key.
- handleRejectedStep() : ServiceResult
- Close a rejected approval run.
- loadGroupHeadRecommendation() : Recommendation
- Load a recommendation group head with approval process context.
- nextIncompleteStep() : ApprovalProcessStep|null
- Find the next configured step that has not already completed in this run.
- orderedSteps() : array<int, ApprovalProcessStep>
- Sort process steps by sequence.
- requiredCount() : int
- Compute required count from the configured threshold.
- resolveActorId() : int|null
- Resolve actor ID from config or trigger context.
- resolveApprovalStatus() : string
- Resolve an approval outcome from workflow context or action config.
- resolveInstanceId() : int
- Resolve workflow instance ID from workflow context.
- resolveKickbackStep() : ApprovalProcessStep
- Resolve a kickback action to a target step.
- resolveRecommendationId() : int
- Resolve recommendation ID from config or trigger context.
- resolveRejectionComment() : string|null
- Resolve the reject comment from workflow resume/action context.
- saveRejectionCloseReason() : void
- Persist the rejection reason without mutating legacy recommendation status/state.
- syncBlockedFlag() : void
- Persist (only on transitions) whether a pending gate currently has an empty approver pool, so admin views can badge blocked approvals without resolving every pool per row.
- syncRequiredCount() : void
- Keep dynamic workflow approval counts aligned with the current target pool.
- updateRunStep() : void
- Update run current-step projection.
Properties
$resolver
private
AwardApprovalResolverService
$resolver
Methods
__construct()
public
__construct([AwardApprovalResolverService|null $resolver = null ]) : mixed
Parameters
- $resolver : AwardApprovalResolverService|null = null
-
Branch-aware approver resolver.
advanceProcess()
Advance the run projection after a workflow approval node resolves.
public
advanceProcess(array<string, mixed> $context, array<string, mixed> $config) : ServiceResult
Parameters
- $context : array<string, mixed>
-
Workflow context.
- $config : array<string, mixed>
-
Node config.
Return values
ServiceResultbuildStepOutput()
Build workflow action output for one step.
public
buildStepOutput(RecommendationApprovalRun $run, Recommendation $recommendation, ApprovalProcessStep $step[, int|null $currentApprovalId = null ][, array<int, string>|null $completedStepKeys = null ]) : array<string, mixed>
Parameters
- $run : RecommendationApprovalRun
-
Approval run.
- $recommendation : Recommendation
-
Recommendation.
- $step : ApprovalProcessStep
-
Approval step.
- $currentApprovalId : int|null = null
-
Pending approval whose responders remain eligible for this step.
- $completedStepKeys : array<int, string>|null = null
-
Previously loaded completed stable step keys.
Return values
array<string, mixed>completedStepKeys()
Return stable keys for approval gates already completed in this run.
public
completedStepKeys(RecommendationApprovalRun $run) : array<int, string>
Parameters
- $run : RecommendationApprovalRun
-
Approval run.
Return values
array<int, string>isFinalApprovalStep()
Determine whether an approval belongs to the last configured step of its award approval process.
public
isFinalApprovalStep(WorkflowApproval $approval, array<string, mixed> $config) : bool|null
Parameters
- $approval : WorkflowApproval
-
Workflow approval.
- $config : array<string, mixed>
-
Approval approver config.
Return values
bool|null —True/false when resolvable, null when this is not a configured award approval step.
resolveConfiguredApproverIds()
Dynamic workflow approval callback for configured award approval steps.
public
resolveConfiguredApproverIds(WorkflowApproval $approval) : array<string|int, int>
Parameters
- $approval : WorkflowApproval
-
Workflow approval.
Return values
array<string|int, int>startProcess()
Start or reuse an approval run for the current workflow instance.
public
startProcess(array<string, mixed> $context, array<string, mixed> $config) : ServiceResult
Parameters
- $context : array<string, mixed>
-
Workflow context.
- $config : array<string, mixed>
-
Node config.
Return values
ServiceResultapprovalApproverConfig()
Build the dynamic approver resolver config.
private
approvalApproverConfig(RecommendationApprovalRun $run, ApprovalProcessStep $step, bool $isFinalStep) : array<string, mixed>
Parameters
- $run : RecommendationApprovalRun
-
Approval run.
- $step : ApprovalProcessStep
-
Approval step.
- $isFinalStep : bool
-
Whether this is the final configured process step.
Return values
array<string, mixed>approverIds()
Resolve approver IDs for a process step.
private
approverIds(ApprovalProcessStep $step, Recommendation $recommendation) : array<string|int, int>
Parameters
- $step : ApprovalProcessStep
-
Approval step.
- $recommendation : Recommendation
-
Recommendation.
Return values
array<string|int, int>assertRunUsesRecommendationProcess()
Reject stale runs before creating or advancing approval steps until synchronization upgrades them.
private
assertRunUsesRecommendationProcess(RecommendationApprovalRun $run, Recommendation $recommendation) : void
Terminal rejection deliberately bypasses this guard so Sync Now can finish a rejected gate whose original workflow resume was interrupted.
Parameters
- $run : RecommendationApprovalRun
-
Approval run.
- $recommendation : Recommendation
-
Recommendation with current award process.
configuredStep()
Rehydrate a configured approval target from workflow approval config.
private
configuredStep(array<string, mixed> $config) : ApprovalProcessStep|null
Parameters
- $config : array<string, mixed>
-
Workflow approval approver config.
Return values
ApprovalProcessStep|nullexcludePriorApprovalResponders()
Remove members who have already responded to a prior approval in this workflow instance.
private
excludePriorApprovalResponders(int $workflowInstanceId, array<string|int, int> $approverIds[, int|null $currentApprovalId = null ]) : array<string|int, int>
Parameters
- $workflowInstanceId : int
-
Workflow instance ID.
- $approverIds : array<string|int, int>
-
Candidate approver IDs.
- $currentApprovalId : int|null = null
-
Current gate whose responders are not prior-step responders.
Return values
array<string|int, int>findStepIndex()
Find a step index by key.
private
findStepIndex(array<int, ApprovalProcessStep> $steps, string $stepKey) : int|null
Parameters
- $steps : array<int, ApprovalProcessStep>
-
Steps.
- $stepKey : string
-
Step key.
Return values
int|nullhandleRejectedStep()
Close a rejected approval run.
private
handleRejectedStep(RecommendationApprovalRun $run, Recommendation $recommendation, int|null $actorId, string|null $closeReason) : ServiceResult
Parameters
- $run : RecommendationApprovalRun
-
Approval run.
- $recommendation : Recommendation
-
Recommendation.
- $actorId : int|null
-
Actor ID.
- $closeReason : string|null
-
Rejection comment to store as the close reason.
Return values
ServiceResultloadGroupHeadRecommendation()
Load a recommendation group head with approval process context.
private
loadGroupHeadRecommendation(int $recommendationId) : Recommendation
Parameters
- $recommendationId : int
-
Recommendation or child recommendation ID.
Return values
RecommendationnextIncompleteStep()
Find the next configured step that has not already completed in this run.
private
nextIncompleteStep(array<int, ApprovalProcessStep> $steps, int $currentIndex, array<int, string> $completedStepKeys) : ApprovalProcessStep|null
Only later steps are considered so adding or moving a step before the current step never rewinds an in-flight workflow.
Parameters
- $steps : array<int, ApprovalProcessStep>
-
Ordered steps.
- $currentIndex : int
-
Current step index.
- $completedStepKeys : array<int, string>
-
Completed stable step keys.
Return values
ApprovalProcessStep|nullorderedSteps()
Sort process steps by sequence.
private
orderedSteps(array<int, ApprovalProcessStep> $steps) : array<int, ApprovalProcessStep>
Parameters
- $steps : array<int, ApprovalProcessStep>
-
Steps.
Return values
array<int, ApprovalProcessStep>requiredCount()
Compute required count from the configured threshold.
private
requiredCount(ApprovalProcessStep $step, array<string|int, int> $approverIds) : int
Parameters
- $step : ApprovalProcessStep
-
Approval step.
- $approverIds : array<string|int, int>
-
Eligible member IDs.
Return values
intresolveActorId()
Resolve actor ID from config or trigger context.
private
resolveActorId(array<string, mixed> $context, array<string, mixed> $config) : int|null
Parameters
- $context : array<string, mixed>
-
Workflow context.
- $config : array<string, mixed>
-
Node config.
Return values
int|nullresolveApprovalStatus()
Resolve an approval outcome from workflow context or action config.
private
resolveApprovalStatus(array<string, mixed> $context, array<string, mixed> $config) : string
Parameters
- $context : array<string, mixed>
-
Workflow context.
- $config : array<string, mixed>
-
Node config.
Return values
stringresolveInstanceId()
Resolve workflow instance ID from workflow context.
private
resolveInstanceId(array<string, mixed> $context) : int
Parameters
- $context : array<string, mixed>
-
Workflow context.
Return values
intresolveKickbackStep()
Resolve a kickback action to a target step.
private
resolveKickbackStep(array<int, ApprovalProcessStep> $steps, int $currentIndex, string $action) : ApprovalProcessStep
Parameters
- $steps : array<int, ApprovalProcessStep>
-
Ordered steps.
- $currentIndex : int
-
Current step index.
- $action : string
-
Kickback action.
Return values
ApprovalProcessStepresolveRecommendationId()
Resolve recommendation ID from config or trigger context.
private
resolveRecommendationId(array<string, mixed> $context, array<string, mixed> $config) : int
Parameters
- $context : array<string, mixed>
-
Workflow context.
- $config : array<string, mixed>
-
Node config.
Return values
intresolveRejectionComment()
Resolve the reject comment from workflow resume/action context.
private
resolveRejectionComment(array<string, mixed> $context, array<string, mixed> $config) : string|null
Parameters
- $context : array<string, mixed>
-
Workflow context.
- $config : array<string, mixed>
-
Node config.
Return values
string|nullsaveRejectionCloseReason()
Persist the rejection reason without mutating legacy recommendation status/state.
private
saveRejectionCloseReason(Recommendation $recommendation, int|null $actorId[, string|null $closeReason = null ]) : void
Parameters
- $recommendation : Recommendation
-
Recommendation.
- $actorId : int|null
-
Actor ID.
- $closeReason : string|null = null
-
Rejection comment to store as the close reason.
syncBlockedFlag()
Persist (only on transitions) whether a pending gate currently has an empty approver pool, so admin views can badge blocked approvals without resolving every pool per row.
private
syncBlockedFlag(WorkflowApproval $approval, array<string|int, int> $approverIds) : void
Parameters
- $approval : WorkflowApproval
-
Workflow approval.
- $approverIds : array<string|int, int>
-
Current approver IDs.
syncRequiredCount()
Keep dynamic workflow approval counts aligned with the current target pool.
private
syncRequiredCount(WorkflowApproval $approval, array<string, mixed> $config, array<string|int, int> $approverIds) : void
Parameters
- $approval : WorkflowApproval
-
Workflow approval.
- $config : array<string, mixed>
-
Workflow approval approver config.
- $approverIds : array<string|int, int>
-
Current approver IDs.
updateRunStep()
Update run current-step projection.
private
updateRunStep(RecommendationApprovalRun $run, ApprovalProcessStep $step, string $status, int|null $actorId) : void
Parameters
- $run : RecommendationApprovalRun
-
Approval run.
- $step : ApprovalProcessStep
-
Approval step.
- $status : string
-
Projection status.
- $actorId : int|null
-
Actor ID.