Documentation

CRM_Search_Import_Parser extends CRM_Import_Parser
in package
uses SavedSearchInspectorTrait

Import parser for Api4-based imports via SearchKit

Table of Contents

Properties

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

Methods

getBaseEntity()  : string
getImportEntities()  : array<string|int, mixed>
getMappedRow()  : array<string|int, mixed>
Get the row from the table mapped to our parameters.
getSelectClause()  : array<string|int, SqlExpression, dataType: string}>
Returns the select clause enhanced with metadata
getUserJobInfo()  : array<string|int, mixed>
Get information about the provided job.
import()  : void
Handle the values in import mode.
init()  : mixed
validateRow()  : bool
applyFilter()  : mixed
checkPermissionToLoadSearch()  : mixed
Only SearchKit admins can use unsecured "preview mode" and pass an array for savedSearch or display
getColumnLabel()  : string
getDataSourceObject()  : CRM_Import_DataSource|null
getField()  : array<string|int, mixed>|null
Returns field definition for a given field or NULL if not found
getFieldMappings()  : array<string|int, mixed>
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, on: array, bridge: string|null}>
getSelectExpression()  : SqlExpression, dataType: string}|null
getTokens()  : array<string|int, mixed>
Search a string for all square bracket tokens and return their contents (without the brackets)
hasValue()  : bool
Checks if a filter contains a non-empty value
loadSavedSearch()  : mixed
If SavedSearch is supplied as a string, this will load it as an array
loadSearchDisplay()  : void
Loads display if not already an array
canAggregate()  : bool
Determines if a column belongs to an aggregate grouping
extractEntityFromFieldName()  : string
getEntityFields()  : array<string|int, mixed>
Used as a fallback for non-DAO entities which don't use the Query object
getEntityValues()  : array<string|int, mixed>
getQuery()  : Api4SelectQuery|null
Returns a Query object for the search entity, or FALSE if it doesn't have a DAO
renameIfAggregate()  : string
saveEntities()  : void
saveFinancialEntities()  : void

Properties

$_apiParams

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

$baseEntity

protected string $baseEntity

$display

protected array<string|int, mixed> $display

$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

$fieldMappings

private array<string|int, mixed>|null $fieldMappings = \NULL

$importEntities

private array<string|int, mixed>|null $importEntities = \NULL

$joinPrefixes

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

$lineItemEntities

private array<string|int, mixed> $lineItemEntities = ['Membership', 'Participant']

Methods

getBaseEntity()

public getBaseEntity() : string
Return values
string

getImportEntities()

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

getMappedRow()

Get the row from the table mapped to our parameters.

public getMappedRow(array<string|int, mixed> $values) : array<string|int, mixed>
Parameters
$values : array<string|int, mixed>
Tags
throws
CRM_Core_Exception
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}>

getUserJobInfo()

Get information about the provided job.

public static getUserJobInfo() : array<string|int, mixed>
  • name
  • id (generally the same as name)
  • label
Return values
array<string|int, mixed>

import()

Handle the values in import mode.

public import(array<string|int, mixed> $values) : void
Parameters
$values : array<string|int, mixed>

The array of values belonging to this line.

validateRow()

public validateRow(array<string|int, mixed>|null $row) : bool
Parameters
$row : array<string|int, mixed>|null
Return values
bool

applyFilter()

protected applyFilter(string|array<string|int, mixed> $fieldName, mixed $value[, array<string|int, mixed>|null $formFields = null ]) : mixed
Parameters
$fieldName : string|array<string|int, mixed>

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

$value : mixed

Filter value

$formFields : array<string|int, mixed>|null = null

Afform filters

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

getFieldMappings()

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

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, on: array, bridge: string|null}>
Return values
array<string|int, array{entity: string, alias: string, table: string, on: array, bridge: string|null}>

getSelectExpression()

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

getTokens()

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

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

hasValue()

Checks if a filter contains a non-empty value

protected hasValue(mixed $value) : bool

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

Parameters
$value : mixed
Return values
bool

canAggregate()

Determines if a column belongs to an aggregate grouping

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

extractEntityFromFieldName()

private extractEntityFromFieldName(string &$fieldName) : string
Parameters
$fieldName : string
Return values
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>

getEntityValues()

private getEntityValues(array<string|int, mixed> $mappedRow, array<string|int, mixed> $entity) : array<string|int, mixed>
Parameters
$mappedRow : array<string|int, mixed>
$entity : 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

saveEntities()

private saveEntities(array<string|int, mixed> &$mappedRow) : void
Parameters
$mappedRow : array<string|int, mixed>

saveFinancialEntities()

private saveFinancialEntities(array<string|int, mixed> &$mappedRow) : void
Parameters
$mappedRow : array<string|int, mixed>

        
On this page

Search results