Documentation

SpecGatherer extends AutoService
in package
implements EventSubscriberInterface

Class SpecGatherer

Tags
service

spec_gatherer

Table of Contents

Interfaces

EventSubscriberInterface

Properties

$specProviders  : array<string|int, SpecProviderInterface>
$entityActionValues  : mixed
$fieldCache  : mixed

Methods

addSpecProvider()  : void
getAllFields()  : array<string|int, mixed>
Get all fields for entity.
getSubscribedEvents()  : mixed
onClearMetadata()  : void
When metadata cache flush is requested, internal caches in this service should also be cleared.
addCoreFields()  : mixed
addCustomFields()  : mixed
Get custom fields that extend this entity
customGroupBelongsTo()  : bool
Implements the logic needed by entities that use multiple groupings (in core, only Participant custom fields have multiple groupings)
filterCustomFieldsByPermission()  : mixed
getCacheKey()  : mixed
getCustomGroupFields()  : void
getSpec()  : RequestSpec
Returns a RequestSpec with all fields. Uses spec providers to add or modify field specifications.
setDynamicFk()  : void
Adds metadata about dynamic foreign key fields.

Properties

$entityActionValues

private mixed $entityActionValues = []

Methods

getAllFields()

Get all fields for entity.

public getAllFields(string $entityName, string $actionName[, array<string|int, mixed> $values = [] ][, bool $checkPermissions = FALSE ]) : array<string|int, mixed>

This uses in-memory caching to speed up cases where getFields is called hundreds of times per page.

The cache is unique per entity + action + language + relevant values. Because the array of $values can be literally anything, we cut it down to just the relevant ones by tracking which values are actually used by the specProviders.

Parameters
$entityName : string
$actionName : string
$values : array<string|int, mixed> = []
$checkPermissions : bool = FALSE
Tags
see
RequestSpec::getValuesUsed()
Return values
array<string|int, mixed>

getSubscribedEvents()

public static getSubscribedEvents() : mixed

onClearMetadata()

When metadata cache flush is requested, internal caches in this service should also be cleared.

public onClearMetadata() : void

addCustomFields()

Get custom fields that extend this entity

private addCustomFields(string $entityName, RequestSpec $spec) : mixed
Parameters
$entityName : string
$spec : RequestSpec
Tags
throws
CRM_Core_Exception
see
CRM_Core_SelectValues::customGroupExtends

customGroupBelongsTo()

Implements the logic needed by entities that use multiple groupings (in core, only Participant custom fields have multiple groupings)

private customGroupBelongsTo(array<string|int, mixed> $customGroup, array<string|int, mixed> $values, mixed $grouping) : bool
Parameters
$customGroup : array<string|int, mixed>
$values : array<string|int, mixed>
$grouping : mixed
Return values
bool

filterCustomFieldsByPermission()

private filterCustomFieldsByPermission(array<string|int, mixed> &$fields, string $actionName) : mixed
Parameters
$fields : array<string|int, mixed>
$actionName : string

getCacheKey()

private getCacheKey(mixed $entityName, mixed $actionName, mixed $cacheValueKeys, mixed $values) : mixed
Parameters
$entityName : mixed
$actionName : mixed
$cacheValueKeys : mixed
$values : mixed

getCustomGroupFields()

private getCustomGroupFields(string $customGroupName, RequestSpec $specification) : void
Parameters
$customGroupName : string
$specification : RequestSpec

getSpec()

Returns a RequestSpec with all fields. Uses spec providers to add or modify field specifications.

private getSpec(string $entityName, string $actionName[, array<string|int, mixed> $values = [] ]) : RequestSpec
Parameters
$entityName : string
$actionName : string
$values : array<string|int, mixed> = []
Tags
throws
CRM_Core_Exception
see
CustomFieldCreationSpecProvider
Return values
RequestSpec

setDynamicFk()

Adds metadata about dynamic foreign key fields.

private setDynamicFk(string $fieldName, array<string|int, mixed> &$field, RequestSpec $spec) : void

E.g. some tables have a DFK with a pair of columns named entity_table and entity_id. This will gather the list of 'dfk_entities' to add as metadata to the e.g. entity_id column.

Additionally, if $values contains a value for e.g. entity_table, then getFields will also output the corresponding fk_entity for the entity_id field.

Parameters
$fieldName : string
$field : array<string|int, mixed>
$spec : RequestSpec

        
On this page

Search results