DefaultOfficerManager
in package
implements
OfficerManagerInterface
uses
QueuedMailerAwareTrait, MailerAwareTrait
Default implementation of OfficerManagerInterface for officer lifecycle management.
Handles officer assignment, release, and recalculation operations with integrated warrant management, role assignment, and notification processing.
Tags
Table of Contents
Interfaces
- OfficerManagerInterface
- Service contract for officer lifecycle management operations.
Properties
- $mailer : Mailer
- $activeWindowManager : ActiveWindowManagerInterface
- $warrantManager : WarrantManagerInterface
Methods
- __construct() : mixed
- assign() : ServiceResult
- Assign a member to an office within a branch, persisting the Officer record, establishing reporting/deputy relationships, starting the ActiveWindow lifecycle, optionally requesting a warrant, and queuing a hire notification.
- recalculateOfficersForOffice() : ServiceResult
- Recalculate reporting relationships and roles for all current/upcoming officers of an office.
- release() : ServiceResult
- Release an officer from their position.
- queueMail() : Mailer
- Returns a mailer instance.
- queueMailJob() : void
- Queues a mail job to be processed later.
- sendMailNow() : Mailer
- Returns a mailer instance.
- _calculateOfficerReportingFields() : array<string|int, mixed>
- Calculate reporting relationship fields for an officer based on office configuration.
Properties
$mailer
protected
Mailer
$mailer
$activeWindowManager
private
ActiveWindowManagerInterface
$activeWindowManager
$warrantManager
private
WarrantManagerInterface
$warrantManager
Methods
__construct()
public
__construct(ActiveWindowManagerInterface $activeWindowManager, WarrantManagerInterface $warrantManager) : mixed
Parameters
- $activeWindowManager : ActiveWindowManagerInterface
-
Temporal assignment management
- $warrantManager : WarrantManagerInterface
-
Warrant lifecycle coordination
assign()
Assign a member to an office within a branch, persisting the Officer record, establishing reporting/deputy relationships, starting the ActiveWindow lifecycle, optionally requesting a warrant, and queuing a hire notification.
public
assign(int $officeId, int $memberId, int $branchId, DateTime $startOn, DateTime|null $endOn, string|null $deputyDescription, int $approverId, string|null $emailAddress) : ServiceResult
Parameters
- $officeId : int
-
Office identifier for the assignment target.
- $memberId : int
-
Member identifier being assigned to the office.
- $branchId : int
-
Branch identifier providing organizational context.
- $startOn : DateTime
-
Assignment start date.
- $endOn : DateTime|null
-
Optional assignment end date; if null, may be derived from the office term length.
- $deputyDescription : string|null
-
Optional deputy description for deputy assignments.
- $approverId : int
-
Identifier of the approver performing the assignment.
- $emailAddress : string|null
-
Optional email address to store on the Officer record and use for notifications.
Return values
ServiceResult —ServiceResult with success === true on success; on failure success === false and reason contains an error message.
recalculateOfficersForOffice()
Recalculate reporting relationships and roles for all current/upcoming officers of an office.
public
recalculateOfficersForOffice(int $officeId, int $updaterId) : ServiceResult
Call when office deputy_to_id, reports_to_id, or grants_role_id changes. Uses fail-fast error handling - stops on first failure.
Parameters
- $officeId : int
-
The office ID for officers requiring recalculation
- $updaterId : int
-
The updater ID for audit trail and role change tracking
Return values
ServiceResult —Result with updated_count, current_count, upcoming_count on success
release()
Release an officer from their position.
public
release(int $officerId, int $revokerId, DateTime $revokedOn, string|null $revokedReason[, string|null $releaseStatus = Officer::RELEASED_STATUS ]) : ServiceResult
Handles ActiveWindow termination, warrant cancellation for warrant-required offices, and sends release notification to the member.
Parameters
- $officerId : int
-
Officer identifier
- $revokerId : int
-
Administrator performing the release
- $revokedOn : DateTime
-
Effective release date
- $revokedReason : string|null
-
Optional reason for release
- $releaseStatus : string|null = Officer::RELEASED_STATUS
-
Status to set (defaults to RELEASED_STATUS)
Return values
ServiceResult —Success or failure with reason
queueMail()
Returns a mailer instance.
protected
queueMail(string $name, mixed $action, mixed $to, mixed $vars) : Mailer
Parameters
- $name : string
-
Mailer's name.
- $action : mixed
- $to : mixed
- $vars : mixed
Tags
Return values
MailerqueueMailJob()
Queues a mail job to be processed later.
protected
queueMailJob(array<string|int, mixed> $data) : void
Parameters
- $data : array<string|int, mixed>
-
Data to be passed to the mailer.
sendMailNow()
Returns a mailer instance.
protected
sendMailNow(array<string|int, mixed> $data) : Mailer
Parameters
- $data : array<string|int, mixed>
Tags
Return values
Mailer_calculateOfficerReportingFields()
Calculate reporting relationship fields for an officer based on office configuration.
private
_calculateOfficerReportingFields(object $office, object $officer) : array<string|int, mixed>
Parameters
- $office : object
-
The office entity with deputy_to_id, reports_to_id, and can_skip_report fields
- $officer : object
-
The officer entity with branch_id
Return values
array<string|int, mixed> —Associative array with reports_to_office_id, reports_to_branch_id, deputy_to_office_id, deputy_to_branch_id, deputy_description