WorkflowApprovalsTable
extends BaseTable
in package
WorkflowApprovals Model
Table of Contents
Constants
- REQUEST_TITLE_MAX_LENGTH : mixed = 255
- CACHE_GROUPS_TO_CLEAR : array<string|int, string> = []
- CACHES_TO_CLEAR : array<string|int, array{string, string}> = []
- ID_CACHES_TO_CLEAR : array<string|int, array{string, string}> = []
Properties
- $RequesterMember : MembersTable|BelongsTo
- $WorkflowApprovalResponses : WorkflowApprovalResponsesTable|HasMany
- $WorkflowApprovalTriageStates : WorkflowApprovalTriageStatesTable|HasMany
- $WorkflowExecutionLogs : WorkflowExecutionLogsTable|BelongsTo
- $WorkflowInstances : WorkflowInstancesTable|BelongsTo
- $memberApprovalScopeCache : array<int, array<string, mixed>>
- Request-local member approval scope cache.
- $pendingApprovalEligibilityCache : array<string, array<string|int, WorkflowApproval>>
- Request-local pending approval eligibility cache.
Methods
- addBranchScopeQuery() : SelectQuery
- Add branch-based data scoping to a query.
- afterDelete() : void
- Clear pending approval caches when approval rows are deleted.
- afterSave() : void
- Clear pending approval caches when approval rows change.
- beforeSave() : void
- Populate denormalized lookup fields from the approval config snapshot.
- buildRules() : RulesChecker
- Build rules for referential integrity.
- clearApprovalScopeCache() : void
- Clear request-local approval scope cache.
- clearPendingApprovalEligibilityCache() : void
- Clear request-local pending approval eligibility cache.
- getPendingApprovalCountForMember() : int
- Get the count of pending approvals for a specific member.
- getPendingApprovalIdsForMember() : array<string|int, int>
- Get pending approval IDs for a member without invoking dynamic resolver services.
- getPendingApprovalsForMember() : array<string|int, WorkflowApproval>
- Get pending approvals for a member without invoking dynamic resolver services.
- getPendingApprovalWorkflowInstanceIdsForMember() : array<string|int, int>
- Get pending workflow instance IDs for a member without invoking dynamic resolver services.
- getWorkflowNamesForMember() : array<int, string>
- Get distinct workflow names represented in a member's My Approvals views.
- initialize() : void
- Initialize method.
- isPendingApprovalForMember() : bool
- Check whether one pending approval is currently actionable for a member.
- newEmptyEntity() : WorkflowApproval
- newEntity() : WorkflowApproval
- patchEntity() : WorkflowApproval
- resolveRequestSnapshotForInstance() : array{request_title: string|null, requester_member_id: int|null}
- Resolve the cached approval request fields for a workflow instance.
- resolveRequestSnapshotForInstanceId() : array{request_title: string|null, requester_member_id: int|null}
- Resolve the cached approval request fields for a workflow instance ID.
- resolveRequestTitleForInstance() : string|null
- Resolve the searchable approval request title for a workflow instance.
- resolveRequestTitleForInstanceId() : string|null
- Resolve the searchable approval request title for a workflow instance ID.
- validationDefault() : Validator
- Default validation rules.
- logImpersonationAction() : void
- Record impersonated writes to audit log table.
- setJsonColumnTypesIfPresent() : void
- Mark JSON columns when the table schema is available.
- applyPendingApprovalCandidateScope() : void
- Narrow pending approvals to rows that could match the member's current scope.
- approvalBranchId() : int|null
- Resolve the branch scope encoded by an award approval config.
- approvalLookupFromConfig() : array<string, mixed>
- approvalScopeNestedIds() : array<string|int, int>
- dynamicConfigIncludesMember() : bool
- Check dynamic approver config against the member's current branch-scoped roles, permissions, and offices.
- getAwardBranchIdsByApprovalRun() : array<int, int>
- Batch-load award branch IDs for pending award approval runs.
- getBranchIndex() : array<int, array{parent_id: int|null, type: string|null}>
- Load branch hierarchy data only when award approvals may need it.
- getMemberApprovalScope() : array<string, mixed>
- Build the current member scope needed for fast approval badge counts.
- getPendingApprovalsMatchingMember() : array<string|int, WorkflowApproval>
- Get pending approval rows matching the member's current approval scope.
- hasPriorDynamicWorkflowResponse() : bool
- Check whether the member has already responded in this dynamic approval's workflow instance.
- isApprovalPendingForMember() : bool
- Check badge-count eligibility without invoking dynamic resolver services.
- memberHasConfiguredPermission() : bool
- Check direct permission approver config against the member scope.
- memberHasConfiguredRole() : bool
- Check direct role approver config against the member scope.
- memberPassesPolicy() : bool
- Check whether the member passes the approval's configured policy.
- memberPermissionCoversBranch() : bool
- Check whether a loader permission object covers the given branch.
- normalizeWorkflowInstanceIds() : array<string|int, int>|null
- Normalize optional workflow instance scoping for cache keys and queries.
- pendingApprovalEligibilityCacheKey() : string
- Build a stable cache key for a member/scoped pending approval lookup.
- pendingApprovalTypeCandidateConditions() : array<string|int, array<string, mixed>>
- positiveIntOrNull() : int|null
- resolveContextValue() : mixed
- Resolve a dot-path value from workflow context.
- resolvePermissionLookup() : array{0: int|null, 1: string|null}
- resolveRoleLookup() : array{0: int|null, 1: string|null}
- stringOrNull() : string|null
- syncApprovalLookupFields() : void
- Populate lookup fields used by member-centric approval queries.
Constants
REQUEST_TITLE_MAX_LENGTH
public
mixed
REQUEST_TITLE_MAX_LENGTH
= 255
CACHE_GROUPS_TO_CLEAR
protected
array<string|int, string>
CACHE_GROUPS_TO_CLEAR
= []
Cache groups to clear entirely on save
CACHES_TO_CLEAR
protected
array<string|int, array{string, string}>
CACHES_TO_CLEAR
= []
Static cache entries to clear on save
ID_CACHES_TO_CLEAR
protected
array<string|int, array{string, string}>
ID_CACHES_TO_CLEAR
= []
Entity-ID cache prefixes to clear on save
Properties
$RequesterMember
public
MembersTable|BelongsTo
$RequesterMember
$WorkflowApprovalResponses
public
WorkflowApprovalResponsesTable|HasMany
$WorkflowApprovalResponses
$WorkflowApprovalTriageStates
public
WorkflowApprovalTriageStatesTable|HasMany
$WorkflowApprovalTriageStates
$WorkflowExecutionLogs
public
WorkflowExecutionLogsTable|BelongsTo
$WorkflowExecutionLogs
$WorkflowInstances
public
WorkflowInstancesTable|BelongsTo
$WorkflowInstances
$memberApprovalScopeCache
Request-local member approval scope cache.
private
static array<int, array<string, mixed>>
$memberApprovalScopeCache
= []
$pendingApprovalEligibilityCache
Request-local pending approval eligibility cache.
private
static array<string, array<string|int, WorkflowApproval>>
$pendingApprovalEligibilityCache
= []
Methods
addBranchScopeQuery()
Add branch-based data scoping to a query.
public
addBranchScopeQuery(SelectQuery $query, array<string|int, int> $branchIDs) : SelectQuery
Child tables should override for custom branch relationships.
Parameters
- $query : SelectQuery
-
The query to modify
- $branchIDs : array<string|int, int>
-
Authorized branch IDs
Return values
SelectQuery —Query with branch filtering
afterDelete()
Clear pending approval caches when approval rows are deleted.
public
afterDelete(mixed $event, mixed $entity, mixed $options) : void
Parameters
- $event : mixed
-
Event object.
- $entity : mixed
-
Deleted entity.
- $options : mixed
-
Delete options.
afterSave()
Clear pending approval caches when approval rows change.
public
afterSave(mixed $event, mixed $entity, mixed $options) : void
Parameters
- $event : mixed
-
Event object.
- $entity : mixed
-
Saved entity.
- $options : mixed
-
Save options.
beforeSave()
Populate denormalized lookup fields from the approval config snapshot.
public
beforeSave(Event $event, EntityInterface $entity, ArrayObject $options) : void
Parameters
- $event : Event
-
The beforeSave event.
- $entity : EntityInterface
-
Approval entity.
- $options : ArrayObject
-
Save options.
buildRules()
Build rules for referential integrity.
public
buildRules(RulesChecker $rules) : RulesChecker
Parameters
- $rules : RulesChecker
Return values
RulesCheckerclearApprovalScopeCache()
Clear request-local approval scope cache.
public
static clearApprovalScopeCache() : void
Primarily useful for tests or long-running CLI workers that mutate member role/office state and then need fresh approval-scope reads.
clearPendingApprovalEligibilityCache()
Clear request-local pending approval eligibility cache.
public
static clearPendingApprovalEligibilityCache() : void
getPendingApprovalCountForMember()
Get the count of pending approvals for a specific member.
public
static getPendingApprovalCountForMember(int $memberId) : int
Parameters
- $memberId : int
-
The member ID to check
Return values
int —Count of pending approvals
getPendingApprovalIdsForMember()
Get pending approval IDs for a member without invoking dynamic resolver services.
public
static getPendingApprovalIdsForMember(int $memberId[, array<string|int, int>|null $workflowInstanceIds = null ]) : array<string|int, int>
Parameters
- $memberId : int
-
The member ID to check.
- $workflowInstanceIds : array<string|int, int>|null = null
-
Optional workflow instance scope.
Return values
array<string|int, int>getPendingApprovalsForMember()
Get pending approvals for a member without invoking dynamic resolver services.
public
static getPendingApprovalsForMember(int $memberId[, array<string, mixed> $contain = [] ][, array<string|int, int>|null $workflowInstanceIds = null ][, int|null $limit = null ][, int $offset = 0 ]) : array<string|int, WorkflowApproval>
This performs a cheap ID pass first, then loads only eligible rows with the caller's requested associations for rich UI rendering.
Parameters
- $memberId : int
-
The member ID to check.
- $contain : array<string, mixed> = []
-
Associations to contain on the rich fetch.
- $workflowInstanceIds : array<string|int, int>|null = null
-
Optional workflow instance scope.
- $limit : int|null = null
-
Maximum approvals to return.
- $offset : int = 0
-
Number of eligible approvals to skip.
Return values
array<string|int, WorkflowApproval>getPendingApprovalWorkflowInstanceIdsForMember()
Get pending workflow instance IDs for a member without invoking dynamic resolver services.
public
static getPendingApprovalWorkflowInstanceIdsForMember(int $memberId[, array<string|int, int>|null $workflowInstanceIds = null ]) : array<string|int, int>
Parameters
- $memberId : int
-
The member ID to check.
- $workflowInstanceIds : array<string|int, int>|null = null
-
Optional workflow instance scope.
Return values
array<string|int, int>getWorkflowNamesForMember()
Get distinct workflow names represented in a member's My Approvals views.
public
static getWorkflowNamesForMember(int $memberId) : array<int, string>
Includes workflows with currently actionable approvals and workflows the member has previously responded to.
Parameters
- $memberId : int
-
Member ID.
Return values
array<int, string>initialize()
Initialize method.
public
initialize(array<string|int, mixed> $config) : void
Parameters
- $config : array<string|int, mixed>
isPendingApprovalForMember()
Check whether one pending approval is currently actionable for a member.
public
static isPendingApprovalForMember(int $approvalId, int $memberId) : bool
Parameters
- $approvalId : int
-
Workflow approval ID.
- $memberId : int
-
Member ID.
Return values
boolnewEmptyEntity()
public
newEmptyEntity() : WorkflowApproval
Return values
WorkflowApprovalnewEntity()
public
newEntity(array<string|int, mixed> $data[, array<string|int, mixed> $options = = '[]' ]) : WorkflowApproval
Parameters
- $data : array<string|int, mixed>
- $options : array<string|int, mixed> = = '[]'
Return values
WorkflowApprovalpatchEntity()
public
patchEntity(EntityInterface $entity, array<string|int, mixed> $data[, array<string|int, mixed> $options = = '[]' ]) : WorkflowApproval
Parameters
- $entity : EntityInterface
- $data : array<string|int, mixed>
- $options : array<string|int, mixed> = = '[]'
Return values
WorkflowApprovalresolveRequestSnapshotForInstance()
Resolve the cached approval request fields for a workflow instance.
public
resolveRequestSnapshotForInstance(WorkflowInstance $instance) : array{request_title: string|null, requester_member_id: int|null}
Parameters
- $instance : WorkflowInstance
-
Workflow instance.
Return values
array{request_title: string|null, requester_member_id: int|null}resolveRequestSnapshotForInstanceId()
Resolve the cached approval request fields for a workflow instance ID.
public
resolveRequestSnapshotForInstanceId(int $instanceId) : array{request_title: string|null, requester_member_id: int|null}
Parameters
- $instanceId : int
-
Workflow instance ID.
Return values
array{request_title: string|null, requester_member_id: int|null}resolveRequestTitleForInstance()
Resolve the searchable approval request title for a workflow instance.
public
resolveRequestTitleForInstance(WorkflowInstance $instance) : string|null
Parameters
- $instance : WorkflowInstance
-
Workflow instance.
Return values
string|nullresolveRequestTitleForInstanceId()
Resolve the searchable approval request title for a workflow instance ID.
public
resolveRequestTitleForInstanceId(int $instanceId) : string|null
Parameters
- $instanceId : int
-
Workflow instance ID.
Return values
string|nullvalidationDefault()
Default validation rules.
public
validationDefault(Validator $validator) : Validator
Parameters
- $validator : Validator
Return values
ValidatorlogImpersonationAction()
Record impersonated writes to audit log table.
protected
logImpersonationAction(string $defaultOperation, EntityInterface $entity) : void
Parameters
- $defaultOperation : string
-
Operation fallback (save/delete)
- $entity : EntityInterface
-
Affected entity
setJsonColumnTypesIfPresent()
Mark JSON columns when the table schema is available.
protected
setJsonColumnTypesIfPresent(array<int, string> $columns) : void
Some reset/migration flows instantiate table classes before every table exists. JSON type mapping is optional metadata, so skip it until the schema can be described instead of failing application bootstrap.
Parameters
- $columns : array<int, string>
-
JSON column names.
applyPendingApprovalCandidateScope()
Narrow pending approvals to rows that could match the member's current scope.
private
static applyPendingApprovalCandidateScope(SelectQuery $query, int $memberId, array<string, mixed> $memberScope) : void
The PHP eligibility pass remains authoritative for branch scoping, policies, and current approver fallback values in JSON config.
Parameters
- $query : SelectQuery
-
Pending approvals query.
- $memberId : int
-
Current member ID.
- $memberScope : array<string, mixed>
-
Current member approval scope.
approvalBranchId()
Resolve the branch scope encoded by an award approval config.
private
static approvalBranchId(array<string, mixed> $config, array<int, int> $awardBranchIdsByRun, array<int, array{parent_id: int|null, type: string|null}> $branchIndex) : int|null
Parameters
- $config : array<string, mixed>
-
Approval config.
- $awardBranchIdsByRun : array<int, int>
-
Award branch IDs keyed by recommendation approval run ID.
- $branchIndex : array<int, array{parent_id: int|null, type: string|null}>
-
Branch hierarchy keyed by branch ID.
Return values
int|nullapprovalLookupFromConfig()
private
approvalLookupFromConfig(string $approverType, array<string, mixed> $config) : array<string, mixed>
Parameters
- $approverType : string
-
Approval type.
- $config : array<string, mixed>
-
Approval config snapshot.
Return values
array<string, mixed>approvalScopeNestedIds()
private
static approvalScopeNestedIds(array<int, array<int, bool>> $idsByBranch) : array<string|int, int>
Parameters
- $idsByBranch : array<int, array<int, bool>>
-
Scope IDs keyed by branch.
Return values
array<string|int, int>dynamicConfigIncludesMember()
Check dynamic approver config against the member's current branch-scoped roles, permissions, and offices.
private
static dynamicConfigIncludesMember(array<string, mixed> $config, int $memberId, array<string, mixed> $memberScope, array<int, int> $awardBranchIdsByRun, array<int, array{parent_id: int|null, type: string|null}> $branchIndex) : bool
Parameters
- $config : array<string, mixed>
-
Approval config.
- $memberId : int
-
Current member ID.
- $memberScope : array<string, mixed>
-
Current member approval scope.
- $awardBranchIdsByRun : array<int, int>
-
Award branch IDs keyed by recommendation approval run ID.
- $branchIndex : array<int, array{parent_id: int|null, type: string|null}>
-
Branch hierarchy keyed by branch ID.
Return values
boolgetAwardBranchIdsByApprovalRun()
Batch-load award branch IDs for pending award approval runs.
private
static getAwardBranchIdsByApprovalRun(array<string|int, WorkflowApproval> $approvals) : array<int, int>
Parameters
- $approvals : array<string|int, WorkflowApproval>
-
Pending approvals.
Return values
array<int, int>getBranchIndex()
Load branch hierarchy data only when award approvals may need it.
private
static getBranchIndex(array<int, int> $awardBranchIdsByRun) : array<int, array{parent_id: int|null, type: string|null}>
Parameters
- $awardBranchIdsByRun : array<int, int>
-
Award branch IDs keyed by recommendation approval run ID.
Return values
array<int, array{parent_id: int|null, type: string|null}>getMemberApprovalScope()
Build the current member scope needed for fast approval badge counts.
private
static getMemberApprovalScope(int $memberId) : array<string, mixed>
Parameters
- $memberId : int
-
Member ID.
Return values
array<string, mixed>getPendingApprovalsMatchingMember()
Get pending approval rows matching the member's current approval scope.
private
static getPendingApprovalsMatchingMember(int $memberId[, array<string|int, int>|null $workflowInstanceIds = null ]) : array<string|int, WorkflowApproval>
Parameters
- $memberId : int
-
The member ID to check.
- $workflowInstanceIds : array<string|int, int>|null = null
-
Optional workflow instance scope.
Return values
array<string|int, WorkflowApproval>hasPriorDynamicWorkflowResponse()
Check whether the member has already responded in this dynamic approval's workflow instance.
private
static hasPriorDynamicWorkflowResponse(WorkflowApproval $approval, int $memberId) : bool
Parameters
- $approval : WorkflowApproval
-
Pending approval.
- $memberId : int
-
Member ID.
Return values
boolisApprovalPendingForMember()
Check badge-count eligibility without invoking dynamic resolver services.
private
static isApprovalPendingForMember(WorkflowApproval $approval, int $memberId, array<string, mixed> $memberScope, array<int, int> $awardBranchIdsByRun, array<int, array{parent_id: int|null, type: string|null}> $branchIndex) : bool
Parameters
- $approval : WorkflowApproval
-
Pending approval row.
- $memberId : int
-
Current member ID.
- $memberScope : array<string, mixed>
-
Current member approval scope.
- $awardBranchIdsByRun : array<int, int>
-
Award branch IDs keyed by recommendation approval run ID.
- $branchIndex : array<int, array{parent_id: int|null, type: string|null}>
-
Branch hierarchy keyed by branch ID.
Return values
boolmemberHasConfiguredPermission()
Check direct permission approver config against the member scope.
private
static memberHasConfiguredPermission(array<string, mixed> $config, array<string, mixed> $memberScope) : bool
Parameters
- $config : array<string, mixed>
-
Approval config.
- $memberScope : array<string, mixed>
-
Current member approval scope.
Return values
boolmemberHasConfiguredRole()
Check direct role approver config against the member scope.
private
static memberHasConfiguredRole(array<string, mixed> $config, array<string, mixed> $memberScope) : bool
Parameters
- $config : array<string, mixed>
-
Approval config.
- $memberScope : array<string, mixed>
-
Current member approval scope.
Return values
boolmemberPassesPolicy()
Check whether the member passes the approval's configured policy.
private
static memberPassesPolicy(WorkflowApproval $approval, int $memberId) : bool
Parameters
- $approval : WorkflowApproval
- $memberId : int
Return values
boolmemberPermissionCoversBranch()
Check whether a loader permission object covers the given branch.
private
static memberPermissionCoversBranch(object|null $permission, int $branchId) : bool
Permission scope is resolved by PermissionsLoader::getPermissions():
branch_ids === null denotes a Global permission (covers every branch),
otherwise it is the explicit list of branches the member holds it in
(including descendants for branch-and-children scoping).
Parameters
- $permission : object|null
-
Loader permission object, or null if not held.
- $branchId : int
-
Branch ID to test coverage for.
Return values
boolnormalizeWorkflowInstanceIds()
Normalize optional workflow instance scoping for cache keys and queries.
private
static normalizeWorkflowInstanceIds(array<string|int, int>|null $workflowInstanceIds) : array<string|int, int>|null
Parameters
- $workflowInstanceIds : array<string|int, int>|null
-
Optional workflow instance IDs.
Return values
array<string|int, int>|nullpendingApprovalEligibilityCacheKey()
Build a stable cache key for a member/scoped pending approval lookup.
private
static pendingApprovalEligibilityCacheKey(int $memberId, array<string|int, int>|null $workflowInstanceIds) : string
Parameters
- $memberId : int
-
Member ID.
- $workflowInstanceIds : array<string|int, int>|null
-
Optional workflow instance IDs.
Return values
stringpendingApprovalTypeCandidateConditions()
private
static pendingApprovalTypeCandidateConditions(int $memberId, array<string, mixed> $memberScope, array<string|int, int> $roleIds, array<string|int, int> $permissionIds, array<string|int, int> $officeIds) : array<string|int, array<string, mixed>>
Parameters
- $memberId : int
-
Current member ID.
- $memberScope : array<string, mixed>
-
Current member approval scope.
- $roleIds : array<string|int, int>
-
Active role IDs from the member scope.
- $permissionIds : array<string|int, int>
-
Active permission IDs from the member scope.
- $officeIds : array<string|int, int>
-
Active office IDs from the member scope.
Return values
array<string|int, array<string, mixed>>positiveIntOrNull()
private
static positiveIntOrNull(mixed $value) : int|null
Parameters
- $value : mixed
-
Raw value.
Return values
int|nullresolveContextValue()
Resolve a dot-path value from workflow context.
private
static resolveContextValue(array<string|int, mixed> $context, string $key) : mixed
Parameters
- $context : array<string|int, mixed>
- $key : string
resolvePermissionLookup()
private
resolvePermissionLookup(int|null $permissionId, string|null $permissionName) : array{0: int|null, 1: string|null}
Parameters
- $permissionId : int|null
-
Configured permission ID.
- $permissionName : string|null
-
Configured permission name.
Return values
array{0: int|null, 1: string|null}resolveRoleLookup()
private
resolveRoleLookup(int|null $roleId, string|null $roleName) : array{0: int|null, 1: string|null}
Parameters
- $roleId : int|null
-
Configured role ID.
- $roleName : string|null
-
Configured role name.
Return values
array{0: int|null, 1: string|null}stringOrNull()
private
static stringOrNull(mixed $value) : string|null
Parameters
- $value : mixed
-
Raw value.
Return values
string|nullsyncApprovalLookupFields()
Populate lookup fields used by member-centric approval queries.
private
syncApprovalLookupFields(EntityInterface $entity) : void
Parameters
- $entity : EntityInterface
-
Approval entity.