Documentation

Download extends AbstractRunAction

Download the results of a SearchDisplay as a spreadsheet.

Note: unlike other APIs this action will directly output a file if 'format' is set to anything other than 'array'.

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
$afform  : string
Name of Afform, if this display is embedded (used for permissioning)
$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.
$debug  : bool
Add debugging info to the api result.
$display  : string|array<string|int, mixed>|null
Either the name of the display or an array containing the display definition (for preview mode)
$filterLabels  : array<string|int, mixed>
Filters passed directly into this display via Afform markup will have their labels appended to the Afform title.
$filters  : array<string|int, mixed>
Search conditions that will be automatically added to the WHERE or HAVING clauses
$format  : string
Requested file format.
$language  : string
Preferred language (optional)
$savedSearch  : string|array<string|int, mixed>
Either the name of the savedSearch or an array containing the savedSearch definition (for preview mode)
$seed  : int
Integer used as a seed when ordering by RAND().
$sort  : array<string|int, mixed>
Array of fields to use for ordering the results
$version  : int
Api version number; cannot be changed.
$_afform  : array<string|int, mixed>
$_arrayStorage  : array<string|int, mixed>
$_entityFields  : array<string|int, mixed>
$_id  : int
$_joinMap  : array<string|int, mixed>
$_paramInfo  : array<string|int, mixed>
$_qfKeys  : array<string|int, mixed>
$_reflection  : ReflectionClass
$_searchEntityFields  : array<string|int, mixed>
$_selectClause  : array<string|int, mixed>
$_selectQuery  : Api4SelectQuery
$currencyFields  : mixed
$editableInfo  : mixed
$entityActions  : array<string|int, mixed>
$formats  : mixed
$tasks  : array<string|int, mixed>

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
compareValues()  : bool
entityFields()  : array<string|int, mixed>
Returns schema fields for this entity & action.
evaluateCondition()  : bool
This function is used internally for evaluating field annotations.
execute()  : SearchDisplayRunResult
Override execute method to change the result object type
filterCompare()  : bool
getActionName()  : string
getAfform()  : string
getChain()  : array<string|int, mixed>
getCheckPermissions()  : bool
getDebug()  : bool
getDisplay()  : array<string|int, mixed>|string|null
getEntityName()  : string
getFilters()  : array<string|int, mixed>
getFormat()  : string
getLanguage()  : string|null
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>
getPseudoFields()  : array<string|int, array<string|int, mixed>>
Extra calculated fields provided by SearchKit
getSeed()  : string
getSelectClause()  : array<string|int, SqlExpression, dataType: string}>
Returns the select clause enhanced with metadata
getSort()  : array<string|int, mixed>
offsetExists()  : bool
offsetGet()  : mixed
offsetSet()  : void
offsetUnset()  : void
paramExists()  : bool
reflect()  : ReflectionClass
setAfform()  : $this
setChain()  : $this
setCheckPermissions()  : $this
setDebug()  : $this
setDisplay()  : $this
setFilters()  : $this
setFormat()  : $this
setLanguage()  : $this
setSeed()  : $this
setSort()  : $this
setVersion()  : $this
addCallbackToDebugOutput()  : mixed
When in debug mode, this logs the callback function being used by a Basic*Action class.
addSelectExpression()  : void
applyFilter()  : mixed
applyFilters()  : mixed
Applies supplied filters to the where clause
augmentSelectClause()  : void
Adds additional fields to the select clause required to render the display
checkLinkCondition()  : bool
Evaluate a link condition.
checkLinkConditions()  : bool
Check if a link should be shown based on its conditions.
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>
formatColumnValue()  : string
Returns final formatted column value
formatLink()  : array<string|int, mixed>|null
Format a link to resolve tokens and form the url.
formatResult()  : array<string|int, array{data: array, columns: array}>
Transforms each row into an array of raw data and an array of formatted columns
formatViewValue()  : array<string|int, mixed>|string
Return raw value if it is a single date, otherwise return parent {@inheritDoc}
formatWriteValues()  : mixed
Replaces pseudoconstants in input values
getColumnIcons()  : array<string|int, mixed>
Add icons to a column
getColumnLabel()  : string
getContentDisposition()  : string
Copied from \League\Csv\AbstractCsv::sendHeaders()
getCssRulesSelect()  : array<string|int, mixed>
Return fields needed for the select clause by a set of css rules
getCssStyles()  : array<string|int, mixed>
Evaluates conditional style rules
getField()  : array<string|int, mixed>|null
Returns field definition for a given field or NULL if not found
getIconsSelect()  : array<string|int, mixed>
Return fields needed for calculating a column's icons
getIdKeyName()  : string
Given an entity name, returns the data fieldName used to identify it.
getJoin()  : array{entity: string, alias: string, table: string, bridge: string|null}|null
getJoinFromAlias()  : string
Given an alias like Contact_Email_01_location_type_id this will return Contact_Email_01.location_type_id
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.
getOrderByFromSort()  : array<string|int, mixed>
Transforms the SORT param (which is expected to be an array of arrays) to the ORDER BY clause (which is an associative array of [field => DIR]
getParamDefaults()  : array<string|int, mixed>
getRuleCondition()  : array<string|int, mixed>
Returns the condition of a cssRules
getSelectAliases()  : array<string|int, string>
Returns an array of field names or aliases + allowed suffixes from the SELECT clause
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
preprocessLinks()  : void
Fills in info about each link in the search display.
processResult()  : mixed
queryArray()  : mixed
selectArray()  : array<string|int, mixed>
sendHeaders()  : mixed
Sets headers based on content type and file name
sortArray()  : array<string|int, mixed>
addFilterLabel()  : mixed
Sets $this->filterLabels to provide contextual titles to search Afforms
canAggregate()  : bool
Determines if a column belongs to an aggregate grouping
checkLinkAccess()  : bool
Check if a link should be visible to the user based on their permissions
evaluateFilters()  : bool
fieldBelongsToEntity()  : bool
Check if a field is appropriate for this entity type or sub-type.
findCurrencyField()  : string|null
Find currency field for an entity.
findFKFields()  : array<string|int, string>
Return all fields for this entity with a foreign key
formatColumn()  : array{val: mixed, links: array, edit: array, label: string, title: string, image: array, cssClass: string}
formatEditableColumn()  : array{entity: string, action: string, input_type: string, data_type: string, options: bool, serialize: bool, nullable: bool, fk_entity: string, value_key: string, record: array, value_path: string}|null
formatFieldLinks()  : array<string|int, array{text: string, url: string, target: string}>
Format a field value as links
formatImage()  : array{url: string, width: int, height: int}|null
formatLinksColumn()  : array<string|int, array{text: string, url: string, target: string, style: string, icon: string}>
Format links for a menu/buttons/links column
formatMultiLink()  : array<string|int, mixed>
Returns an array of multiple links for use as a dropdown-select when API::getLinks returns > 1 record
generateFileUrl()  : string
Convert file id to a readable url
getAfformDirectiveFilters()  : array<string|int, string>
Finds all directive filters and applies the ones with a literal value
getAfformFilterFields()  : array<string|int, string>
Returns a list of afform fields used as search filters
getColumnIcon()  : string|null
getCurrencyField()  : string|null
Return the corresponding currency field if a select expression is monetary
getEditableInfo()  : array{entity: string, input_type: string, data_type: string, options: bool, serialize: bool, nullable: bool, fk_entity: string, value_key: string, value_path: string, id_key: string, id_path: string, explicit_join: string, grouping_fields: array}|null
getEntityFields()  : array<string|int, mixed>
Used as a fallback for non-DAO entities which don't use the Query object
getLinkTokens()  : array<string|int, mixed>
Get fields needed by a link which should be added to the SELECT clause
getPermittedLinkAction()  : string|null
Given entity/action name, return the api action name if the user is allowed to run it.
getQfKey()  : string|null
getQuery()  : Api4SelectQuery|bool
Returns a Query object for the search entity, or FALSE if it doesn't have a DAO
getTask()  : array<string|int, mixed>|null
Returns information about a task, but only if user has permission to use it.
getUrl()  : string
getValue()  : mixed
getWhereClauseValues()  : array<string|int, mixed>
Returns any key/value pairs in the WHERE clause (those using the `=` operator)
loadAfform()  : array<string|int, mixed>|false
Return afform with name specified in api call.
outputCSV()  : mixed
Outputs headers and CSV directly to browser for download
outputSpreadsheet()  : mixed
Create PhpSpreadsheet document and output directly to browser for download
preprocessLink()  : void
renameIfAggregate()  : string
replaceTokens()  : string
rewrite()  : string
Rewrite field value, subtituting tokens and evaluating smarty tags
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

$afform

Name of Afform, if this display is embedded (used for permissioning)

protected string $afform

$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.

$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.

$display

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

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

Leave NULL to use the autogenerated default.

$filterLabels

Filters passed directly into this display via Afform markup will have their labels appended to the Afform title.

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

$filters

Search conditions that will be automatically added to the WHERE or HAVING clauses

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

$format

Requested file format.

protected string $format = 'array'

'array' will return a normal api result, with table headers as the first row. 'csv', etc. will directly output a file to the browser.

Tags
required
options

array,csv,xlsx,ods,pdf

$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> $savedSearch
Tags
required

$seed

Integer used as a seed when ordering by RAND().

protected int $seed

This keeps the order stable enough to use a pager with random sorting.

$sort

Array of fields to use for ordering the results

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

$version

Api version number; cannot be changed.

protected int $version = 4

$_arrayStorage

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

$_qfKeys

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

Ex: ['civicrm/foo/bar?id=[id]&widget=gizmo' => 'CRMFooBar1234abcd1234abcd']

$formats

private mixed $formats = ['xlsx' => ['writer' => 'Xlsx', 'mime' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'], 'ods' => ['writer' => 'Ods', 'mime' => 'application/vnd.oasis.opendocument.spreadsheet'], 'pdf' => ['writer' => 'Dompdf', 'mime' => 'application/pdf']]

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

compareValues()

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

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

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

getDisplay()

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

getEntityName()

public getEntityName() : string
Return values
string

getFilters()

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

getFormat()

public getFormat() : string
Return values
string

getLanguage()

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

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>

getPseudoFields()

Extra calculated fields provided by SearchKit

public static getPseudoFields() : array<string|int, array<string|int, mixed>>
Return values
array<string|int, 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}>

getSort()

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

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

setAfform()

public setAfform([string $afform = ]) : $this
Parameters
$afform : string =
Return values
$this

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

setDebug()

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

Enable/disable debug output

Parameters
$debug : bool =
Return values
$this

setDisplay()

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

setFilters()

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

setFormat()

public setFormat([string $format = ]) : $this
Parameters
$format : string =
Return values
$this

setLanguage()

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

setSeed()

public setSeed([string $seed = ]) : $this
Parameters
$seed : string =
Return values
$this

setSort()

public setSort([array<string|int, mixed> $sort = ]) : $this
Parameters
$sort : array<string|int, mixed> =
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

addSelectExpression()

protected addSelectExpression(string $expr) : void
Parameters
$expr : string

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

applyFilters()

Applies supplied filters to the where clause

protected applyFilters() : mixed

augmentSelectClause()

Adds additional fields to the select clause required to render the display

protected augmentSelectClause(array<string|int, mixed> &$apiParams) : void
Parameters
$apiParams : array<string|int, mixed>

checkLinkCondition()

Evaluate a link condition.

protected checkLinkCondition(array<string|int, mixed> $condition, array<string|int, mixed> $data) : bool
Parameters
$condition : array<string|int, mixed>
$data : array<string|int, mixed>
Return values
bool

checkLinkConditions()

Check if a link should be shown based on its conditions.

protected checkLinkConditions(array<string|int, mixed> $link, array<string|int, mixed> $data) : bool

Given a link, check if it is set to be displayed conditionally. If so, evaluate the condition, else return TRUE.

Parameters
$link : array<string|int, mixed>
$data : array<string|int, mixed>
Return values
bool

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>

formatColumnValue()

Returns final formatted column value

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

Format a link to resolve tokens and form the url.

protected formatLink(array<string|int, mixed> $link, array<string|int, mixed> $data[, bool $allowMultiple = FALSE ][, string|null $text = NULL ][, int $index = 0 ]) : array<string|int, mixed>|null

There are 3 ways a link can be declared:

  1. entity+action
  2. entity+task
  3. path
Parameters
$link : array<string|int, mixed>
$data : array<string|int, mixed>
$allowMultiple : bool = FALSE
$text : string|null = NULL
$index : int = 0
Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>|null

formatResult()

Transforms each row into an array of raw data and an array of formatted columns

protected formatResult(iterable<string|int, mixed> $result) : array<string|int, array{data: array, columns: array}>
Parameters
$result : iterable<string|int, mixed>
Return values
array<string|int, array{data: array, columns: array}>

formatViewValue()

Return raw value if it is a single date, otherwise return parent {@inheritDoc}

protected formatViewValue(mixed $key, mixed $rawValue, mixed $data, mixed $dataType[, mixed $format = NULL ]) : array<string|int, mixed>|string
Parameters
$key : mixed
$rawValue : mixed
$data : mixed
$dataType : mixed
$format : mixed = NULL
Return values
array<string|int, mixed>|string

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

getColumnIcons()

Add icons to a column

protected getColumnIcons(array<string|int, mixed> $column, array<string|int, mixed> $data, array<string|int, mixed> $out) : array<string|int, mixed>

Note: Only one icon is allowed per side (left/right). If more than one per side is given, latter icons are treated as fallbacks and only shown if prior ones are missing.

Parameters
$column : array<string|int, mixed>
$data : array<string|int, mixed>
$out : array<string|int, mixed>
Return values
array<string|int, mixed>

getContentDisposition()

Copied from \League\Csv\AbstractCsv::sendHeaders()

protected getContentDisposition(string $fileName) : string
Parameters
$fileName : string
Return values
string

getCssRulesSelect()

Return fields needed for the select clause by a set of css rules

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

getCssStyles()

Evaluates conditional style rules

protected getCssStyles(array<string|int, array<string|int, mixed>> $styleRules, array<string|int, mixed> $data[, int|null $index = NULL ]) : array<string|int, mixed>

Rules are in the format ['css class', 'field_name', 'OPERATOR', 'value']

Parameters
$styleRules : array<string|int, array<string|int, mixed>>
$data : array<string|int, mixed>
$index : int|null = NULL
Return values
array<string|int, 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

getIconsSelect()

Return fields needed for calculating a column's icons

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

getIdKeyName()

Given an entity name, returns the data fieldName used to identify it.

protected getIdKeyName(string|null $entityName) : string
Parameters
$entityName : string|null
Return values
string

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

getJoinFromAlias()

Given an alias like Contact_Email_01_location_type_id this will return Contact_Email_01.location_type_id

protected getJoinFromAlias(string $alias) : string
Parameters
$alias : string
Return values
string

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).

getOrderByFromSort()

Transforms the SORT param (which is expected to be an array of arrays) to the ORDER BY clause (which is an associative array of [field => DIR]

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

getParamDefaults()

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

getRuleCondition()

Returns the condition of a cssRules

protected getRuleCondition(array<string|int, mixed> $clause[, bool $isMulti = FALSE ]) : array<string|int, mixed>
Parameters
$clause : array<string|int, mixed>
$isMulti : bool = FALSE
Return values
array<string|int, mixed>

getSelectAliases()

Returns an array of field names or aliases + allowed suffixes from the SELECT clause

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

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>

Fills in info about each link in the search display.

protected preprocessLinks() : void

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>

sendHeaders()

Sets headers based on content type and file name

protected sendHeaders(string $fileName) : mixed
Parameters
$fileName : string

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

checkLinkAccess()

Check if a link should be visible to the user based on their permissions

private checkLinkAccess(array<string|int, mixed> $link, array<string|int, mixed> $data) : bool

Checks ACLs for all links other than VIEW (presumably if a record is shown in SearchKit then the user already has view access, and the check is expensive).

Parameters
$link : array<string|int, mixed>
$data : array<string|int, mixed>
Tags
throws
CRM_Core_Exception
throws
NotImplementedException
Return values
bool

evaluateFilters()

private evaluateFilters(array<string|int, mixed> $row) : bool
Parameters
$row : array<string|int, mixed>
Return values
bool

fieldBelongsToEntity()

Check if a field is appropriate for this entity type or sub-type.

private fieldBelongsToEntity(string $entityName, string $fieldName, array<string|int, mixed> $entityValues[, bool $checkPermissions = TRUE ]) : bool

For example, the 'first_name' field does not belong to Contacts of type Organization. And custom data is sometimes limited to specific contact types, event types, case types, etc.

Parameters
$entityName : string
$fieldName : string
$entityValues : array<string|int, mixed>
$checkPermissions : bool = TRUE
Return values
bool

findCurrencyField()

Find currency field for an entity.

private findCurrencyField(string $entityName) : string|null
Parameters
$entityName : string
Return values
string|null

findFKFields()

Return all fields for this entity with a foreign key

private findFKFields(string $entityName) : array<string|int, string>
Parameters
$entityName : string
Return values
array<string|int, string>

formatColumn()

private formatColumn(array<string|int, mixed> $column, array<string|int, mixed> $data) : array{val: mixed, links: array, edit: array, label: string, title: string, image: array, cssClass: string}
Parameters
$column : array<string|int, mixed>
$data : array<string|int, mixed>
Return values
array{val: mixed, links: array, edit: array, label: string, title: string, image: array, cssClass: string}

formatEditableColumn()

private formatEditableColumn(array<string|int, mixed> $column, array<string|int, mixed> $data) : array{entity: string, action: string, input_type: string, data_type: string, options: bool, serialize: bool, nullable: bool, fk_entity: string, value_key: string, record: array, value_path: string}|null
Parameters
$column : array<string|int, mixed>
$data : array<string|int, mixed>
Return values
array{entity: string, action: string, input_type: string, data_type: string, options: bool, serialize: bool, nullable: bool, fk_entity: string, value_key: string, record: array, value_path: string}|null

Format a field value as links

private formatFieldLinks(mixed $column, mixed $data, mixed $value) : array<string|int, array{text: string, url: string, target: string}>
Parameters
$column : mixed
$data : mixed
$value : mixed
Return values
array<string|int, array{text: string, url: string, target: string}>

formatImage()

private formatImage(mixed $column, mixed $data) : array{url: string, width: int, height: int}|null
Parameters
$column : mixed
$data : mixed
Return values
array{url: string, width: int, height: int}|null

formatLinksColumn()

Format links for a menu/buttons/links column

private formatLinksColumn(array<string|int, mixed> $column, array<string|int, mixed> $data) : array<string|int, array{text: string, url: string, target: string, style: string, icon: string}>
Parameters
$column : array<string|int, mixed>
$data : array<string|int, mixed>
Return values
array<string|int, array{text: string, url: string, target: string, style: string, icon: string}>

Returns an array of multiple links for use as a dropdown-select when API::getLinks returns > 1 record

private formatMultiLink(array<string|int, mixed> $link, array<string|int, mixed> $apiInfo, array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
$link : array<string|int, mixed>
$apiInfo : array<string|int, mixed>
$data : array<string|int, mixed>
Return values
array<string|int, mixed>

generateFileUrl()

Convert file id to a readable url

private generateFileUrl(mixed $fileID) : string
Parameters
$fileID : mixed
Tags
throws
CRM_Core_Exception
Return values
string

getAfformDirectiveFilters()

Finds all directive filters and applies the ones with a literal value

private getAfformDirectiveFilters() : array<string|int, string>

Returns the list of filters that did not get auto-applied (value was passed via js)

Return values
array<string|int, string>

getAfformFilterFields()

Returns a list of afform fields used as search filters

private getAfformFilterFields() : array<string|int, string>

Limited to the current display

Return values
array<string|int, string>

getColumnIcon()

private getColumnIcon(array<string|int, mixed> $icons, string $side, int $index, array<string|int, mixed> $data, bool $isMulti) : string|null
Parameters
$icons : array<string|int, mixed>
$side : string
$index : int
$data : array<string|int, mixed>
$isMulti : bool
Return values
string|null

getCurrencyField()

Return the corresponding currency field if a select expression is monetary

private getCurrencyField(string $select) : string|null
Parameters
$select : string
Return values
string|null

getEditableInfo()

private getEditableInfo(mixed $key) : array{entity: string, input_type: string, data_type: string, options: bool, serialize: bool, nullable: bool, fk_entity: string, value_key: string, value_path: string, id_key: string, id_path: string, explicit_join: string, grouping_fields: array}|null
Parameters
$key : mixed
Return values
array{entity: string, input_type: string, data_type: string, options: bool, serialize: bool, nullable: bool, fk_entity: string, value_key: string, value_path: string, id_key: string, id_path: string, explicit_join: string, grouping_fields: array}|null

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>

getLinkTokens()

Get fields needed by a link which should be added to the SELECT clause

private getLinkTokens(array<string|int, mixed> $link) : array<string|int, mixed>
Parameters
$link : array<string|int, mixed>
Return values
array<string|int, mixed>

getPermittedLinkAction()

Given entity/action name, return the api action name if the user is allowed to run it.

private getPermittedLinkAction(string $entityName, string $actionName) : string|null

This function serves 2 purposes:

  1. Efficiently check api gatekeeper permissions (reuses a single getActions api call for every link).
  2. Transform funny action names (some links have non-api-standard actions like "detach" or "copy").
Parameters
$entityName : string
$actionName : string
Return values
string|null

getQfKey()

private getQfKey(string $pathExpr) : string|null
Parameters
$pathExpr : string

Path formula. Should specify an explicit path. Ex: 'civicrm/foo/bar?id=[id]&widget=gizmo`

Return values
string|null

getTask()

Returns information about a task, but only if user has permission to use it.

private getTask(string $taskName) : array<string|int, mixed>|null
Parameters
$taskName : string
Return values
array<string|int, mixed>|null

getUrl()

private getUrl(string $path[, array<string|int, mixed> $query = NULL ]) : string
Parameters
$path : string
$query : array<string|int, mixed> = NULL
Return values
string

getValue()

private getValue(string $key, array<string|int, mixed> $data, int $rowIndex) : mixed
Parameters
$key : string
$data : array<string|int, mixed>
$rowIndex : int

getWhereClauseValues()

Returns any key/value pairs in the WHERE clause (those using the `=` operator)

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

loadAfform()

Return afform with name specified in api call.

private loadAfform() : array<string|int, mixed>|false

Verifies the searchDisplay is embedded in the afform and the user has permission to view it.

Return values
array<string|int, mixed>|false

outputCSV()

Outputs headers and CSV directly to browser for download

private outputCSV(array<string|int, mixed> $rows, array<string|int, mixed> $columns, string $fileName) : mixed
Parameters
$rows : array<string|int, mixed>
$columns : array<string|int, mixed>
$fileName : string

outputSpreadsheet()

Create PhpSpreadsheet document and output directly to browser for download

private outputSpreadsheet(array<string|int, mixed> $rows, array<string|int, mixed> $columns) : mixed
Parameters
$rows : array<string|int, mixed>
$columns : array<string|int, mixed>
private preprocessLink(array{path: string, entity: string, action: string, task: string, join: string, target: string, style: string, title: string, text: string, prefix: string, conditions: array} &$link) : void
Parameters
$link : array{path: string, entity: string, action: string, task: string, join: string, target: string, style: string, title: string, text: string, prefix: string, conditions: array}

renameIfAggregate()

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

replaceTokens()

private replaceTokens(string $tokenExpr, array<string|int, mixed> $data, string $format) : string
Parameters
$tokenExpr : string
$data : array<string|int, mixed>
$format : string

view|raw|url

Return values
string

rewrite()

Rewrite field value, subtituting tokens and evaluating smarty tags

private rewrite(array<string|int, mixed> $column, array<string|int, mixed> $data) : string
Parameters
$column : array<string|int, mixed>
$data : array<string|int, mixed>
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