CRM_Contribute_RecurTokens
extends CRM_Core_EntityTokens
in package
Class CRM_Contribute_RecurTokens
Generate "contribution_recur.*" tokens.
Table of Contents
Properties
- $activeTokens : array<string|int, mixed>
- $entity : string
- $tokenNames : array<string|int, mixed>
- $checkPermissions : bool
- Should permissions be checked when loading tokens.
- $fieldMetadata : array<string|int, mixed>
- Metadata about the entity fields.
- $prefetch : array<string|int, mixed>
- $tokensMetadata : array<string|int, mixed>
- Metadata about all tokens.
Methods
- __construct() : mixed
- Class constructor.
- alterActionScheduleQuery() : void
- Alter action schedule query.
- checkActive() : bool
- Check if the token processor is active.
- evaluateToken() : mixed
- Evaluate the content of a single token.
- evaluateTokens() : mixed
- Populate the token data.
- getActiveTokens() : mixed
- To handle variable tokens, override this function and return the active tokens.
- getCurrencyFieldName() : array<string|int, mixed>
- getExtendableTableName() : string
- Get the name of the table this token class can extend.
- getPrefetchFields() : array<string|int, mixed>
- Get the fields required to prefetch the entity.
- getSubscribedEvents() : mixed
- isHTMLTextField() : bool
- Is the text stored in html format.
- prefetch() : mixed
- To perform a bulk lookup before rendering tokens, override this function and return the prefetched data.
- registerTokens() : mixed
- Register the declared tokens.
- addFieldToTokenMetadata() : void
- Add the token to the metadata based on the field spec.
- getApiEntityName() : string
- Get the entity name for api v4 calls.
- getBasicTokens() : array<string|int, string>
- getBespokeTokens() : array<string|int, mixed>
- Get any tokens with custom calculation.
- getCacheKey() : string
- Get a cache key appropriate to the current usage.
- getCurrency() : string
- Get the currency to use for formatting money.
- getCustomFieldName() : string
- Get the apiv4 style custom field name.
- getCustomFieldValue() : array<string|int, mixed>|string|void|null
- getDependencies() : array<string|int, mixed>
- Get fields which need to be returned to render another token.
- getDeprecatedTokens() : array<string|int, mixed>
- Get array of deprecated tokens and the new token they map to.
- getEntityAlias() : string
- Get the entity alias to use within queries.
- getEntityIDField() : string
- getEntityName() : string
- getExposedFields() : array<string|int, string>
- Get entity fields that should be exposed as tokens.
- getFieldMetadata() : array<string|int, mixed>
- Get the metadata for the available fields.
- getFieldValue() : string|int
- getHiddenTokens() : array<string|int, mixed>
- Get tokens to be suppressed from the widget.
- getMetadataForField() : array<string|int, mixed>
- Get the metadata for the field.
- getRelatedTokens() : array<string|int, mixed>
- Get related entity tokens.
- getRelatedTokensForEntity() : array<string|int, mixed>
- Get metadata for tokens for a related entity joined by a field on the main entity.
- getReturnFields() : array<string|int, string>
- Get an array of fields to be requested.
- getSkippedFields() : array<string|int, string>
- Get entity fields that should not be exposed as tokens.
- getTokenMappingsForRelatedEntities() : array<string|int, mixed>
- Get token mappings for related entities - specifically the contact entity.
- getTokenMetadata() : array<string|int, mixed>
- Get the metadata about the available tokens
- getTokenMetadataOverrides() : array<string|int, array<string|int, string>>
- Get any overrides for token metadata.
- isBooleanField() : bool
- Is the given field a boolean field.
- isCustomField() : bool
- Is the given field a custom field.
- isDateField() : bool
- Is the given field a date field.
- isMoneyField() : bool
- Is the given field a date field.
- isPseudoField() : bool
- Is the given field a pseudo field.
Properties
$activeTokens
public
array<string|int, mixed>
$activeTokens
List of active tokens - tokens provided by this class and used in the message Array(string $tokenName);
$entity
public
string
$entity
Ex: 'contact' or profile' or 'employer'
$tokenNames
public
array<string|int, mixed>
$tokenNames
List of tokens provided by this class Array(string $fieldName => string $label).
$checkPermissions
Should permissions be checked when loading tokens.
protected
bool
$checkPermissions
= \FALSE
$fieldMetadata
Metadata about the entity fields.
protected
array<string|int, mixed>
$fieldMetadata
= []
$prefetch
protected
array<string|int, mixed>
$prefetch
= []
$tokensMetadata
Metadata about all tokens.
protected
array<string|int, mixed>
$tokensMetadata
= []
Methods
__construct()
Class constructor.
public
__construct() : mixed
alterActionScheduleQuery()
Alter action schedule query.
public
alterActionScheduleQuery(MailingQueryEvent $e) : void
Parameters
- $e : MailingQueryEvent
checkActive()
Check if the token processor is active.
public
checkActive(TokenProcessor $processor) : bool
Parameters
- $processor : TokenProcessor
Return values
boolevaluateToken()
Evaluate the content of a single token.
public
evaluateToken(TokenRow $row, mixed $entity, mixed $field[, mixed $prefetch = NULL ]) : mixed
Parameters
- $row : TokenRow
-
The record for which we want token values.
- $entity : mixed
-
The name of the token entity.
- $field : mixed
-
The name of the token field.
- $prefetch : mixed = NULL
-
Any data that was returned by the prefetch().
Tags
evaluateTokens()
Populate the token data.
public
evaluateTokens(TokenValueEvent $e) : mixed
Parameters
- $e : TokenValueEvent
-
The event, which includes a list of rows and tokens.
getActiveTokens()
To handle variable tokens, override this function and return the active tokens.
public
getActiveTokens(TokenValueEvent $e) : mixed
Parameters
- $e : TokenValueEvent
getCurrencyFieldName()
public
getCurrencyFieldName() : array<string|int, mixed>
Return values
array<string|int, mixed>getExtendableTableName()
Get the name of the table this token class can extend.
public
getExtendableTableName() : string
The default is based on the entity but some token classes, specifically the event class, latch on to other tables - ie the participant table.
Return values
stringgetPrefetchFields()
Get the fields required to prefetch the entity.
public
getPrefetchFields(TokenValueEvent $e) : array<string|int, mixed>
Parameters
- $e : TokenValueEvent
Tags
Return values
array<string|int, mixed>getSubscribedEvents()
public
static getSubscribedEvents() : mixed
isHTMLTextField()
Is the text stored in html format.
public
isHTMLTextField(string $fieldName) : bool
Parameters
- $fieldName : string
Return values
boolprefetch()
To perform a bulk lookup before rendering tokens, override this function and return the prefetched data.
public
prefetch(TokenValueEvent $e) : mixed
Parameters
- $e : TokenValueEvent
registerTokens()
Register the declared tokens.
public
registerTokens(TokenRegisterEvent $e) : mixed
Parameters
- $e : TokenRegisterEvent
-
The registration event. Add new tokens using register().
addFieldToTokenMetadata()
Add the token to the metadata based on the field spec.
protected
addFieldToTokenMetadata(array<string|int, mixed> &$tokensMetadata, array<string|int, mixed> $field, array<string|int, mixed> $exposedFields[, string $prefix = '' ]) : void
Parameters
- $tokensMetadata : array<string|int, mixed>
- $field : array<string|int, mixed>
- $exposedFields : array<string|int, mixed>
- $prefix : string = ''
getApiEntityName()
Get the entity name for api v4 calls.
protected
getApiEntityName() : string
Return values
stringgetBasicTokens()
protected
getBasicTokens() : array<string|int, string>
Tags
Return values
array<string|int, string>getBespokeTokens()
Get any tokens with custom calculation.
protected
getBespokeTokens() : array<string|int, mixed>
Return values
array<string|int, mixed>getCacheKey()
Get a cache key appropriate to the current usage.
protected
getCacheKey() : string
Return values
stringgetCurrency()
Get the currency to use for formatting money.
protected
getCurrency(mixed $row) : string
Parameters
- $row : mixed
Return values
stringgetCustomFieldName()
Get the apiv4 style custom field name.
protected
getCustomFieldName(int $id) : string
Parameters
- $id : int
Tags
Return values
stringgetCustomFieldValue()
protected
getCustomFieldValue(mixed $entityID, string $field) : array<string|int, mixed>|string|void|null
Parameters
- $entityID : mixed
- $field : string
-
eg. 'custom_1'
Tags
Return values
array<string|int, mixed>|string|void|null —$mixed
getDependencies()
Get fields which need to be returned to render another token.
protected
getDependencies() : array<string|int, mixed>
Return values
array<string|int, mixed>getDeprecatedTokens()
Get array of deprecated tokens and the new token they map to.
protected
getDeprecatedTokens() : array<string|int, mixed>
Return values
array<string|int, mixed>getEntityAlias()
Get the entity alias to use within queries.
protected
getEntityAlias() : string
The default has a double underscore which should prevent any ambiguity with an existing table name.
Return values
stringgetEntityIDField()
protected
getEntityIDField() : string
Return values
stringgetEntityName()
protected
getEntityName() : string
Return values
stringgetExposedFields()
Get entity fields that should be exposed as tokens.
protected
getExposedFields() : array<string|int, string>
Return values
array<string|int, string>getFieldMetadata()
Get the metadata for the available fields.
protected
getFieldMetadata() : array<string|int, mixed>
Return values
array<string|int, mixed>getFieldValue()
protected
getFieldValue(TokenRow $row, string $field) : string|int
Parameters
- $row : TokenRow
- $field : string
Return values
string|intgetHiddenTokens()
Get tokens to be suppressed from the widget.
protected
getHiddenTokens() : array<string|int, mixed>
Note this is expected to be an interim function. Now we are no longer working around the parent function we can just define them once... with metadata, in a future refactor.
Return values
array<string|int, mixed>getMetadataForField()
Get the metadata for the field.
protected
getMetadataForField(string $fieldName) : array<string|int, mixed>
Parameters
- $fieldName : string
Return values
array<string|int, mixed>getRelatedTokens()
Get related entity tokens.
protected
getRelatedTokens() : array<string|int, mixed>
Return values
array<string|int, mixed>getRelatedTokensForEntity()
Get metadata for tokens for a related entity joined by a field on the main entity.
protected
getRelatedTokensForEntity(string $entity, string $joinField, array<string|int, mixed> $tokenList[, array<string|int, mixed> $hiddenTokens = [] ]) : array<string|int, mixed>
Parameters
- $entity : string
- $joinField : string
- $tokenList : array<string|int, mixed>
- $hiddenTokens : array<string|int, mixed> = []
Tags
Return values
array<string|int, mixed>getReturnFields()
Get an array of fields to be requested.
protected
getReturnFields() : array<string|int, string>
Tags
Return values
array<string|int, string>getSkippedFields()
Get entity fields that should not be exposed as tokens.
protected
getSkippedFields() : array<string|int, string>
Return values
array<string|int, string>getTokenMappingsForRelatedEntities()
Get token mappings for related entities - specifically the contact entity.
protected
getTokenMappingsForRelatedEntities() : array<string|int, mixed>
This function exists to help manage the way contact tokens is structured of an query-object style result set that needs to be mapped to apiv4.
The end goal is likely to be to advertised tokens that better map to api v4 and deprecate the existing ones but that is a long-term migration.
Return values
array<string|int, mixed>getTokenMetadata()
Get the metadata about the available tokens
protected
getTokenMetadata() : array<string|int, mixed>
Return values
array<string|int, mixed>getTokenMetadataOverrides()
Get any overrides for token metadata.
protected
getTokenMetadataOverrides() : array<string|int, array<string|int, string>>
This is most obviously used for setting the audience, which will affect widget-presence.
Return values
array<string|int, array<string|int, string>>isBooleanField()
Is the given field a boolean field.
protected
isBooleanField(string $fieldName) : bool
Parameters
- $fieldName : string
Return values
boolisCustomField()
Is the given field a custom field.
protected
isCustomField(string $fieldName) : bool
Parameters
- $fieldName : string
Return values
boolisDateField()
Is the given field a date field.
protected
isDateField(string $fieldName) : bool
Parameters
- $fieldName : string
Return values
boolisMoneyField()
Is the given field a date field.
protected
isMoneyField(string $fieldName) : bool
Parameters
- $fieldName : string
Return values
boolisPseudoField()
Is the given field a pseudo field.
protected
isPseudoField(string $fieldName) : bool
Parameters
- $fieldName : string