KMP PHP API Reference

RecommendationsController extends AppController
in package
uses DataverseGridTrait

Recommendations Controller

Manages the complete award recommendation lifecycle from submission through final disposition. Implements state machine-based workflow with table and kanban views. Supports authenticated and public submission workflows.

Uses DataverseGridTrait for table-based data display.

Table of Contents

Constants

VIEW_DATA_EVENT  = 'KMP.plugins.callForViewData'
VIEW_PLUGIN_EVENT  = 'KMP.plugins.callForViewCells'

Properties

$Recommendations  : RecommendationsTable
$isCsvRequest  : bool
$pluginViewCells  : array<string|int, mixed>

Methods

add()  : Response|null|void
Display the recommendation submission form for authenticated users and process posted submissions.
beforeFilter()  : Response|null|void
Configure authentication - allows unauthenticated submitRecommendation.
delete()  : Response|null
Delete a recommendation with transaction safety.
edit()  : Response|null|void
Edit an existing recommendation with member data synchronization.
gatheringAwardsGridData()  : Response|null|void
Grid Data for "Gathering Awards" context
gatheringsAutoComplete()  : void
Return gathering autocomplete options for recommendation edit/quick-edit forms.
gatheringsForAward()  : void
Return gatherings linked to an award, optionally including attendance indicators for a member.
gatheringsForBulkEdit()  : void
Build and return a JSON list of gatherings suitable for bulk-editing the selected recommendations.
gatheringsForBulkEditAutoComplete()  : void
Return gathering autocomplete options for bulk edit modal.
getFilteredGatheringsForAward()  : array<string|int, mixed>
Retrieve gatherings linked to an award and format them for display, optionally marking member attendance.
gridData()  : Response|null|void
Grid Data method - provides data for the Dataverse grid
index()  : Response|null|void
Recommendation system landing page.
initialize()  : void
Initialize Awards Plugin Base Controller.
isCsvRequest()  : bool
Check if current request is for CSV export.
kanbanUpdate()  : Response
Handle AJAX kanban board state transitions via drag-and-drop.
memberSubmittedRecsGridData()  : Response|null|void
Grid Data for "Submitted By Member" context
recsForMemberGridData()  : Response|null|void
Grid Data for "Recs For Member" context
submitRecommendation()  : Response|null
Render and process the public recommendation submission form for guest users.
switchView()  : Response
Switch between mobile and desktop view modes.
turboBulkEditForm()  : Response|null|void
Render the Turbo Frame bulk edit form for modifying multiple recommendations at once.
turboEditForm()  : Response|null
Render a populated edit form for a recommendation intended for Turbo Frame partial updates.
turboQuickEditForm()  : Response|null
Render a streamlined Turbo Frame quick-edit form for a recommendation.
updateStates()  : Response|null
Perform a transactional bulk state transition and related updates for multiple recommendations.
view()  : Response|null
Display a single recommendation with its workflow context and related entities.
applyCustomFilterHandlers()  : SelectQuery
Apply custom filter handlers for columns with complex filtering logic
applyHiddenStateVisibility()  : SelectQuery
Apply hidden-state visibility constraints to a recommendations query.
applyStateFilterOptionsToGridResult()  : array<string|int, mixed>
Inject dynamic state filter options into a Dataverse grid result payload.
authorizeCurrentUrl()  : void
Authorize the current URL/action via Authorization component.
buildDataverseGridState()  : array<string|int, mixed>
Build complete grid state object (single source of truth)
buildExportDataFromEntities()  : array<string|int, mixed>
Build export data from pre-processed entities (Data Mode)
buildExportDataFromQuery()  : array<string|int, mixed>
Build export data from database query (Query Mode)
buildGatheringsExportValue()  : string
Build gatherings export text showing combined recommendation events and member attendance.
buildGatheringsHtml()  : string
Build gatherings HTML showing combined recommendation events and member attendance.
buildNotesHtml()  : string
Build notes HTML for recommendation with popover showing all notes
buildOpLinksHtml()  : string
Build OP (Order of Precedence) links HTML for a recommendation
buildReasonHtml()  : string
Build reason HTML with popover for full text if it exceeds 50 characters
extractExportValue()  : string
Extract export value from entity using column metadata
extractFilterFromExpression()  : mixed
Recursively extract a filter value from an expression tree
extractFilterFromSystemView()  : mixed
Extract a specific filter value from a system view configuration
extractFilterFromViewConfig()  : mixed
Extract a specific filter value from a saved user view's config
extractFilterGrouping()  : array<string|int, mixed>
Extract filter grouping information from expression tree
extractSystemViewDefaults()  : array{filters: array, dateRange: array, search: ?string, skipFilterColumns: array}
Extract default filters/search metadata for a system view configuration
formatExportValue()  : string
Format value for CSV export
getMemberAttendanceGatherings()  : array<int, array<string|int, Gathering>>
Fetch gatherings where members are attending with share_with_crown or share_with_kingdom enabled.
handleCsvExport()  : Response
Handle CSV export from grid result
isCsvExportRequest()  : bool
Check if the current request is for CSV export
loadFilterOptions()  : array<string|int, mixed>
Load filter options from a data source
organizeViewCells()  : array<string|int, mixed>
Organize view cells by type and display order.
prepareRecommendationsForExport()  : iterable<string|int, mixed>
Prepare recommendations for CSV export with computed fields
processDataverseGrid()  : array<string|int, mixed>
Process dataverse grid request with unified logic
resolveNestedValue()  : mixed
Resolve nested value from entity using dot notation path

Constants

VIEW_DATA_EVENT

public string VIEW_DATA_EVENT = 'KMP.plugins.callForViewData'

Event for plugin view data enhancement

VIEW_PLUGIN_EVENT

public string VIEW_PLUGIN_EVENT = 'KMP.plugins.callForViewCells'

Event for plugin view cell registration

Properties

$isCsvRequest

protected bool $isCsvRequest = false

Whether current request is for CSV export (.csv extension)

$pluginViewCells

protected array<string|int, mixed> $pluginViewCells = []

View cells from plugins for current request

Methods

add()

Display the recommendation submission form for authenticated users and process posted submissions.

public add() : Response|null|void

Creates a new Recommendation linked to the current user, optionally associates member data and preferences, initializes workflow state fields and court preference defaults, saves the record within a database transaction, and either redirects on success or re-renders the form with dropdown data (awards, domains, levels, branches, gatherings).

Tags
see
submitRecommendation()

For the unauthenticated public submission workflow

see
view()

For recommendation detail display after submission

see
Recommendation

For recommendation entity structure

Return values
Response|null|void

Redirects on successful submission or renders the form on GET / validation failure

beforeFilter()

Configure authentication - allows unauthenticated submitRecommendation.

public beforeFilter(EventInterface $event) : Response|null|void
Parameters
$event : EventInterface

The beforeFilter event instance

Return values
Response|null|void

delete()

Delete a recommendation with transaction safety.

public delete([string|null $id = null ]) : Response|null

Performs soft deletion of the recommendation after authorization validation.

Parameters
$id : string|null = null

Recommendation ID to delete

Tags
throws
NotFoundException

When recommendation not found

Return values
Response|null

Redirects to index page after deletion

edit()

Edit an existing recommendation with member data synchronization.

public edit([string|null $id = null ]) : Response|null|void

Handles recommendation updates including member assignment changes, court preference synchronization, and optional note creation within a database transaction.

Parameters
$id : string|null = null

Recommendation ID to edit

Tags
throws
NotFoundException

When recommendation not found

Return values
Response|null|void

Redirects on successful edit or to current page

gatheringAwardsGridData()

Grid Data for "Gathering Awards" context

public gatheringAwardsGridData(CsvExportService $csvExportService, RecommendationQueryService $queryService[, int|null $gatheringId = null ]) : Response|null|void

Provides recommendation data for recommendations scheduled at a specific gathering. Used in the gathering detail's "Awards" tab.

Parameters
$csvExportService : CsvExportService

Injected CSV export service

$queryService : RecommendationQueryService
$gatheringId : int|null = null

The gathering ID whose scheduled recommendations to show

Return values
Response|null|void

Renders view or returns CSV response

gatheringsAutoComplete()

Return gathering autocomplete options for recommendation edit/quick-edit forms.

public gatheringsAutoComplete([string|null $awardId = null ]) : void

Returns Ajax HTML list items consumed by the shared auto-complete controller.

Parameters
$awardId : string|null = null

Award ID for gathering activity filtering.

gatheringsForAward()

Return gatherings linked to an award, optionally including attendance indicators for a member.

public gatheringsForAward([string|null $awardId = null ]) : void

Renders a JSON array where each item contains: id, name, display (formatted branch and date range, with an appended * when the member is attending and sharing with crown), has_attendance, and share_with_crown.

Parameters
$awardId : string|null = null

The award ID to filter gatherings for.

Tags
throws
NotFoundException

When the specified award cannot be found.

gatheringsForBulkEdit()

Build and return a JSON list of gatherings suitable for bulk-editing the selected recommendations.

public gatheringsForBulkEdit() : void

Determines gatherings that offer activities common to all awards referenced by the provided recommendation IDs, optionally limits to future gatherings depending on the supplied status, and includes attendance counts for members referenced by the recommendations when they share attendance with Crown. Expects a POST request with ids (array of recommendation ids) and optional status; skips authorization and renders a JSON payload with a gatherings array (each item contains id, name, display, and attendance_count).

gatheringsForBulkEditAutoComplete()

Return gathering autocomplete options for bulk edit modal.

public gatheringsForBulkEditAutoComplete() : void

Returns Ajax HTML list items consumed by the shared auto-complete controller.

getFilteredGatheringsForAward()

Retrieve gatherings linked to an award and format them for display, optionally marking member attendance.

public getFilteredGatheringsForAward(int $awardId[, int|null $memberId = null ][, bool $futureOnly = true ][, int|null $includeGatheringId = null ][, array<string|int, int> $includeGatheringIds = [] ]) : array<string|int, mixed>
Parameters
$awardId : int

The award ID whose linked gatherings should be returned.

$memberId : int|null = null

Optional member ID; when provided, gatherings the member attends with share_with_crown enabled are marked.

$futureOnly : bool = true

When true, include only gatherings with a start date in the future.

$includeGatheringId : int|null = null

If provided, ensure this gathering ID is included in the results even if it would be excluded by the activity or date filters.

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

Additional gathering IDs to include (for recommendation-selected gatherings).

Return values
array<string|int, mixed>

Associative array mapping gathering ID => formatted display string ("Name in Branch on YYYY-MM-DD - YYYY-MM-DD"); entries with an asterisk indicate the member is attending and sharing with crown.

gridData()

Grid Data method - provides data for the Dataverse grid

public gridData(CsvExportService $csvExportService, RecommendationQueryService $queryService) : Response|null|void

This method handles the AJAX requests from the dv_grid element, providing recommendation data with proper filtering, sorting, pagination, and authorization. It supports status-based system views and permission-based state filtering.

Parameters
$csvExportService : CsvExportService

Injected CSV export service

$queryService : RecommendationQueryService
Return values
Response|null|void

Renders view or returns CSV response

index()

Recommendation system landing page.

public index() : Response|null|void

Primary entry point rendering the Dataverse grid interface. Grid data is loaded lazily via gridData() action.

Return values
Response|null|void

initialize()

Initialize Awards Plugin Base Controller.

public initialize() : void

Loads Authentication, Authorization, and Flash components.

isCsvRequest()

Check if current request is for CSV export.

public isCsvRequest() : bool
Return values
bool

kanbanUpdate()

Handle AJAX kanban board state transitions via drag-and-drop.

public kanbanUpdate(RecommendationStateService $stateService[, string|null $id = null ]) : Response

Updates recommendation state and position within kanban columns. Supports placeBefore/placeAfter positioning for stack ranking.

Parameters
$stateService : RecommendationStateService
$id : string|null = null

Recommendation ID to update

Tags
throws
NotFoundException

When recommendation not found

Return values
Response

JSON response indicating success or failure

memberSubmittedRecsGridData()

Grid Data for "Submitted By Member" context

public memberSubmittedRecsGridData(CsvExportService $csvExportService, RecommendationQueryService $queryService[, int|null $memberId = null ]) : Response|null|void

Provides recommendation data for recommendations submitted by a specific member. Used in the member profile's "Submitted Award Recs" tab.

Parameters
$csvExportService : CsvExportService

Injected CSV export service

$queryService : RecommendationQueryService
$memberId : int|null = null

The member ID whose submissions to show (-1 for current user)

Return values
Response|null|void

Renders view or returns CSV response

recsForMemberGridData()

Grid Data for "Recs For Member" context

public recsForMemberGridData(CsvExportService $csvExportService, RecommendationQueryService $queryService[, int|null $memberId = null ]) : Response|null|void

Provides recommendation data for recommendations about a specific member. Used in the member profile's "Recs For Member" tab.

Parameters
$csvExportService : CsvExportService

Injected CSV export service

$queryService : RecommendationQueryService
$memberId : int|null = null

The member ID whose received recommendations to show

Return values
Response|null|void

Renders view or returns CSV response

submitRecommendation()

Render and process the public recommendation submission form for guest users.

public submitRecommendation() : Response|null

Presents a guest-facing form to submit award recommendations and handles form submissions, creating a new recommendation record while applying necessary defaults and minimal member-data integration when a matching member is provided.

Tags
see
add()

For authenticated member submission workflow

see
beforeFilter()

For authentication bypass configuration

Return values
Response|null

Redirects authenticated users or after successful redirects; otherwise renders the form.

switchView()

Switch between mobile and desktop view modes.

public switchView() : Response

Stores preference in session and redirects to appropriate interface. Mobile redirects to viewMobileCard, desktop to profile.

Return values
Response

Redirect response

turboBulkEditForm()

Render the Turbo Frame bulk edit form for modifying multiple recommendations at once.

public turboBulkEditForm(RecommendationFormService $formService) : Response|null|void

Prepares dropdowns and supporting data for bulk operations (branches, gatherings, state/status options and state rules) and exposes them to the view as rules, branches, gatheringList, and statusList.

Parameters
$formService : RecommendationFormService
Tags
throws
InternalErrorException

When preparation of bulk form data fails.

see
updateStates()

For bulk state transition processing

see
turboEditForm()

For individual recommendation editing

see
StaticHelpers::getAppSetting()

For configuration loading

Return values
Response|null|void

The response when rendering the bulk edit form template, or null when rendering proceeds in-controller.

turboEditForm()

Render a populated edit form for a recommendation intended for Turbo Frame partial updates.

public turboEditForm(RecommendationFormService $formService[, string|null $id = null ]) : Response|null

Loads the recommendation and related lookup data (awards, domains, branches, gatherings, state rules) and exposes them to the view so the Turbo Frame can display an in-place edit form.

Parameters
$formService : RecommendationFormService
$id : string|null = null

Recommendation ID to load for the form

Tags
throws
NotFoundException

If the recommendation cannot be found

see
edit()

For form submission handling

see
turboQuickEditForm()

For a streamlined quick-edit variant

Return values
Response|null

A Response when the action issues an explicit response, or null after setting view variables for rendering

turboQuickEditForm()

Render a streamlined Turbo Frame quick-edit form for a recommendation.

public turboQuickEditForm(RecommendationFormService $formService[, string|null $id = null ]) : Response|null

Provides a minimal edit form containing the most commonly changed fields, populated with essential dropdowns (awards, branches, gatherings, status) and state rules to support rapid in-place edits.

Parameters
$formService : RecommendationFormService
$id : string|null = null

Recommendation ID to load for the quick-edit form.

Tags
throws
NotFoundException

If the recommendation cannot be found.

see
turboEditForm()

For the full edit interface

see
edit()

For form submission handling

see
kanbanUpdate()

For drag-and-drop state transitions

Return values
Response|null

Renders the quick-edit template or null when rendering within a Turbo Frame.

updateStates()

Perform a transactional bulk state transition and related updates for multiple recommendations.

public updateStates(RecommendationStateService $stateService) : Response|null

Updates the selected recommendations' state and corresponding status, and optionally sets gathering assignment, given date, and close reason. When a note is provided, an administrative note is created for each affected recommendation attributed to the current user. All changes are applied inside a transaction and will be committed on success or rolled back on failure.

Redirects to the provided current_page request value when present, otherwise redirects to the table view for the current view/status. Flash messages are set to indicate success or failure.

Parameters
$stateService : RecommendationStateService
Tags
see
Recommendation::getStatuses()

For state → status mapping

see
NotesTable

For note creation and management

Return values
Response|null

Redirects to configured page or back to table view

view()

Display a single recommendation with its workflow context and related entities.

public view([string|null $id = null ]) : Response|null

Loads the recommendation together with related data (requester, member, branch, award, gatherings) and authorizes view access before exposing the entity to the view layer.

Parameters
$id : string|null = null

The recommendation ID to display.

Tags
throws
NotFoundException

If the recommendation does not exist or is inaccessible.

Return values
Response|null

The response for the rendered view, or null if the controller does not return a response.

applyCustomFilterHandlers()

Apply custom filter handlers for columns with complex filtering logic

protected applyCustomFilterHandlers(SelectQuery $query, array<string|int, mixed> $customFilterColumns, string $tableName, bool $canFilter, array<string|int, mixed> $currentFilters, mixed $currentView, array<string|int, mixed>|null $selectedSystemView, bool $dirtyFilters) : SelectQuery

Columns can define a customFilterHandler in their metadata to specify a static method that handles their filtering. This allows complex filter logic (like querying multiple tables) to be defined alongside the column definition rather than requiring special controller knowledge.

Filter values are extracted from:

  1. Query string parameters (user-applied filters)
  2. Saved user view configuration (when loading a saved view)
  3. System view configuration (when loading a system view)
Parameters
$query : SelectQuery

The query to filter

$customFilterColumns : array<string|int, mixed>

Columns with customFilterHandler defined

$tableName : string

The main table name

$canFilter : bool

Whether user filtering is enabled

$currentFilters : array<string|int, mixed>

Current filter values from query params

$currentView : mixed

Current saved user view (or null)

$selectedSystemView : array<string|int, mixed>|null

Current system view config (or null)

$dirtyFilters : bool

Whether user explicitly modified filters

Return values
SelectQuery

The filtered query

applyHiddenStateVisibility()

Apply hidden-state visibility constraints to a recommendations query.

protected applyHiddenStateVisibility(SelectQuery $query, bool $canViewHidden) : SelectQuery

Delegate to RecommendationQueryService::applyHiddenStateVisibility() instead.

Parameters
$query : SelectQuery

Recommendations query

$canViewHidden : bool

Whether hidden rows may be included

Return values
SelectQuery

applyStateFilterOptionsToGridResult()

Inject dynamic state filter options into a Dataverse grid result payload.

protected applyStateFilterOptionsToGridResult(array<string|int, mixed> $result, bool $canViewHidden) : array<string|int, mixed>
Parameters
$result : array<string|int, mixed>

Dataverse grid processing result.

$canViewHidden : bool

Whether hidden states should be included.

Return values
array<string|int, mixed>

Updated grid result with state filter options in metadata and gridState.

authorizeCurrentUrl()

Authorize the current URL/action via Authorization component.

protected authorizeCurrentUrl() : void
Tags
throws
ForbiddenException

When authorization fails

buildDataverseGridState()

Build complete grid state object (single source of truth)

protected buildDataverseGridState(mixed $currentView, array<string|int, mixed>|null $selectedSystemView, array<string|int, mixed>|null $systemViews, iterable<string|int, mixed> $availableViews, Member|null $currentMember, string|int|null $preferredViewId, string $search, array<string|int, mixed> $filters, array<string|int, mixed> $filterOptions, array<string|int, mixed> $dropdownFilterColumns, array<string|int, mixed> $dateRangeFilterColumns, array<string|int, mixed> $sort, array<string|int, mixed> $visibleColumns, array<string|int, mixed> $allColumns, string $gridKey, int $pageSize, bool $showAllTab, bool $canAddViews, bool $canFilter, bool $hasSearch, bool $hasDropdownFilters, bool $hasDateRangeFilters, array<string|int, mixed> $skipFilterColumns, bool $canExportCsv, bool $showFilterPills, bool $showViewTabs, bool $enableColumnPicker[, array<string|int, mixed> $lockedFilters = [] ][, bool $enableBulkSelection = false ][, array<string|int, mixed> $bulkActions = [] ]) : array<string|int, mixed>
Parameters
$currentView : mixed

Current saved view entity (null for system views or "All")

$selectedSystemView : array<string|int, mixed>|null

Currently selected system view

$systemViews : array<string|int, mixed>|null

All available system views

$availableViews : iterable<string|int, mixed>

Collection of saved views

$currentMember : Member|null

Authenticated member

$preferredViewId : string|int|null

Preferred view ID from user preferences

$search : string

Current search term

$filters : array<string|int, mixed>

Active filters by column key

$filterOptions : array<string|int, mixed>

Available filter options by column key

$dropdownFilterColumns : array<string|int, mixed>

Metadata for filterable columns

$dateRangeFilterColumns : array<string|int, mixed>
$sort : array<string|int, mixed>

Current sort configuration

$visibleColumns : array<string|int, mixed>

Array of visible column keys

$allColumns : array<string|int, mixed>

Complete column metadata

$gridKey : string

Unique grid identifier

$pageSize : int

Number of rows per page

$showAllTab : bool

Whether to show "All" tab

$canAddViews : bool

Whether users can create custom views

$canFilter : bool

Whether filtering is enabled

$hasSearch : bool
$hasDropdownFilters : bool
$hasDateRangeFilters : bool
$skipFilterColumns : array<string|int, mixed>

Columns with filter UI but not query application

$canExportCsv : bool

Whether CSV export button is shown

$showFilterPills : bool

Whether active filter pills/badges are displayed

$showViewTabs : bool

Whether view tabs are displayed

$enableColumnPicker : bool

Whether column picker is available

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

Filter column keys that cannot be removed by users

$enableBulkSelection : bool = false
$bulkActions : array<string|int, mixed> = []
Return values
array<string|int, mixed>

Complete grid state

buildExportDataFromEntities()

Build export data from pre-processed entities (Data Mode)

protected buildExportDataFromEntities(iterable<string|int, mixed> $data, array<string|int, mixed> $visibleColumns, array<string|int, mixed> $columnsMetadata) : array<string|int, mixed>

Extracts values from entities using column metadata configuration. Supports virtual properties, nested relations via renderField, and custom exportValue callbacks.

Parameters
$data : iterable<string|int, mixed>

Pre-processed entities or arrays

$visibleColumns : array<string|int, mixed>

List of visible column keys

$columnsMetadata : array<string|int, mixed>

Column configuration metadata

Return values
array<string|int, mixed>

Transformed data ready for CSV export

buildExportDataFromQuery()

Build export data from database query (Query Mode)

protected buildExportDataFromQuery(Query $query, array<string|int, mixed> $visibleColumns, array<string|int, mixed> $columnsMetadata, string $tableName) : array<string|int, mixed>

Builds SQL SELECT statements and executes query for simple database fields. Best for exports that don't require computed fields.

Parameters
$query : Query

Database query to execute

$visibleColumns : array<string|int, mixed>

List of visible column keys

$columnsMetadata : array<string|int, mixed>

Column configuration metadata

$tableName : string

Full table name for model alias extraction

Return values
array<string|int, mixed>

Transformed data ready for CSV export

buildGatheringsExportValue()

Build gatherings export text showing combined recommendation events and member attendance.

protected buildGatheringsExportValue(Recommendation $recommendation[, array<string|int, mixed> $attendanceGatherings = [] ]) : string

Attendance gatherings are marked with a text suffix to replace the UI icon.

Parameters
$recommendation : Recommendation

The recommendation entity

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

Optional array of gatherings from member attendance

Return values
string

Text string with gathering information for exports

buildGatheringsHtml()

Build gatherings HTML showing combined recommendation events and member attendance.

protected buildGatheringsHtml(Recommendation $recommendation[, array<string|int, mixed> $attendanceGatherings = [] ]) : string

Displays up to 3 gatherings with a "more" link to expand if there are more. Attendance gatherings (from GatheringAttendances with share_with_crown or share_with_kingdom) are shown with a person-check icon to distinguish from recommendation-linked events.

Parameters
$recommendation : Recommendation

The recommendation entity

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

Optional array of gatherings from member attendance

Return values
string

HTML string with gathering information

buildNotesHtml()

Build notes HTML for recommendation with popover showing all notes

protected buildNotesHtml(Recommendation $recommendation) : string

Displays note count with a popover button that shows all notes when clicked.

Parameters
$recommendation : Recommendation

The recommendation entity

Return values
string

HTML string with notes count and popover

buildOpLinksHtml()

Build OP (Order of Precedence) links HTML for a recommendation

protected buildOpLinksHtml(Recommendation $recommendation) : string
Parameters
$recommendation : Recommendation

The recommendation entity

Return values
string

HTML string with OP links

buildReasonHtml()

Build reason HTML with popover for full text if it exceeds 50 characters

protected buildReasonHtml(Recommendation $recommendation) : string

Uses Bootstrap popover to show full text without expanding the column.

Parameters
$recommendation : Recommendation

The recommendation entity

Return values
string

HTML string with reason, truncated with popover if needed

extractExportValue()

Extract export value from entity using column metadata

protected extractExportValue(mixed $entity, string $columnKey, array<string|int, mixed> $columnMeta) : string

Resolution order:

  1. exportValue callback if defined in column metadata
  2. renderField path for nested entity access (e.g., 'member.name_for_herald')
  3. Direct property access using column key
Parameters
$entity : mixed

Entity or array to extract value from

$columnKey : string

Column key identifier

$columnMeta : array<string|int, mixed>

Column metadata configuration

Return values
string

Extracted and formatted value

extractFilterFromExpression()

Recursively extract a filter value from an expression tree

protected extractFilterFromExpression(array<string|int, mixed> $expression, string $columnKey) : mixed
Parameters
$expression : array<string|int, mixed>

The expression node to search

$columnKey : string

The column key to find

Return values
mixed

The filter value or null if not found

extractFilterFromSystemView()

Extract a specific filter value from a system view configuration

protected extractFilterFromSystemView(array<string|int, mixed> $systemView, string $columnKey) : mixed
Parameters
$systemView : array<string|int, mixed>

The system view configuration

$columnKey : string

The column key to find

Return values
mixed

The filter value or null if not found

extractFilterFromViewConfig()

Extract a specific filter value from a saved user view's config

protected extractFilterFromViewConfig(mixed $view, string $columnKey) : mixed
Parameters
$view : mixed

The GridView entity

$columnKey : string

The column key to find

Return values
mixed

The filter value or null if not found

extractFilterGrouping()

Extract filter grouping information from expression tree

protected extractFilterGrouping(array<string|int, mixed>|null $selectedSystemView, array<string|int, mixed> $skipFilterColumns) : array<string|int, mixed>

Analyzes the expression tree to determine OR relationships between filters. Returns metadata that the frontend can use to display visual OR indicators.

Parameters
$selectedSystemView : array<string|int, mixed>|null

Currently active system view

$skipFilterColumns : array<string|int, mixed>

Columns that show as pills but don't query

Return values
array<string|int, mixed>

Grouping metadata with 'orGroups' array

extractSystemViewDefaults()

Extract default filters/search metadata for a system view configuration

protected extractSystemViewDefaults(array<string, mixed> $systemViewConfig) : array{filters: array, dateRange: array, search: ?string, skipFilterColumns: array}
Parameters
$systemViewConfig : array<string, mixed>

Raw system view config

Return values
array{filters: array, dateRange: array, search: ?string, skipFilterColumns: array}

formatExportValue()

Format value for CSV export

protected formatExportValue(mixed $value) : string

Handles various data types and converts to string representation.

Parameters
$value : mixed

Value to format

Return values
string

Formatted string value

getMemberAttendanceGatherings()

Fetch gatherings where members are attending with share_with_crown or share_with_kingdom enabled.

protected getMemberAttendanceGatherings(iterable<string|int, mixed> $recommendations) : array<int, array<string|int, Gathering>>

Retrieves attendance records for all unique member_ids in the recommendations set and returns a map of member_id => array of gathering entities.

Parameters
$recommendations : iterable<string|int, mixed>

Collection of recommendation entities

Return values
array<int, array<string|int, Gathering>>

Map of member_id to gatherings array

handleCsvExport()

Handle CSV export from grid result

protected handleCsvExport(array<string|int, mixed> $result, CsvExportService $csvExportService, string $entityName[, string|null $tableName = null ][, iterable<string|int, mixed>|null $data = null ]) : Response

Generates a CSV export response from the grid processing result. Supports two modes:

  1. Query Mode (default): Uses the query from result to build SQL SELECT statements. Best for simple fields that map directly to database columns.

  2. Data Mode: Pass pre-processed data with computed/virtual fields already populated. Best for exports that include calculated fields, virtual properties, or complex transformations that can't be done in SQL.

Column Value Resolution (in order of precedence):

  1. exportValue callback in column metadata - custom formatting function
  2. renderField path (e.g., 'member.name_for_herald') - for nested entity access
  3. queryField for relation columns in query mode
  4. Direct column key access on entity/array
Parameters
$result : array<string|int, mixed>

Result from processDataverseGrid() with isCsvExport flag

$csvExportService : CsvExportService

CSV export service instance

$entityName : string

Base name for the export file (e.g., 'members', 'warrants')

$tableName : string|null = null

Optional table name for fetchTable (e.g., 'Awards.Recommendations' for plugin tables) If not provided, uses ucfirst($entityName)

$data : iterable<string|int, mixed>|null = null

Optional pre-processed data. If provided, uses data mode instead of query mode. Data should be an iterable of entities or arrays with all computed fields populated.

Tags
throws
ForbiddenException

If user lacks export permission

Return values
Response

CSV download response

isCsvExportRequest()

Check if the current request is for CSV export

protected isCsvExportRequest() : bool
Return values
bool

True if CSV export is requested

loadFilterOptions()

Load filter options from a data source

protected loadFilterOptions(array<string|int, mixed>|string $source) : array<string|int, mixed>

Supports multiple formats for filterOptionsSource:

  1. Simple string (table name): Uses 'id' for value, 'name' for label

    'filterOptionsSource' => 'Branches'
    
  2. Array with table: Database table with full control

    'filterOptionsSource' => [
        'table' => 'Waivers.WaiverTypes',  // Required: table name for fetchTable()
        'valueField' => 'id',              // Optional: field for option value (default: 'id')
        'labelField' => 'name',            // Optional: field for option label (default: 'name')
        'conditions' => ['is_active' => true],  // Optional: filter conditions
        'order' => ['name' => 'ASC'],      // Optional: sort order (default: labelField ASC)
    ]
    
  3. Array with appSetting: Load from app settings (YAML array)

    'filterOptionsSource' => [
        'appSetting' => 'Branches.Types',  // Required: app setting key
    ]
    

    The app setting should contain a YAML array like: ['Kingdom', 'Principality', 'Barony'] Both value and label will be set to the array item value.

  4. Array with method: Call a static method on a class to get options

    'filterOptionsSource' => [
        'method' => 'getGatheringsFilterOptions',  // Required: static method name
        'class' => 'Awards\\KMP\\GridColumns\\RecommendationsGridColumns',  // Required: fully qualified class name
    ]
    

    The method should return array of ['value' => string, 'label' => string].

Parameters
$source : array<string|int, mixed>|string

Source identifier string (table name) or configuration array

Return values
array<string|int, mixed>

Filter options as array of ['value' => string, 'label' => string]

organizeViewCells()

Organize view cells by type and display order.

protected organizeViewCells(array<string|int, mixed> $viewCells) : array<string|int, mixed>

Unused - view cells organized in ViewCellRegistry

Parameters
$viewCells : array<string|int, mixed>

Flat array of view cell configurations

Return values
array<string|int, mixed>

Organized array grouped by type and sorted by order

prepareRecommendationsForExport()

Prepare recommendations for CSV export with computed fields

protected prepareRecommendationsForExport(Query $query[, array<string|int, mixed> $options = [] ]) : iterable<string|int, mixed>

Fetches all data from the query (not paginated) and populates computed fields that can't be calculated via SQL (virtual properties, formatted strings, etc.)

Parameters
$query : Query

The filtered query from processDataverseGrid

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

Export options (includeAttendance => bool)

Return values
iterable<string|int, mixed>

Recommendations with computed fields populated

processDataverseGrid()

Process dataverse grid request with unified logic

protected processDataverseGrid(array<string|int, mixed> $config) : array<string|int, mixed>

This method handles all aspects of grid processing including view management, filtering, searching, sorting, and pagination. It supports both saved user views and system-defined views.

Parameters
$config : array<string|int, mixed>

Grid configuration with the following keys:

  • gridKey (string): Unique identifier for the grid
  • gridColumnsClass (string): Fully qualified class name for grid columns metadata
  • baseQuery (Query): Base query object to start with
  • tableName (string): Primary table name for field qualification
  • defaultSort (array): Default sort configuration ['field' => 'direction']
  • defaultPageSize (int): Default number of records per page (default: 25)
  • systemViews (array|null): Optional array of system views (for Warrants-style grids)
  • defaultSystemView (string|null): Default system view key (required if systemViews provided)
  • queryCallback (callable|null): Optional callback to modify query per system view
  • showAllTab (bool): Whether to show "All" tab (default: true for saved views, false for system views)
  • canAddViews (bool): Whether users can create custom views (default: true)
  • canFilter (bool): Whether user filtering is enabled (default: true). When false, users cannot add/remove filters via the UI or query parameters. However, filters defined by system views are ALWAYS applied regardless of this setting.
  • canExportCsv (bool): Whether CSV export button is shown (default: true)
  • showFilterPills (bool): Whether active filter pills/badges are displayed (default: true)
  • showViewTabs (bool): Whether view tabs are displayed (default: true)
  • enableColumnPicker (bool): Whether column picker is available (default: true)
  • lockedFilters (array): Array of filter column keys that cannot be removed by users. Locked filters will not show remove (×) buttons and their values cannot be cleared via query string parameters. Useful for embedded grids where context filters (e.g., member_id) must always be applied.
  • enableBulkSelection (bool): Whether row selection checkboxes are shown (default: false)
  • bulkActions (array): Array of bulk action button configurations when enableBulkSelection is true. Each action is an array with keys: label, icon, modalTarget, permission.

NOTE: Authorization scope must be applied to baseQuery BEFORE calling this method. Use $baseQuery = $this->Authorization->applyScope($baseQuery, 'index'); in your controller before passing the query to processDataverseGrid().

Return values
array<string|int, mixed>

Result array with keys: data, gridState, columnsMetadata, etc.

resolveNestedValue()

Resolve nested value from entity using dot notation path

protected resolveNestedValue(mixed $entity, string $path) : mixed
Parameters
$entity : mixed

Entity to traverse

$path : string

Dot-notation path (e.g., 'member.name_for_herald')

Return values
mixed

Resolved value or null if path doesn't exist


        
On this page

Search results