AuthorizationApprovalsTable
extends BaseTable
in package
AuthorizationApprovalsTable
Manages approval workflow tracking for authorization requests. Each record represents an individual approval request sent to a specific approver, tracking decisions, timing, and complete accountability.
Core Responsibilities:
- Track multi-level approval workflows with secure token validation
- Record approver decisions (approve/deny) with timing and notes
- Provide complete audit trail of approval process
- Support email-based approval workflows
- Enable approval analytics and performance metrics
Database Schema:
activities_authorization_approvalstable- Foreign keys: authorization_id, approver_id
- Unique index on authorization_token for secure validation
- Indexes on authorization_id, approver_id, responded_on for queries
Key Methods:
initialize(): Set up associations and configurationvalidationDefault(): Field validation rulesbuildRules(): Referential integrity rulesmemberAuthQueueCount(): Static method for pending approval count
Performance:
- Indexed on approver_id + responded_on for efficient pending queries
- Token-based lookups use unique index on authorization_token
- Association loading optimized for email notification workflows
Tags
Table of Contents
Constants
- CACHE_GROUPS_TO_CLEAR = []
- CACHES_TO_CLEAR = []
- ID_CACHES_TO_CLEAR = []
Properties
- $Approvers : MembersTable|BelongsTo
- $Authorizations : AuthorizationsTable|BelongsTo
Methods
- addBranchScopeQuery() : SelectQuery
- Add branch-based data scoping to a query.
- afterDelete() : void
- After delete hook to capture impersonation audit trail entries.
- afterSave() : void
- After-save handler for automatic cache invalidation.
- buildRules() : RulesChecker
- Application integrity rules for authorization approval workflow.
- initialize() : void
- Initialize the table with associations and configuration.
- memberAuthQueueCount() : int
- Get pending approval queue count for a specific member.
- validationDefault() : Validator
- Default validation rules for authorization approval workflow data.
- logImpersonationAction() : void
- Record impersonated writes to audit log table.
Constants
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
$Approvers
public
MembersTable|BelongsTo
$Approvers
$Authorizations
public
AuthorizationsTable|BelongsTo
$Authorizations
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()
After delete hook to capture impersonation audit trail entries.
public
afterDelete(EventInterface $event, EntityInterface $entity, ArrayObject $options) : void
Parameters
- $event : EventInterface
-
Delete event
- $entity : EntityInterface
-
Entity being deleted
- $options : ArrayObject
-
Delete options
afterSave()
After-save handler for automatic cache invalidation.
public
afterSave(EventInterface $event, EntityInterface $entity, ArrayObject $options) : void
Parameters
- $event : EventInterface
-
The afterSave event
- $entity : EntityInterface
-
The saved entity
- $options : ArrayObject
-
Save options
buildRules()
Application integrity rules for authorization approval workflow.
public
buildRules(RulesChecker $rules) : RulesChecker
Rules Enforced:
authorization_idmust reference existing Authorization entityapprover_idmust reference existing Member entity
Validation Chain:
- Field validation via
validationDefault() - Referential integrity rules via
buildRules() - Database constraints at persistence time
Error Handling: Rule violations produce field-specific error messages for targeted error display in forms and API responses.
Performance: Rules use CakePHP's caching for existence checks, with queries leveraging primary key indexes for fast validation.
Parameters
- $rules : RulesChecker
-
Rules checker configuration
Tags
Return values
RulesChecker —Configured rules checker
initialize()
Initialize the table with associations and configuration.
public
initialize(array<string, mixed> $config) : void
Associations:
Authorizations(INNER JOIN): Required authorization contextApprovers(LEFT JOIN): Optional approver member context
Configuration:
- Table name:
activities_authorization_approvals - Display field:
id - Primary key:
id
Inherited Behaviors from BaseTable:
- Timestamp tracking (created, modified)
- Footprint tracking (created_by, modified_by)
- Cache integration
- Branch scoping
Parameters
- $config : array<string, mixed>
-
The configuration for the Table
Tags
memberAuthQueueCount()
Get pending approval queue count for a specific member.
public
static memberAuthQueueCount(int $memberId) : int
Returns the count of pending authorization approvals assigned to a specific member. Optimized for navigation badge display and member dashboard integration as a lightweight static query.
Query Criteria:
approver_id = $memberId: Approvals assigned to this memberresponded_on IS NULL: Pending (not yet responded)
Return Value: Integer count of pending approvals (0 if none)
Performance:
- Static method: No table instantiation overhead
- COUNT(*) query: Minimal database load
- Indexed on approver_id + responded_on
- Compatible with query caching
Common Uses:
- Navigation badge display
- Member dashboard statistics
- Approval queue monitoring
- Real-time notification systems
Parameters
- $memberId : int
-
The ID of the member
Tags
Return values
int —Count of pending approvals assigned to member
validationDefault()
Default validation rules for authorization approval workflow data.
public
validationDefault(Validator $validator) : Validator
Required Fields:
authorization_id: Integer linking to valid Authorizationapprover_id: Integer linking to valid Memberauthorization_token: String (max 255) required on creationrequested_on: Date field required on creationapproved: Boolean (required when responding)
Optional Fields:
responded_on: Date, nullable until approval decisionapprover_notes: String (max 255), nullable
Validation Chain:
- Field validation (types, lengths, presence)
- Referential integrity rules via
buildRules() - Custom business logic rules if needed
Parameters
- $validator : Validator
-
Validator configuration
Tags
Return values
Validator —Configured validator
logImpersonationAction()
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