FacetFormatter
extends BaseFormatter
in package
Facet formatter for API responses
Tags
Table of Contents
- format() : array<string|int, mixed>
- Create the result facet list
- buildFacetFilters() : array<string|int, mixed>
- Build an array of facet filters from the request params
- buildFacetValues() : array<string|int, mixed>
- Recursive function to create a facet value list for a single facet
- filterArrayValues() : void
- Recursive function to filter array fields: - remove empty values - convert boolean values to 0/1 - force numerically indexed (non-associative) arrays to have numeric keys.
- matchFacetItem() : bool
- Match a facet item with the filters.
- resetArrayIndices() : void
- Reset numerical array indices.
Methods
format()
Create the result facet list
public
format(array<string|int, mixed> $request, Results $results, array<string|int, mixed> $hierarchicalFacetData) : array<string|int, mixed>
Parameters
- $request : array<string|int, mixed>
-
Request parameters
- $results : Results
-
Search results
- $hierarchicalFacetData : array<string|int, mixed>
-
Hierarchical facet data
Return values
array<string|int, mixed> —buildFacetFilters()
Build an array of facet filters from the request params
protected
buildFacetFilters(array<string|int, mixed> $request) : array<string|int, mixed>
Parameters
- $request : array<string|int, mixed>
-
Request params
Return values
array<string|int, mixed> —buildFacetValues()
Recursive function to create a facet value list for a single facet
protected
buildFacetValues(array<string|int, mixed> $list[, array<string|int, mixed> $filters = false ]) : array<string|int, mixed>
Parameters
- $list : array<string|int, mixed>
-
Facet items
- $filters : array<string|int, mixed> = false
-
Facet filters
Return values
array<string|int, mixed> —filterArrayValues()
Recursive function to filter array fields: - remove empty values - convert boolean values to 0/1 - force numerically indexed (non-associative) arrays to have numeric keys.
protected
filterArrayValues(array<string|int, mixed> &$array) : void
Parameters
- $array : array<string|int, mixed>
-
Array to check
Return values
void —matchFacetItem()
Match a facet item with the filters.
protected
matchFacetItem(array<string|int, mixed> $facet, array<string|int, mixed> $filters) : bool
Parameters
- $facet : array<string|int, mixed>
-
Facet
- $filters : array<string|int, mixed>
-
Facet filters
Return values
bool —resetArrayIndices()
Reset numerical array indices.
protected
resetArrayIndices(array<string|int, mixed> &$array) : void
Parameters
- $array : array<string|int, mixed>
-
Array