KMP PHP API Reference

OfficersTable extends BaseTable
in package

Officers Table - Officer assignment lifecycle management

Manages officer assignments with ActiveWindow temporal behavior, warrant integration, and hierarchical reporting relationships. Performs daily status checks for automatic UPCOMING → CURRENT → EXPIRED transitions.

Tags
see

/docs/5.1-officers-plugin.md

Table of Contents

Constants

CACHE_GROUPS_TO_CLEAR  = []
CACHES_TO_CLEAR  = []
ID_CACHES_TO_CLEAR  = []

Properties

$ApprovedBy  : MembersTable|BelongsTo
$Branches  : BranchesTable|BelongsTo
$CurrentWarrants  : WarrantsTable|HasOne
$DeputyToBranches  : BranchesTable|BelongsTo
$DeputyToCurrently  : OfficersTable|HasMany
$DeputyToOffices  : OfficesTable|BelongsTo
$Members  : MembersTable|BelongsTo
$Offices  : OfficesTable|BelongsTo
$PendingWarrants  : WarrantsTable|HasMany
$ReportsToBranches  : BranchesTable|BelongsTo
$ReportsToCurrently  : OfficersTable|HasMany
$ReportsToOffices  : OfficesTable|BelongsTo
$RevokedBy  : MembersTable|BelongsTo
$Warrants  : WarrantsTable|HasMany

Methods

addBranchScopeQuery()  : SelectQuery
Add branch-based data scoping to a query.
addDisplayConditionsAndFields()  : SelectQuery
Augments a SelectQuery with display-oriented fields, conditional expressions, containment, and ordering based on officer type.
afterDelete()  : void
After delete hook to capture impersonation audit trail entries.
afterSave()  : void
After-save handler for automatic cache invalidation.
buildRules()  : RulesChecker
Returns a rules checker object that will be used for validating application integrity.
findEffectiveReportsTo()  : array<string|int, Officer>
Resolve the effective officers who should receive reports for a given officer by traversing the reporting office/branch hierarchy when offices may be vacant or configured to skip reporting.
findOrCreate()  : Officer
get()  : Officer
initialize()  : void
Initialize method
newEmptyEntity()  : Officer
newEntity()  : Officer
patchEntity()  : Officer
save()  : Officer|false
saveOrFail()  : Officer
validationDefault()  : Validator
Default validation rules.
checkOfficerStatus()  : void
Check officer status.
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

addDisplayConditionsAndFields()

Augments a SelectQuery with display-oriented fields, conditional expressions, containment, and ordering based on officer type.

public addDisplayConditionsAndFields(SelectQuery $q, string $type) : SelectQuery

Adds computed display expressions for revoke reason and reporting descriptions, selects common officer fields, and configures related containment (Members, Offices, RevokedBy, warrants, reporting/deputy relations) appropriate for 'current', 'upcoming', or 'previous' officer listings.

Parameters
$q : SelectQuery

The query to modify.

$type : string

One of 'current', 'upcoming', or 'previous' to control which fields and associations are included.

Return values
SelectQuery

The modified query with added selects, containments, and ordering suitable for display.

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()

Returns a rules checker object that will be used for validating application integrity.

public buildRules(RulesChecker $rules) : RulesChecker
Parameters
$rules : RulesChecker

The rules object to be modified.

Return values
RulesChecker

findEffectiveReportsTo()

Resolve the effective officers who should receive reports for a given officer by traversing the reporting office/branch hierarchy when offices may be vacant or configured to skip reporting.

public findEffectiveReportsTo(Officer $officer[, array<string|int, string> $visitedOffices = [] ]) : array<string|int, Officer>
Parameters
$officer : Officer

The officer assignment whose effective report recipients should be resolved; its reports_to_office_id and reports_to_branch_id determine the starting point.

$visitedOffices : array<string|int, string> = []

Internal set of visited "office_branch" keys used to prevent circular traversal (for internal use; callers should not populate this).

Return values
array<string|int, Officer>

Array of officer entities that effectively receive reports for the given officer; empty array when none are found or when the resolution reaches the top-level (society).

findOrCreate()

public findOrCreate(mixed $search[, callable|null $callback = = 'null' ][, array<string|int, mixed> $options = = '[]' ]) : Officer
Parameters
$search : mixed
$callback : callable|null = = 'null'
$options : array<string|int, mixed> = = '[]'
Return values
Officer

get()

public get(mixed $primaryKey[, array<string|int, mixed>|string $finder = = '\'all\'' ][, CacheInterface|string|null $cache = = 'null' ][, Closure|string|null $cacheKey = = 'null' ], mixed ...$args) : Officer
Parameters
$primaryKey : mixed
$finder : array<string|int, mixed>|string = = '\'all\''
$cache : CacheInterface|string|null = = 'null'
$cacheKey : Closure|string|null = = 'null'
$args : mixed
Return values
Officer

initialize()

Initialize method

public initialize(array<string, mixed> $config) : void
Parameters
$config : array<string, mixed>

The configuration for the Table.

newEntity()

public newEntity(array<string|int, mixed> $data[, array<string|int, mixed> $options = = '[]' ]) : Officer
Parameters
$data : array<string|int, mixed>
$options : array<string|int, mixed> = = '[]'
Return values
Officer

patchEntity()

public patchEntity(EntityInterface $entity, array<string|int, mixed> $data[, array<string|int, mixed> $options = = '[]' ]) : Officer
Parameters
$entity : EntityInterface
$data : array<string|int, mixed>
$options : array<string|int, mixed> = = '[]'
Return values
Officer

save()

public save(EntityInterface $entity[, array<string|int, mixed> $options = = '[]' ]) : Officer|false
Parameters
$entity : EntityInterface
$options : array<string|int, mixed> = = '[]'
Return values
Officer|false

saveOrFail()

public saveOrFail(EntityInterface $entity[, array<string|int, mixed> $options = = '[]' ]) : Officer
Parameters
$entity : EntityInterface
$options : array<string|int, mixed> = = '[]'
Return values
Officer

validationDefault()

Default validation rules.

public validationDefault(Validator $validator) : Validator
Parameters
$validator : Validator

Validator instance.

Return values
Validator

checkOfficerStatus()

Check officer status.

protected checkOfficerStatus() : void

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