AbstractRunAction
extends AbstractAction
in package
uses
SavedSearchInspectorTrait, ArrayQueryActionTrait
Base class for running a search.
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
- $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>
- $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>
- 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
- 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>
- 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
- Format raw field value according to data type
- formatWriteValues() : mixed
- Replaces pseudoconstants in input values
- getColumnIcons() : array<string|int, mixed>
- Add icons to a column
- getColumnLabel() : string
- 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>
- 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.
- preprocessLink() : void
- renameIfAggregate() : string
- replaceTokens() : string
- rewrite() : string
- Rewrite field value, subtituting tokens and evaluating smarty tags
- sortCompare() : mixed
- walkFilters() : bool
Properties
$_debugOutput
public
mixed
$_debugOutput
= []
$_actionName
protected
string
$_actionName
$_apiParams
protected
array{select: array, where: array, having: array, orderBy: array, limit: int, offset: int, checkPermissions: bool, debug: bool}
$_apiParams
$_entityName
protected
string
$_entityName
$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
= []
$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
$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
$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
$_afform
private
array<string|int, mixed>
$_afform
$_arrayStorage
private
array<string|int, mixed>
$_arrayStorage
= []
$_entityFields
private
array<string|int, mixed>
$_entityFields
$_id
private
int
$_id
Used to identify api calls for transactions
Tags
$_joinMap
private
array<string|int, mixed>
$_joinMap
$_paramInfo
private
array<string|int, mixed>
$_paramInfo
$_qfKeys
private
array<string|int, mixed>
$_qfKeys
= []
Ex: ['civicrm/foo/bar?id=[id]&widget=gizmo' => 'CRMFooBar1234abcd1234abcd']
$_reflection
private
ReflectionClass
$_reflection
$_searchEntityFields
private
array<string|int, mixed>
$_searchEntityFields
$_selectClause
private
array<string|int, mixed>
$_selectClause
$_selectQuery
private
Api4SelectQuery
$_selectQuery
$currencyFields
private
mixed
$currencyFields
= []
$editableInfo
private
mixed
$editableInfo
= []
$entityActions
private
array<string|int, mixed>
$entityActions
$tasks
private
array<string|int, mixed>
$tasks
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
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
_run()
public
_run(Result $result) : mixed
Parameters
- $result : Result
Tags
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
$thiscompareValues()
public
static compareValues(mixed $value, string $operator, mixed $expected) : bool
Parameters
- $value : mixed
- $operator : string
- $expected : mixed
Return values
boolentityFields()
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
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
Return values
boolexecute()
Override execute method to change the result object type
public
execute() : SearchDisplayRunResult
Return values
SearchDisplayRunResultfilterCompare()
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
Return values
boolgetActionName()
public
getActionName() : string
Return values
stringgetAfform()
public
getAfform() : string
Return values
stringgetChain()
public
getChain() : array<string|int, mixed>
Return values
array<string|int, mixed>getCheckPermissions()
public
getCheckPermissions() : bool
Return values
boolgetDebug()
public
getDebug() : bool
Return values
boolgetDisplay()
public
getDisplay() : array<string|int, mixed>|string|null
Return values
array<string|int, mixed>|string|nullgetEntityName()
public
getEntityName() : string
Return values
stringgetFilters()
public
getFilters() : array<string|int, mixed>
Return values
array<string|int, mixed>getLanguage()
public
getLanguage() : string|null
Return values
string|nullgetParamInfo()
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>>getSeed()
public
getSeed() : string
Return values
stringgetSelectClause()
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
Return values
booloffsetGet()
public
& offsetGet(mixed $offset) : mixed
Parameters
- $offset : mixed
Tags
Attributes
- #[ReturnTypeWillChange]
offsetSet()
public
offsetSet(mixed $offset, mixed $value) : void
Parameters
- $offset : mixed
- $value : mixed
Tags
offsetUnset()
public
offsetUnset(mixed $offset) : void
Parameters
- $offset : mixed
Tags
paramExists()
public
paramExists(string $param) : bool
Parameters
- $param : string
Return values
boolreflect()
public
reflect() : ReflectionClass
Return values
ReflectionClasssetAfform()
public
setAfform([string $afform = ]) : $this
Parameters
- $afform : string =
Return values
$thissetChain()
public
setChain([array<string|int, mixed> $chain = ]) : $this
Parameters
- $chain : array<string|int, mixed> =
Return values
$thissetCheckPermissions()
public
setCheckPermissions(bool $checkPermissions) : $this
Parameters
- $checkPermissions : bool
Return values
$thissetDebug()
public
setDebug([bool $debug = ]) : $this
Enable/disable debug output
Parameters
- $debug : bool =
Return values
$thissetDisplay()
public
setDisplay([array<string|int, mixed>|string $display = ]) : $this
Parameters
- $display : array<string|int, mixed>|string =
Return values
$thissetFilters()
public
setFilters([array<string|int, mixed> $filters = ]) : $this
Parameters
- $filters : array<string|int, mixed> =
Return values
$thissetLanguage()
public
setLanguage([string|null $language = ]) : $this
Parameters
- $language : string|null =
Return values
$thissetSeed()
public
setSeed([string $seed = ]) : $this
Parameters
- $seed : string =
Return values
$thissetSort()
public
setSort([array<string|int, mixed> $sort = ]) : $this
Parameters
- $sort : array<string|int, mixed> =
Return values
$thissetVersion()
public
setVersion(int $val) : $this
Parameters
- $val : int
Tags
Return values
$thisaddCallbackToDebugOutput()
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
boolcheckLinkConditions()
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
boolcheckPermissionToLoadSearch()
Only SearchKit admins can use unsecured "preview mode" and pass an array for savedSearch or display
protected
checkPermissionToLoadSearch() : mixed
Tags
checkRequiredFields()
Validates required fields for actions which create a new object.
protected
checkRequiredFields(mixed $values) : array<string|int, mixed>
Parameters
- $values : mixed
Tags
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>formatLink()
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:
- entity+action
- entity+task
- path
Parameters
- $link : array<string|int, mixed>
- $data : array<string|int, mixed>
- $allowMultiple : bool = FALSE
- $text : string|null = NULL
- $index : int = 0
Tags
Return values
array<string|int, mixed>|nullformatResult()
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()
Format raw field value according to data type
protected
formatViewValue(string $key, mixed $rawValue, array<string|int, mixed> $data, string $dataType[, string|null $format = NULL ]) : array<string|int, mixed>|string
Parameters
- $key : string
- $rawValue : mixed
- $data : array<string|int, mixed>
- $dataType : string
- $format : string|null = NULL
Return values
array<string|int, mixed>|stringformatWriteValues()
Replaces pseudoconstants in input values
protected
formatWriteValues(array<string|int, mixed> &$record) : mixed
Parameters
- $record : array<string|int, mixed>
Tags
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>getColumnLabel()
protected
getColumnLabel(SqlExpression $expr) : string
Parameters
- $expr : SqlExpression
Return values
stringgetCssRulesSelect()
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>|nullgetIconsSelect()
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
stringgetJoin()
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}|nullgetJoinFromAlias()
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
stringgetJoinLabel()
protected
getJoinLabel(string $joinAlias) : string
Parameters
- $joinAlias : string
Return values
stringgetJoins()
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}|nullgetTokens()
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
boollimitArray()
protected
limitArray(mixed $values) : array<string|int, mixed>
Parameters
- $values : mixed
Return values
array<string|int, mixed>loadSavedSearch()
If SavedSearch is supplied as a string, this will load it as an array
protected
loadSavedSearch([int|null $id = NULL ]) : mixed
Parameters
- $id : int|null = NULL
Tags
loadSearchDisplay()
Loads display if not already an array
protected
loadSearchDisplay() : void
preprocessLinks()
Fills in info about each link in the search display.
protected
preprocessLinks() : void
processResult()
protected
abstract processResult(SearchDisplayRunResult $result) : mixed
Parameters
- $result : SearchDisplayRunResult
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>addFilterLabel()
Sets $this->filterLabels to provide contextual titles to search Afforms
private
addFilterLabel(mixed $fieldName, mixed $value) : mixed
Parameters
- $fieldName : mixed
- $value : mixed
Tags
canAggregate()
Determines if a column belongs to an aggregate grouping
private
canAggregate(string $fieldPath) : bool
Parameters
- $fieldPath : string
Return values
boolcheckLinkAccess()
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
Return values
boolevaluateFilters()
private
evaluateFilters(array<string|int, mixed> $row) : bool
Parameters
- $row : array<string|int, mixed>
Return values
boolfieldBelongsToEntity()
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
boolfindCurrencyField()
Find currency field for an entity.
private
findCurrencyField(string $entityName) : string|null
Parameters
- $entityName : string
Return values
string|nullfindFKFields()
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}|nullformatFieldLinks()
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}|nullformatLinksColumn()
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}>formatMultiLink()
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
Return values
stringgetAfformDirectiveFilters()
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|nullgetCurrencyField()
Return the corresponding currency field if a select expression is monetary
private
getCurrencyField(string $select) : string|null
Parameters
- $select : string
Return values
string|nullgetEditableInfo()
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}|nullgetEntityFields()
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:
- Efficiently check api gatekeeper permissions (reuses a single getActions api call for every link).
- Transform funny action names (some links have non-api-standard actions like "detach" or "copy").
Parameters
- $entityName : string
- $actionName : string
Return values
string|nullgetQfKey()
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|nullgetQuery()
Returns a Query object for the search entity, or FALSE if it doesn't have a DAO
private
getQuery() : Api4SelectQuery|bool
Return values
Api4SelectQuery|boolgetTask()
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>|nullgetUrl()
private
getUrl(string $path[, array<string|int, mixed> $query = NULL ]) : string
Parameters
- $path : string
- $query : array<string|int, mixed> = NULL
Return values
stringgetValue()
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>|falsepreprocessLink()
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
stringreplaceTokens()
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
stringrewrite()
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
stringsortCompare()
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>