KMP PHP API Reference

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_approvals table
  • 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 configuration
  • validationDefault(): Field validation rules
  • buildRules(): Referential integrity rules
  • memberAuthQueueCount(): 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
see
AuthorizationApproval

Authorization approval entity

see

5.6.8-authorization-approval-entity-reference.md Comprehensive technical reference

see
AuthorizationManagerInterface

Authorization workflow service

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

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_id must reference existing Authorization entity
  • approver_id must reference existing Member entity

Validation Chain:

  1. Field validation via validationDefault()
  2. Referential integrity rules via buildRules()
  3. 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
see
AuthorizationsTable

Authorization existence check

see
MembersTable

Approver existence check

see
RulesChecker

CakePHP rules checker documentation

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 context
  • Approvers (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
see
AuthorizationsTable

Authorization context

see
MembersTable

Approver member information

see
BaseTable

Inherited behaviors

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 member
  • responded_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
see
AuthorizationApproval

Authorization approval entity

see

5.6.8-authorization-approval-entity-reference.md Technical reference

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 Authorization
  • approver_id: Integer linking to valid Member
  • authorization_token: String (max 255) required on creation
  • requested_on: Date field required on creation
  • approved: Boolean (required when responding)

Optional Fields:

  • responded_on: Date, nullable until approval decision
  • approver_notes: String (max 255), nullable

Validation Chain:

  1. Field validation (types, lengths, presence)
  2. Referential integrity rules via buildRules()
  3. Custom business logic rules if needed
Parameters
$validator : Validator

Validator configuration

Tags
see
AuthorizationApproval

Entity field mappings

see
Table::buildRules()

For referential integrity rules

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


        
On this page

Search results