CourtAgendaService
in package
uses
LocatorAwareTrait
Builds and mutates gathering court agendas for visual planning and print output.
Table of Contents
Constants
- LONG_AGENDA_MINUTES : mixed = 90
- LONG_SEGMENT_MINUTES : mixed = 45
- ROAMING_SEGMENT_NAME : mixed = 'Roaming Court'
Properties
- $awardActivityEligibility : array<string, bool>
- Request-local award/activity eligibility lookup keyed by "awardId:activityId".
- $syncingAgendaPlacement : bool
- Re-entrancy guard for bestowal-driven agenda placement sync.
Methods
- addBestowalToSegment() : CourtAgendaItem
- Add an eligible gathering bestowal to a court segment.
- addBlock() : CourtAgendaItem
- addSegment() : CourtAgendaSegment
- buildAgendaViewModel() : array<string, mixed>
- ensureEligibleCourtSegments() : int
- Ensure scheduled gathering activities that can present awards are represented as court lanes.
- estimateMinutesForBestowal() : int
- getOrCreateDefaultAgenda() : CourtAgenda
- importGatheringBestowals() : int
- Import bestowals already assigned to the agenda gathering.
- moveItem() : void
- moveToRoamingCourt() : CourtAgendaItem
- Move a bestowal or existing agenda item into roaming court.
- removeItem() : void
- Remove an agenda item from court planning.
- syncAgendaPlacementForBestowal() : void
- Mirror a bestowal's court assignment onto its gathering's default agenda in real time.
- updateItem() : CourtAgendaItem
- activityDisplayLabel() : string
- activityTimeLabel() : string|null
- applyAgendaPlacementForBestowal() : void
- assertBestowalCanUseSegment() : void
- assertScheduledActivityBelongsToGathering() : void
- assertSegmentCanAcceptAgendaItems() : void
- awardActivityEligibilityKey() : string
- awardLabel() : string
- bestowalAwardLabel() : string
- bestowalCanUseSegment() : bool
- bestowalsForEligibility() : array<int, Bestowal>
- clearBestowalCourtAssignment() : void
- consolidateAutoSegments() : void
- Collapse duplicate blank auto-created segments from earlier imports.
- deleteEmptyLegacyCourtSegments() : void
- durationHint() : string
- eligibleBestowalsBySegment() : array<int, array<int, Bestowal>>
- eligibleScheduledActivitiesForGathering() : array<int, object>
- Scheduled activities that can host a court: any entry whose activity type can present awards, plus entries that already have bestowals assigned to them.
- eligibleSegmentOptionsForBestowal() : array<int, string>
- eligibleSegmentOptionsFromMap() : array<int, string>
- emptyToNull() : mixed
- ensureRoamingSegment() : CourtAgendaSegment
- existingAgendaBestowalIds() : array<int, int>
- hydrateAgendaItemBestowals() : void
- isRoamingSegment() : bool
- itemLabel() : string
- moveSegmentItems() : void
- moveSegmentOptions() : array<int, string>
- nextItemSortOrder() : int
- nextSegmentSortOrder() : int
- nextSortOrder() : int
- placedBestowalIds() : array<string|int, int>
- plannedStartTimeLabel() : string|null
- Start-only label for the segment planned_start_time column (max 20 chars).
- primeAwardActivityEligibility() : void
- recommendationReasons() : array<int, string>
- recommendationSpecialties() : array<int, string>
- renumberItems() : void
- resolveSegmentForBestowalSlot() : CourtAgendaSegment|null
- Resolve (creating when needed) the agenda segment matching a bestowal's court slot.
- scheduledActivityLabel() : string
- scheduledActivityOptions() : array<int|string, string>
- segmentIdForBestowal() : int
- segmentIdForBestowalWithCache() : int
- segmentIdsByScheduledActivity() : array<int, int>
- segmentOptions() : array<int, string>
- syncBestowalPlacementFromSegment() : void
- syncBestowalStackRanksForAgenda() : void
- syncBestowalStackRanksForSegment() : void
- syncBestowalStackRanksForSegmentEntity() : void
- unscheduledBestowalData() : array<int, array<string, mixed>>
- unscheduledBestowals() : array<int, Bestowal>
Constants
LONG_AGENDA_MINUTES
private
mixed
LONG_AGENDA_MINUTES
= 90
LONG_SEGMENT_MINUTES
private
mixed
LONG_SEGMENT_MINUTES
= 45
ROAMING_SEGMENT_NAME
private
mixed
ROAMING_SEGMENT_NAME
= 'Roaming Court'
Properties
$awardActivityEligibility
Request-local award/activity eligibility lookup keyed by "awardId:activityId".
private
array<string, bool>
$awardActivityEligibility
= []
$syncingAgendaPlacement
Re-entrancy guard for bestowal-driven agenda placement sync.
private
static bool
$syncingAgendaPlacement
= false
Methods
addBestowalToSegment()
Add an eligible gathering bestowal to a court segment.
public
addBestowalToSegment(int $agendaId, int $bestowalId, int $targetSegmentId[, int|null $actorId = null ]) : CourtAgendaItem
Parameters
- $agendaId : int
-
Agenda ID.
- $bestowalId : int
-
Bestowal ID.
- $targetSegmentId : int
-
Target segment ID.
- $actorId : int|null = null
-
Actor ID.
Return values
CourtAgendaItemaddBlock()
public
addBlock(array<string, mixed> $data[, int|null $actorId = null ]) : CourtAgendaItem
Parameters
- $data : array<string, mixed>
-
Submitted block data.
- $actorId : int|null = null
-
Actor ID.
Return values
CourtAgendaItemaddSegment()
public
addSegment(array<string, mixed> $data[, int|null $actorId = null ]) : CourtAgendaSegment
Parameters
- $data : array<string, mixed>
-
Submitted segment data.
- $actorId : int|null = null
-
Actor ID.
Return values
CourtAgendaSegmentbuildAgendaViewModel()
public
buildAgendaViewModel(int $agendaId) : array<string, mixed>
Parameters
- $agendaId : int
-
Agenda ID.
Return values
array<string, mixed>ensureEligibleCourtSegments()
Ensure scheduled gathering activities that can present awards are represented as court lanes.
public
ensureEligibleCourtSegments(int $agendaId[, int|null $actorId = null ]) : int
Parameters
- $agendaId : int
-
Agenda ID.
- $actorId : int|null = null
-
Optional actor ID.
Return values
int —Number of created segments.
estimateMinutesForBestowal()
public
estimateMinutesForBestowal(object $bestowal) : int
Parameters
- $bestowal : object
-
Bestowal entity.
Return values
intgetOrCreateDefaultAgenda()
public
getOrCreateDefaultAgenda(int $gatheringId[, int|null $actorId = null ]) : CourtAgenda
Parameters
- $gatheringId : int
-
Gathering ID.
- $actorId : int|null = null
-
Optional actor ID for audit fields.
Return values
CourtAgendaimportGatheringBestowals()
Import bestowals already assigned to the agenda gathering.
public
importGatheringBestowals(int $agendaId[, int|null $actorId = null ]) : int
Parameters
- $agendaId : int
-
Agenda ID.
- $actorId : int|null = null
-
Optional actor ID.
Return values
int —Number of imported items.
moveItem()
public
moveItem(int $itemId, int $targetSegmentId, int $targetSortOrder[, int|null $actorId = null ]) : void
Parameters
- $itemId : int
-
Item ID.
- $targetSegmentId : int
-
Target segment ID.
- $targetSortOrder : int
-
Target order.
- $actorId : int|null = null
-
Actor ID.
moveToRoamingCourt()
Move a bestowal or existing agenda item into roaming court.
public
moveToRoamingCourt(int $agendaId[, int|null $itemId = null ][, int|null $bestowalId = null ][, int|null $actorId = null ]) : CourtAgendaItem
Parameters
- $agendaId : int
-
Agenda ID.
- $itemId : int|null = null
-
Optional agenda item ID.
- $bestowalId : int|null = null
-
Optional bestowal ID.
- $actorId : int|null = null
-
Actor ID.
Return values
CourtAgendaItemremoveItem()
Remove an agenda item from court planning.
public
removeItem(int $itemId[, int|null $actorId = null ]) : void
Bestowal items stay assigned to the gathering, but their court slot is cleared so they return to the eligible backlog instead of roaming court.
Parameters
- $itemId : int
-
Item ID.
- $actorId : int|null = null
-
Actor ID.
syncAgendaPlacementForBestowal()
Mirror a bestowal's court assignment onto its gathering's default agenda in real time.
public
syncAgendaPlacementForBestowal(Bestowal $bestowal[, int|null $actorId = null ]) : void
Invoked from BestowalsTable::afterSave whenever the gathering or court slot fields change, so agenda items follow the canonical bestowal fields without a manual "Refresh Scheduled Bestowals" pass: assignments create or move the bestowal's agenda item, cleared slots (or gathering moves) remove stale items. Only PRESENT bestowal items are managed — interjection blocks are untouched, and this direction never writes bestowal fields or to-dos.
Parameters
- $bestowal : Bestowal
-
Saved bestowal.
- $actorId : int|null = null
-
Actor for audit columns on created rows.
updateItem()
public
updateItem(int $itemId, array<string, mixed> $data[, int|null $actorId = null ]) : CourtAgendaItem
Parameters
- $itemId : int
-
Item ID.
- $data : array<string, mixed>
-
Submitted data.
- $actorId : int|null = null
-
Actor ID.
Return values
CourtAgendaItemactivityDisplayLabel()
private
activityDisplayLabel(object $activity) : string
Parameters
- $activity : object
-
Scheduled activity.
Return values
stringactivityTimeLabel()
private
activityTimeLabel(object $activity) : string|null
Parameters
- $activity : object
-
Scheduled activity.
Return values
string|nullapplyAgendaPlacementForBestowal()
private
applyAgendaPlacementForBestowal(Bestowal $bestowal, int|null $actorId) : void
Parameters
- $bestowal : Bestowal
-
Saved bestowal.
- $actorId : int|null
-
Actor ID.
assertBestowalCanUseSegment()
private
assertBestowalCanUseSegment(Bestowal $bestowal, CourtAgendaSegment $segment) : void
Parameters
- $bestowal : Bestowal
-
Bestowal.
- $segment : CourtAgendaSegment
-
Target segment.
assertScheduledActivityBelongsToGathering()
private
assertScheduledActivityBelongsToGathering(int $scheduledActivityId, int $gatheringId) : void
Parameters
- $scheduledActivityId : int
-
Scheduled gathering activity ID.
- $gatheringId : int
-
Agenda gathering ID.
assertSegmentCanAcceptAgendaItems()
private
assertSegmentCanAcceptAgendaItems(CourtAgendaSegment $segment) : void
Parameters
- $segment : CourtAgendaSegment
-
Segment.
awardActivityEligibilityKey()
private
awardActivityEligibilityKey(int $awardId, int $activityId) : string
Parameters
- $awardId : int
-
Award ID.
- $activityId : int
-
Gathering activity ID.
Return values
stringawardLabel()
private
awardLabel(CourtAgendaItem $item) : string
Parameters
- $item : CourtAgendaItem
-
Agenda item.
Return values
stringbestowalAwardLabel()
private
bestowalAwardLabel(Bestowal $bestowal) : string
Parameters
- $bestowal : Bestowal
-
Bestowal.
Return values
stringbestowalCanUseSegment()
private
bestowalCanUseSegment(Bestowal $bestowal, CourtAgendaSegment $segment) : bool
Parameters
- $bestowal : Bestowal
-
Bestowal.
- $segment : CourtAgendaSegment
-
Target segment.
Return values
boolbestowalsForEligibility()
private
bestowalsForEligibility(array<int, CourtAgendaSegment> $segments, array<int, Bestowal> $unscheduledBestowals) : array<int, Bestowal>
Parameters
- $segments : array<int, CourtAgendaSegment>
-
Court segments.
- $unscheduledBestowals : array<int, Bestowal>
-
Unscheduled bestowals.
Return values
array<int, Bestowal>clearBestowalCourtAssignment()
private
clearBestowalCourtAssignment(Bestowal $bestowal, int|null $actorId) : void
Parameters
- $bestowal : Bestowal
-
Bestowal.
- $actorId : int|null
-
Actor ID.
consolidateAutoSegments()
Collapse duplicate blank auto-created segments from earlier imports.
private
consolidateAutoSegments(int $agendaId, int|null $actorId) : void
Parameters
- $agendaId : int
-
Agenda ID.
- $actorId : int|null
-
Actor ID.
deleteEmptyLegacyCourtSegments()
private
deleteEmptyLegacyCourtSegments(int $agendaId) : void
Parameters
- $agendaId : int
-
Agenda ID.
durationHint()
private
durationHint(CourtAgendaItem $item) : string
Parameters
- $item : CourtAgendaItem
-
Agenda item.
Return values
stringeligibleBestowalsBySegment()
private
eligibleBestowalsBySegment(CourtAgenda $agenda, array<int, Bestowal> $unscheduled) : array<int, array<int, Bestowal>>
Parameters
- $agenda : CourtAgenda
-
Agenda.
- $unscheduled : array<int, Bestowal>
-
Unscheduled bestowals.
Return values
array<int, array<int, Bestowal>>eligibleScheduledActivitiesForGathering()
Scheduled activities that can host a court: any entry whose activity type can present awards, plus entries that already have bestowals assigned to them.
private
eligibleScheduledActivitiesForGathering(int $gatheringId) : array<int, object>
Parameters
- $gatheringId : int
-
Gathering ID.
Return values
array<int, object>eligibleSegmentOptionsForBestowal()
private
eligibleSegmentOptionsForBestowal(Bestowal $bestowal, array<int, CourtAgendaSegment> $segments) : array<int, string>
Parameters
- $bestowal : Bestowal
-
Bestowal.
- $segments : array<int, CourtAgendaSegment>
-
Court segments.
Return values
array<int, string>eligibleSegmentOptionsFromMap()
private
eligibleSegmentOptionsFromMap(Bestowal $bestowal, array<int, CourtAgendaSegment> $segments, array<int, array<int, Bestowal>> $eligibleBySegment) : array<int, string>
Parameters
- $bestowal : Bestowal
-
Bestowal.
- $segments : array<int, CourtAgendaSegment>
-
Court segments.
- $eligibleBySegment : array<int, array<int, Bestowal>>
-
Eligible bestowals by segment.
Return values
array<int, string>emptyToNull()
private
emptyToNull(mixed $value) : mixed
Parameters
- $value : mixed
-
Value.
ensureRoamingSegment()
private
ensureRoamingSegment(int $agendaId[, int|null $actorId = null ]) : CourtAgendaSegment
Parameters
- $agendaId : int
-
Agenda ID.
- $actorId : int|null = null
-
Actor ID.
Return values
CourtAgendaSegmentexistingAgendaBestowalIds()
private
existingAgendaBestowalIds(int $agendaId, array<int, Bestowal> $bestowals) : array<int, int>
Parameters
- $agendaId : int
-
Agenda ID.
- $bestowals : array<int, Bestowal>
-
Candidate bestowals.
Return values
array<int, int>hydrateAgendaItemBestowals()
private
hydrateAgendaItemBestowals(array<int, CourtAgendaSegment> $segments) : void
Parameters
- $segments : array<int, CourtAgendaSegment>
-
Court agenda segments.
isRoamingSegment()
private
isRoamingSegment(CourtAgendaSegment $segment) : bool
Parameters
- $segment : CourtAgendaSegment
-
Segment.
Return values
boolitemLabel()
private
itemLabel(CourtAgendaItem $item) : string
Parameters
- $item : CourtAgendaItem
-
Agenda item.
Return values
stringmoveSegmentItems()
private
moveSegmentItems(int $sourceSegmentId, int $targetSegmentId, int|null $actorId) : void
Parameters
- $sourceSegmentId : int
-
Source segment ID.
- $targetSegmentId : int
-
Target segment ID.
- $actorId : int|null
-
Actor ID.
moveSegmentOptions()
private
moveSegmentOptions(CourtAgendaItem $item, array<int, CourtAgendaSegment> $segments) : array<int, string>
Parameters
- $item : CourtAgendaItem
-
Agenda item.
- $segments : array<int, CourtAgendaSegment>
-
Court segments.
Return values
array<int, string>nextItemSortOrder()
private
nextItemSortOrder(int $segmentId) : int
Parameters
- $segmentId : int
-
Segment ID.
Return values
intnextSegmentSortOrder()
private
nextSegmentSortOrder(int $agendaId) : int
Parameters
- $agendaId : int
-
Agenda ID.
Return values
intnextSortOrder()
private
nextSortOrder(Table $table, string $foreignKey, int $foreignId) : int
Parameters
- $table : Table
-
Table instance.
- $foreignKey : string
-
Foreign key.
- $foreignId : int
-
Foreign ID.
Return values
intplacedBestowalIds()
private
placedBestowalIds(array<int, CourtAgendaSegment> $segments) : array<string|int, int>
Parameters
- $segments : array<int, CourtAgendaSegment>
-
Court segments.
Return values
array<string|int, int>plannedStartTimeLabel()
Start-only label for the segment planned_start_time column (max 20 chars).
private
plannedStartTimeLabel(object $activity) : string|null
Parameters
- $activity : object
-
Scheduled activity.
Return values
string|nullprimeAwardActivityEligibility()
private
primeAwardActivityEligibility(array<int, Bestowal> $bestowals, array<int, CourtAgendaSegment> $segments) : void
Parameters
- $bestowals : array<int, Bestowal>
-
Bestowals.
- $segments : array<int, CourtAgendaSegment>
-
Court segments.
recommendationReasons()
private
recommendationReasons(CourtAgendaItem $item) : array<int, string>
Parameters
- $item : CourtAgendaItem
-
Agenda item.
Return values
array<int, string>recommendationSpecialties()
private
recommendationSpecialties(CourtAgendaItem $item) : array<int, string>
Parameters
- $item : CourtAgendaItem
-
Agenda item.
Return values
array<int, string>renumberItems()
private
renumberItems(int $segmentId) : void
Parameters
- $segmentId : int
-
Segment ID.
resolveSegmentForBestowalSlot()
Resolve (creating when needed) the agenda segment matching a bestowal's court slot.
private
resolveSegmentForBestowalSlot(Bestowal $bestowal, int $gatheringId, int|null $actorId) : CourtAgendaSegment|null
Parameters
- $bestowal : Bestowal
-
Saved bestowal.
- $gatheringId : int
-
Bestowal gathering ID.
- $actorId : int|null
-
Actor ID.
Return values
CourtAgendaSegment|null —Null when the bestowal has no valid slot.
scheduledActivityLabel()
private
scheduledActivityLabel(CourtAgendaSegment $segment) : string
Parameters
- $segment : CourtAgendaSegment
-
Segment.
Return values
stringscheduledActivityOptions()
private
scheduledActivityOptions(int $gatheringId) : array<int|string, string>
Parameters
- $gatheringId : int
-
Gathering ID.
Return values
array<int|string, string>segmentIdForBestowal()
private
segmentIdForBestowal(int $agendaId, object $bestowal, int|null $actorId) : int
Parameters
- $agendaId : int
-
Agenda ID.
- $bestowal : object
-
Bestowal entity.
- $actorId : int|null
-
Actor ID.
Return values
intsegmentIdForBestowalWithCache()
private
segmentIdForBestowalWithCache(int $agendaId, object $bestowal, int|null $actorId, array<int, int> &$segmentIdsByActivity) : int
Parameters
- $agendaId : int
-
Agenda ID.
- $bestowal : object
-
Bestowal entity.
- $actorId : int|null
-
Actor ID.
- $segmentIdsByActivity : array<int, int>
-
Cached scheduled activity to segment map.
Return values
intsegmentIdsByScheduledActivity()
private
segmentIdsByScheduledActivity(array<int, CourtAgendaSegment> $segments) : array<int, int>
Parameters
- $segments : array<int, CourtAgendaSegment>
-
Court segments.
Return values
array<int, int>segmentOptions()
private
segmentOptions(array<int, CourtAgendaSegment> $segments) : array<int, string>
Parameters
- $segments : array<int, CourtAgendaSegment>
-
Court segments.
Return values
array<int, string>syncBestowalPlacementFromSegment()
private
syncBestowalPlacementFromSegment(Bestowal $bestowal, CourtAgendaSegment $segment, int|null $actorId) : void
Parameters
- $bestowal : Bestowal
-
Bestowal.
- $segment : CourtAgendaSegment
-
Target segment.
- $actorId : int|null
-
Actor ID.
syncBestowalStackRanksForAgenda()
private
syncBestowalStackRanksForAgenda(int $agendaId) : void
Parameters
- $agendaId : int
-
Agenda ID.
syncBestowalStackRanksForSegment()
private
syncBestowalStackRanksForSegment(int $segmentId) : void
Parameters
- $segmentId : int
-
Segment ID.
syncBestowalStackRanksForSegmentEntity()
private
syncBestowalStackRanksForSegmentEntity(CourtAgendaSegment $segment) : void
Parameters
- $segment : CourtAgendaSegment
-
Segment.
unscheduledBestowalData()
private
unscheduledBestowalData(array<int, Bestowal> $bestowals, array<int, CourtAgendaSegment> $segments, array<string|int, mixed> $eligibleBySegment) : array<int, array<string, mixed>>
Parameters
- $bestowals : array<int, Bestowal>
-
Unscheduled bestowals.
- $segments : array<int, CourtAgendaSegment>
-
Court segments.
- $eligibleBySegment : array<string|int, mixed>
Return values
array<int, array<string, mixed>>unscheduledBestowals()
private
unscheduledBestowals(CourtAgenda $agenda, array<string|int, int> $placedBestowalIds) : array<int, Bestowal>
Parameters
- $agenda : CourtAgenda
-
Agenda.
- $placedBestowalIds : array<string|int, int>
-
Bestowal IDs already on the agenda.