CoreUtil
in package
Table of Contents
Methods
- checkAccessDelegated() : bool
- If the permissions of record $A are based on record $B, then use `checkAccessDelegated($B...)` to make see if access to $B is permitted.
- checkAccessRecord() : bool|null
- Check if current user is authorized to perform specified action on a given entity.
- entityExists() : bool
- formatOptionList() : array<string|int, mixed>|bool
- Transforms a raw option list (which could be either a flat or non-associative array) into an APIv4-compatible format.
- formatViewValue() : mixed
- getApiClass() : string|AbstractEntity|null
- getApiNameFromBAO() : string|null
- Returns API entity name given an BAO/DAO class name
- getApiNameFromTableName() : string|null
- Given a sql table name, return the name of the api entity.
- getBAOFromApiName() : CRM_Core_DAO|string
- getCustomGroupExtends() : array{extends: array, column: string, grouping: mixed}|null
- For a given API Entity, return the types of custom fields it supports and the column they join to.
- getCustomGroupName() : string|null
- getEntityTypes() : array<string|int, mixed>
- Collect the 'type' values from every entity.
- getIdFieldName() : string
- Get name of unique identifier, typically "id"
- getInfoItem() : mixed
- Get a piece of metadata about an entity
- getOperators() : array<string|int, string>
- getOptionValueFields() : array<string|int, mixed>
- Get the suffixes supported by a given option group
- getRefCount() : array<string|int, array{name: string, type: string, count: int, table: string|null, key: string|null}>
- Fetches database references + those returned by hook
- getRefCountTotal() : int
- Gets total number of references
- getSchemaMap() : SchemaMap
- getSearchableOptions() : array<string|int, mixed>
- getSearchFields() : array<string|int, mixed>
- Get name of field(s) to display in search context
- getSqlFunctions() : array<string|int, mixed>
- Gets info about all available sql functions
- getTableName() : string|null
- Get table name of given entity
- isContact() : bool
- Returns TRUE if `entityName` is 'Contact', 'Individual', 'Organization' or 'Household'
- isCustomEntity() : bool
- isType() : bool
- Check if entity is of given type.
- stripNamespace() : string
- Strips leading namespace from a classname
- topSortFields() : void
- Sorts fields so that control fields are ordered before the fields they control.
Methods
checkAccessDelegated()
If the permissions of record $A are based on record $B, then use `checkAccessDelegated($B...)` to make see if access to $B is permitted.
public
static checkAccessDelegated(string $entityName, string $actionName, array<string|int, mixed> $record, int $userID) : bool
Parameters
- $entityName : string
- $actionName : string
- $record : array<string|int, mixed>
- $userID : int
-
Contact ID of the user we are testing, or 0 for the anonymous user.
Tags
Return values
boolcheckAccessRecord()
Check if current user is authorized to perform specified action on a given entity.
public
static checkAccessRecord(AbstractAction $apiRequest, array<string|int, mixed> $record[, int|null $userID = NULL ]) : bool|null
Parameters
- $apiRequest : AbstractAction
- $record : array<string|int, mixed>
- $userID : int|null = NULL
-
Contact ID of the user we are testing, 0 for the anonymous user.
Tags
Return values
bool|nullentityExists()
public
static entityExists(string $entityName) : bool
Parameters
- $entityName : string
Return values
boolformatOptionList()
Transforms a raw option list (which could be either a flat or non-associative array) into an APIv4-compatible format.
public
static formatOptionList(array<string|int, mixed>|bool $options, array<string|int, mixed>|bool $format) : array<string|int, mixed>|bool
Parameters
- $options : array<string|int, mixed>|bool
- $format : array<string|int, mixed>|bool
Return values
array<string|int, mixed>|boolformatViewValue()
public
static formatViewValue(string $entityName, string $fieldName, array<string|int, mixed> $values[, string $action = 'get' ]) : mixed
Parameters
- $entityName : string
- $fieldName : string
- $values : array<string|int, mixed>
- $action : string = 'get'
getApiClass()
public
static getApiClass(string $entityName) : string|AbstractEntity|null
Parameters
- $entityName : string
Return values
string|AbstractEntity|nullgetApiNameFromBAO()
Returns API entity name given an BAO/DAO class name
public
static getApiNameFromBAO(mixed $baoClassName) : string|null
Returns null if the API has not been implemented
Parameters
- $baoClassName : mixed
Return values
string|nullgetApiNameFromTableName()
Given a sql table name, return the name of the api entity.
public
static getApiNameFromTableName(string $tableName) : string|null
Parameters
- $tableName : string
Return values
string|nullgetBAOFromApiName()
public
static getBAOFromApiName(mixed $entityName) : CRM_Core_DAO|string
Parameters
- $entityName : mixed
Return values
CRM_Core_DAO|string —The BAO name for use in static calls. Return doc block is hacked to allow auto-completion of static methods
getCustomGroupExtends()
For a given API Entity, return the types of custom fields it supports and the column they join to.
public
static getCustomGroupExtends(string $entityName) : array{extends: array, column: string, grouping: mixed}|null
Sort of the inverse of this function:
Parameters
- $entityName : string
Tags
Return values
array{extends: array, column: string, grouping: mixed}|nullgetCustomGroupName()
public
static getCustomGroupName(string $entityName) : string|null
Parameters
- $entityName : string
Return values
string|nullgetEntityTypes()
Collect the 'type' values from every entity.
public
static getEntityTypes() : array<string|int, mixed>
Return values
array<string|int, mixed>getIdFieldName()
Get name of unique identifier, typically "id"
public
static getIdFieldName(string $entityName) : string
Parameters
- $entityName : string
Return values
stringgetInfoItem()
Get a piece of metadata about an entity
public
static getInfoItem(string $entityName, string $keyToReturn) : mixed
Parameters
- $entityName : string
- $keyToReturn : string
getOperators()
public
static getOperators() : array<string|int, string>
Return values
array<string|int, string>getOptionValueFields()
Get the suffixes supported by a given option group
public
static getOptionValueFields(string|int $optionGroup[, string $key = 'name' ]) : array<string|int, mixed>
Parameters
- $optionGroup : string|int
-
OptionGroup id or name
- $key : string = 'name'
-
Is $optionGroup being passed as "id" or "name"
Return values
array<string|int, mixed>getRefCount()
Fetches database references + those returned by hook
public
static getRefCount(string $entityName, int $entityId) : array<string|int, array{name: string, type: string, count: int, table: string|null, key: string|null}>
Parameters
- $entityName : string
- $entityId : int
Tags
Return values
array<string|int, array{name: string, type: string, count: int, table: string|null, key: string|null}>getRefCountTotal()
Gets total number of references
public
static getRefCountTotal(string $entityName, mixed $entityId) : int
Parameters
- $entityName : string
- $entityId : mixed
Tags
Return values
intgetSchemaMap()
public
static getSchemaMap() : SchemaMap
Return values
SchemaMapgetSearchableOptions()
public
static getSearchableOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>getSearchFields()
Get name of field(s) to display in search context
public
static getSearchFields(string $entityName) : array<string|int, mixed>
Parameters
- $entityName : string
Return values
array<string|int, mixed>getSqlFunctions()
Gets info about all available sql functions
public
static getSqlFunctions() : array<string|int, mixed>
Return values
array<string|int, mixed>getTableName()
Get table name of given entity
public
static getTableName(string $entityName) : string|null
Parameters
- $entityName : string
Return values
string|nullisContact()
Returns TRUE if `entityName` is 'Contact', 'Individual', 'Organization' or 'Household'
public
static isContact(string $entityName) : bool
Parameters
- $entityName : string
Return values
boolisCustomEntity()
public
static isCustomEntity(mixed $customGroupName) : bool
since 5.71 will be removed around 5.81
Parameters
- $customGroupName : mixed
Tags
Return values
boolisType()
Check if entity is of given type.
public
static isType(string $entityName, string $entityType) : bool
Parameters
- $entityName : string
-
e.g. 'Contact'
- $entityType : string
-
e.g. 'SortableEntity'
Return values
boolstripNamespace()
Strips leading namespace from a classname
public
static stripNamespace(string $className) : string
Parameters
- $className : string
Return values
stringtopSortFields()
Sorts fields so that control fields are ordered before the fields they control.
public
static topSortFields(array<string|int, array<string|int, mixed>> &$fields) : void
Parameters
- $fields : array<string|int, array<string|int, mixed>>