Documentation

GetDefault extends AbstractAction uses SavedSearchInspectorTrait, ArrayQueryActionTrait, SelectParamTrait

Generate the default display for a saved search.

Dispatches civi.search.defaultDisplay event to allow subscribers to provide a display based on context.

Table of Contents

Properties

$_debugOutput  : mixed
$_actionName  : string
$_apiParams  : array{select: array, where: array, having: array, orderBy: array, limit: int, offset: int, checkPermissions: bool, debug: bool}
$_entityName  : string
$chain  : array<string|int, mixed>
Additional api requests - will be called once per result.
$checkPermissions  : bool
Whether to enforce acl permissions based on the current user.
$context  : array<string|int, mixed>
Provide context information; passed through to `civi.search.defaultDisplay` subscribers
$debug  : bool
Add debugging info to the api result.
$language  : string
Preferred language (optional)
$savedSearch  : string|array<string|int, mixed>|null
Either the name of the savedSearch or an array containing the savedSearch definition (for preview mode)
$select  : array<string|int, mixed>
Fields to return for each $ENTITY. Defaults to all fields `[*]`.
$type  : string
$version  : int
Api version number; cannot be changed.
$_arrayStorage  : array<string|int, mixed>
$_entityFields  : array<string|int, mixed>
$_id  : int
$_joinMap  : array<string|int, mixed>
$_paramInfo  : array<string|int, mixed>
$_reflection  : ReflectionClass
$_searchEntityFields  : array<string|int, mixed>
$_selectClause  : array<string|int, mixed>
$_selectQuery  : Api4SelectQuery

Methods

__call()  : static|mixed
Magic function to provide automatic getter/setter for params.
__construct()  : mixed
Action constructor.
__set()  : mixed
Strictly enforce api parameters
_run()  : mixed
addChain()  : $this
addSelect()  : $this
Add one or more fields to be selected (wildcard * allowed)
compareValues()  : bool
configureColumn()  : array<string|int, mixed>
entityFields()  : array<string|int, mixed>
Returns schema fields for this entity & action.
evaluateCondition()  : bool
This function is used internally for evaluating field annotations.
execute()  : Result
Invoke api call.
expandSelectClauseWildcards()  : mixed
Adds all standard fields matched by the * wildcard
filterCompare()  : bool
getActionName()  : string
getChain()  : array<string|int, mixed>
getCheckPermissions()  : bool
getContext()  : array<string|int, mixed>
getDebug()  : bool
getDisplayTypes()  : array<string|int, mixed>
Options callback for $this->type
getEntityName()  : string
getLanguage()  : string|null
getLinksMenu()  : mixed
return array[]
getParamInfo()  : array<string|int, mixed>
Get documentation for one or all params
getParams()  : array<string|int, mixed>
Serialize this object's params into an array
getPermissions()  : array<string|int, mixed>
getSelectClause()  : array<string|int, SqlExpression, dataType: string}>
Returns the select clause enhanced with metadata
getType()  : string
offsetExists()  : bool
offsetGet()  : mixed
offsetSet()  : void
offsetUnset()  : void
paramExists()  : bool
reflect()  : ReflectionClass
setChain()  : $this
setCheckPermissions()  : $this
setContext()  : $this
setDebug()  : $this
setLanguage()  : $this
setType()  : $this
setVersion()  : $this
addCallbackToDebugOutput()  : mixed
When in debug mode, this logs the callback function being used by a Basic*Action class.
applyFilter()  : mixed
checkPermissionToLoadSearch()  : mixed
Only SearchKit admins can use unsecured "preview mode" and pass an array for savedSearch or display
checkRequiredFields()  : array<string|int, mixed>
Validates required fields for actions which create a new object.
filterArray()  : array<string|int, mixed>
formatWriteValues()  : mixed
Replaces pseudoconstants in input values
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}>
getLanguageOptions()  : array<string|int, mixed>
Get available preferred languages.
getMagicProperties()  : array<string|int, mixed>
Get a list of class properties for which magic methods are supported.
getParamDefaults()  : array<string|int, mixed>
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
limitArray()  : array<string|int, mixed>
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
queryArray()  : mixed
selectArray()  : array<string|int, mixed>
sortArray()  : array<string|int, mixed>
canAggregate()  : bool
Determines if a column belongs to an aggregate grouping
evaluateFilters()  : bool
getColumnLink()  : mixed
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
sortCompare()  : mixed
walkFilters()  : bool

Properties

$_apiParams

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

$chain

Additional api requests - will be called once per result.

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

Keys can be any string - this will be the name given to the output.

You can reference other values in the api results in this call by prefixing them with $.

For example, you could create a contact and place them in a group by chaining the GroupContact api to the Contact api:

Contact::create()
  ->setValue('first_name', 'Hello')
  ->addChain('add_a_group', GroupContact::create()
    ->setValue('contact_id', '$id')
    ->setValue('group_id', 123)
  )

This will substitute the id of the newly created contact with $id.

$checkPermissions

Whether to enforce acl permissions based on the current user.

protected bool $checkPermissions = TRUE

Setting to FALSE will disable permission checks and override ACLs. In REST/javascript this cannot be disabled.

$context

Provide context information; passed through to `civi.search.defaultDisplay` subscribers

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

$debug

Add debugging info to the api result.

protected bool $debug = FALSE

When enabled, $result->debug will be populated with information about the api call, including sql queries executed.

Note: with checkPermissions enabled, debug info will only be returned if the user has "view debug output" permission.

$language

Preferred language (optional)

protected string $language

This option will notify major localization subsystems (ts(), multilingual, etc) about which locale should be used for composing/formatting messaging.

This indicates the preferred language. The effective language is determined by Civi\Core\Locale::negotiate($preferredLanguage).

Tags
optionsCallback

getLanguageOptions

$savedSearch

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

protected string|array<string|int, mixed>|null $savedSearch

$select

Fields to return for each $ENTITY. Defaults to all fields `[*]`.

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

Use the * wildcard by itself to select all available fields, or use it to match similarly-named fields. E.g. is_* will match fields named is_primary, is_active, etc.

Set to ["row_count"] to return only the number of $ENTITIES found.

$type

protected string $type = 'table'
Tags
optionsCallback

getDisplayTypes

$version

Api version number; cannot be changed.

protected int $version = 4

$_arrayStorage

private array<string|int, mixed> $_arrayStorage = []

Methods

__call()

Magic function to provide automatic getter/setter for params.

public __call(mixed $name, mixed $arguments) : static|mixed
Parameters
$name : mixed
$arguments : mixed
Tags
throws
CRM_Core_Exception
Return values
static|mixed

__construct()

Action constructor.

public __construct(string $entityName, string $actionName) : mixed
Parameters
$entityName : string
$actionName : string

__set()

Strictly enforce api parameters

public __set(mixed $name, mixed $value) : mixed
Parameters
$name : mixed
$value : mixed
Tags
throws
Exception

addChain()

public addChain(string $name, AbstractAction $apiRequest[, string|int|array<string|int, mixed> $index = NULL ]) : $this
Parameters
$name : string

Unique name for this chained request

$apiRequest : AbstractAction
$index : string|int|array<string|int, mixed> = NULL

See civicrm_api4() for documentation of $index param

Return values
$this

addSelect()

Add one or more fields to be selected (wildcard * allowed)

public addSelect(string ...$fieldNames) : $this
Parameters
$fieldNames : string
Return values
$this

compareValues()

public static compareValues(mixed $value, string $operator, mixed $expected) : bool
Parameters
$value : mixed
$operator : string
$expected : mixed
Return values
bool

configureColumn()

public configureColumn(SqlExpression, dataType: string} $clause, string $key) : array<string|int, mixed>
Parameters
$clause : SqlExpression, dataType: string}
$key : string
Return values
array<string|int, mixed>

entityFields()

Returns schema fields for this entity & action.

public entityFields() : array<string|int, mixed>

Here we bypass the api wrapper and run the getFields action directly. This is because we DON'T want the wrapper to check permissions as this is an internal op.

Tags
see
GetFields
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

evaluateCondition()

This function is used internally for evaluating field annotations.

public static evaluateCondition(string $expr, array<string|int, mixed> $vars) : bool

It should never be passed raw user input.

Parameters
$expr : string

Conditional in php format e.g. $foo > $bar

$vars : array<string|int, mixed>

Variable name => value

Tags
throws
CRM_Core_Exception
throws
Exception
Return values
bool

expandSelectClauseWildcards()

Adds all standard fields matched by the * wildcard

public expandSelectClauseWildcards() : mixed

Note: this function only deals with simple wildcard expressions. It ignores those containing special characters like dots or parentheses, they are handled separately in Api4SelectQuery.

Tags
throws
CRM_Core_Exception

filterCompare()

public static filterCompare(array<string|int, mixed> $row, array<string|int, mixed> $condition[, int|null $index = NULL ]) : bool
Parameters
$row : array<string|int, mixed>
$condition : array<string|int, mixed>
$index : int|null = NULL
Tags
throws
NotImplementedException
Return values
bool

getActionName()

public getActionName() : string
Return values
string

getChain()

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

getCheckPermissions()

public getCheckPermissions() : bool
Return values
bool

getContext()

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

getDisplayTypes()

Options callback for $this->type

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

getEntityName()

public getEntityName() : string
Return values
string

getLanguage()

public getLanguage() : string|null
Return values
string|null

getLinksMenu()

return array[]

public getLinksMenu() : mixed

getParamInfo()

Get documentation for one or all params

public getParamInfo([string $param = NULL ]) : array<string|int, mixed>
Parameters
$param : string = NULL
Return values
array<string|int, mixed>

of arrays [description, type, default, (comment)]

getParams()

Serialize this object's params into an array

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

getPermissions()

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

getSelectClause()

Returns the select clause enhanced with metadata

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

getType()

public getType() : string
Return values
string

offsetExists()

public offsetExists(mixed $offset) : bool
Parameters
$offset : mixed
Tags
inheritDoc
Return values
bool

offsetGet()

public & offsetGet(mixed $offset) : mixed
Parameters
$offset : mixed
Tags
inheritDoc
Attributes
#[ReturnTypeWillChange]

offsetSet()

public offsetSet(mixed $offset, mixed $value) : void
Parameters
$offset : mixed
$value : mixed
Tags
inheritDoc

offsetUnset()

public offsetUnset(mixed $offset) : void
Parameters
$offset : mixed
Tags
inheritDoc

paramExists()

public paramExists(string $param) : bool
Parameters
$param : string
Return values
bool

reflect()

public reflect() : ReflectionClass
Return values
ReflectionClass

setChain()

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

setCheckPermissions()

public setCheckPermissions(bool $checkPermissions) : $this
Parameters
$checkPermissions : bool
Return values
$this

setContext()

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

setDebug()

public setDebug([bool $debug = ]) : $this

Enable/disable debug output

Parameters
$debug : bool =
Return values
$this

setLanguage()

public setLanguage([string|null $language = ]) : $this
Parameters
$language : string|null =
Return values
$this

setType()

public setType([string $type = ]) : $this
Parameters
$type : string =
Return values
$this

addCallbackToDebugOutput()

When in debug mode, this logs the callback function being used by a Basic*Action class.

protected addCallbackToDebugOutput(callable $callable) : mixed
Parameters
$callable : callable

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

checkRequiredFields()

Validates required fields for actions which create a new object.

protected checkRequiredFields(mixed $values) : array<string|int, mixed>
Parameters
$values : mixed
Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

filterArray()

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

formatWriteValues()

Replaces pseudoconstants in input values

protected formatWriteValues(array<string|int, mixed> &$record) : mixed
Parameters
$record : array<string|int, mixed>
Tags
throws
CRM_Core_Exception

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}>

getLanguageOptions()

Get available preferred languages.

protected getLanguageOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>

getMagicProperties()

Get a list of class properties for which magic methods are supported.

protected static getMagicProperties() : array<string|int, mixed>
Return values
array<string|int, mixed>

List of supported properties, keyed by property name. Array(string $propertyName => bool $true).

getParamDefaults()

protected getParamDefaults() : array<string|int, mixed>
Return values
array<string|int, mixed>

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

limitArray()

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

queryArray()

protected queryArray(array<string|int, mixed> $values, Result $result) : mixed
Parameters
$values : array<string|int, mixed>

List of all rows to be filtered

$result : Result

Object to store result

selectArray()

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

sortArray()

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

canAggregate()

Determines if a column belongs to an aggregate grouping

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

evaluateFilters()

private evaluateFilters(array<string|int, mixed> $row) : bool
Parameters
$row : array<string|int, mixed>
Return values
bool
private getColumnLink(array<string|int, mixed> &$col, SqlExpression, dataType: string} $clause) : mixed
Parameters
$col : array<string|int, mixed>
$clause : SqlExpression, dataType: string}

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

sortCompare()

private sortCompare(mixed $a, mixed $b) : mixed
Parameters
$a : mixed
$b : mixed

walkFilters()

private walkFilters(array<string|int, mixed> $row, array<string|int, mixed> $filters) : bool
Parameters
$row : array<string|int, mixed>
$filters : array<string|int, mixed>
Tags
throws
NotImplementedException
Return values
bool

        
On this page

Search results