Documentation

SavedSearchInspectorTrait

Trait for requiring a savedSearch as a param plus util functions for inspecting it.

Table of Contents

Properties

$_apiParams  : array{select: array, where: array, having: array, orderBy: array, limit: int, offset: int, checkPermissions: bool, debug: bool}
$savedSearch  : string|array<string|int, mixed>
Either the name of the savedSearch or an array containing the savedSearch definition (for preview mode)
$_joinMap  : array<string|int, mixed>
$_searchEntityFields  : array<string|int, mixed>
$_selectClause  : array<string|int, mixed>
$_selectQuery  : Api4SelectQuery

Methods

getSavedSearch()  : array<string|int, mixed>|string
getSelectClause()  : array<string|int, SqlExpression, dataType: string}>
Returns the select clause enhanced with metadata
setSavedSearch()  : $this
applyFilter()  : mixed
checkPermissionToLoadSearch()  : mixed
Only SearchKit admins can use unsecured "preview mode" and pass an array for savedSearch or display
getColumnLabel()  : string
getField()  : array<string|int, mixed>|null
Returns field definition for a given field or NULL if not found
getJoin()  : array{entity: string, alias: string, table: string, bridge: string|null}|null
getJoinLabel()  : string
getJoins()  : array<string|int, array{entity: string, alias: string, table: string, bridge: string|null}>
getSelectExpression()  : SqlExpression, dataType: string}|null
getTokens()  : array<string|int, mixed>
Search a string for all square bracket tokens and return their contents (without the brackets)
hasValue()  : bool
Checks if a filter contains a non-empty value
loadSavedSearch()  : mixed
If SavedSearch is supplied as a string, this will load it as an array
loadSearchDisplay()  : void
Loads display if not already an array
canAggregate()  : bool
Determines if a column belongs to an aggregate grouping
getEntityFields()  : array<string|int, mixed>
Used as a fallback for non-DAO entities which don't use the Query object
getQuery()  : Api4SelectQuery|bool
Returns a Query object for the search entity, or FALSE if it doesn't have a DAO
renameIfAggregate()  : string

Properties

$_apiParams

protected array{select: array, where: array, having: array, orderBy: array, limit: int, offset: int, checkPermissions: bool, debug: bool} $_apiParams

$savedSearch

Either the name of the savedSearch or an array containing the savedSearch definition (for preview mode)

protected string|array<string|int, mixed> $savedSearch
Tags
required

Methods

getSavedSearch()

public getSavedSearch() : array<string|int, mixed>|string
Return values
array<string|int, mixed>|string

getSelectClause()

Returns the select clause enhanced with metadata

public getSelectClause() : array<string|int, SqlExpression, dataType: string}>
Return values
array<string|int, SqlExpression, dataType: string}>

setSavedSearch()

public setSavedSearch([array<string|int, mixed>|string $savedSearch = ]) : $this
Parameters
$savedSearch : array<string|int, mixed>|string =
Return values
$this

applyFilter()

protected applyFilter(string|array<string|int, mixed> $fieldName, mixed $value) : mixed
Parameters
$fieldName : string|array<string|int, mixed>

If multiple field names are given they will be combined in an OR clause

$value : mixed

getField()

Returns field definition for a given field or NULL if not found

protected getField(mixed $fieldName) : array<string|int, mixed>|null
Parameters
$fieldName : mixed
Return values
array<string|int, mixed>|null

getJoin()

protected getJoin(string $joinAlias) : array{entity: string, alias: string, table: string, bridge: string|null}|null
Parameters
$joinAlias : string

Alias of the join, with or without the trailing dot

Return values
array{entity: string, alias: string, table: string, bridge: string|null}|null

getJoinLabel()

protected getJoinLabel(string $joinAlias) : string
Parameters
$joinAlias : string
Return values
string

getJoins()

protected getJoins() : array<string|int, array{entity: string, alias: string, table: string, bridge: string|null}>
Return values
array<string|int, array{entity: string, alias: string, table: string, bridge: string|null}>

getSelectExpression()

protected getSelectExpression(string $key) : SqlExpression, dataType: string}|null
Parameters
$key : string
Return values
SqlExpression, dataType: string}|null

getTokens()

Search a string for all square bracket tokens and return their contents (without the brackets)

protected getTokens(string $str) : array<string|int, mixed>
Parameters
$str : string
Return values
array<string|int, mixed>

hasValue()

Checks if a filter contains a non-empty value

protected hasValue(mixed $value) : bool

"Empty" search values are [], '', and NULL. Also recursively checks arrays to ensure they contain at least one non-empty value.

Parameters
$value : mixed
Return values
bool

canAggregate()

Determines if a column belongs to an aggregate grouping

private canAggregate(string $fieldPath) : bool
Parameters
$fieldPath : string
Return values
bool

getEntityFields()

Used as a fallback for non-DAO entities which don't use the Query object

private getEntityFields() : array<string|int, mixed>
Return values
array<string|int, mixed>

renameIfAggregate()

private renameIfAggregate(string $fieldPath[, bool $asSelect = FALSE ]) : string
Parameters
$fieldPath : string
$asSelect : bool = FALSE
Return values
string

        
On this page

Search results