class TimestampTriggers

Build a set of SQL triggers for tracking timestamps on an entity.

This class is a generalization of CRM-10554 with the aim of enabling CRM-20958.

Methods

create(string $tableName, string $customDataEntity)

No description

__construct(string $tableName, string $customDataEntity, string $createdDate = 'created_date', string $modifiedDate = 'modified_date', array $relations = [])

TimestampTriggers constructor.

onTriggerInfo(GenericHookEvent $e)

Add our list of triggers to the global list.

alterTriggerInfo(array $info, string|NULL $tableFilter = NULL)

Add our list of triggers to the global list.

generateTimestampTriggers(array $info, string|null $tableFilter, array $relatedTableNames, string $contactRefColumn)

Generate triggers to update the timestamp.

string
getTableName()

No description

setTableName(string $tableName)

No description

string
getCustomDataEntity()

No description

setCustomDataEntity(string $customDataEntity)

No description

string
getCreatedDate()

No description

setCreatedDate(string $createdDate)

No description

string
getModifiedDate()

No description

setModifiedDate(string $modifiedDate)

No description

array
getRelations()

No description

setRelations(array $relations)

No description

array
getAllRelations()

Get a list of all tracked relations.

Details

at line 84
static TimestampTriggers create(string $tableName, string $customDataEntity)

Parameters

string $tableName SQL table name. Ex: 'civicrm_contact', 'civicrm_activity'.
string $customDataEntity An entity name (from civicrm_custom_group.extends). Ex: 'Contact', 'Activity'.

Return Value

TimestampTriggers

at line 106
__construct(string $tableName, string $customDataEntity, string $createdDate = 'created_date', string $modifiedDate = 'modified_date', array $relations = [])

TimestampTriggers constructor.

Parameters

string $tableName SQL table name. Ex: 'civicrm_contact', 'civicrm_activity'.
string $customDataEntity An entity name (from civicrm_custom_group.extends). Ex: 'Contact', 'Activity'.
string $createdDate SQL column name. Ex: 'created_date'.
string $modifiedDate SQL column name. Ex: 'modified_date'.
array $relations Ex: $relations[0] == array('table' => 'civicrm_bar', 'column' => 'foo_id');

at line 126
onTriggerInfo(GenericHookEvent $e)

Add our list of triggers to the global list.

Parameters

GenericHookEvent $e

See also

CRM_Utils_Hook::triggerInfo

at line 141
alterTriggerInfo(array $info, string|NULL $tableFilter = NULL)

Add our list of triggers to the global list.

Parameters

array $info See hook_civicrm_triggerInfo.
string|NULL $tableFilter See hook_civicrm_triggerInfo.

See also

CRM_Utils_Hook::triggerInfo
CRM_Core_DAO::triggerRebuild

at line 192
generateTimestampTriggers(array $info, string|null $tableFilter, array $relatedTableNames, string $contactRefColumn)

Generate triggers to update the timestamp.

The corresponding civicrm_FOO row is updated on insert/update/delete to a table that extends civicrm_FOO. Don't regenerate triggers for all such tables if only asked for one table.

Parameters

array $info Reference to the array where generated trigger information is being stored
string|null $tableFilter Name of the table for which triggers are being generated, or NULL if all tables
array $relatedTableNames Array of all core or all custom table names extending civicrm_FOO
string $contactRefColumn 'contact_id' if processing core tables, 'entity_id' if processing custom tables

See also

triggerInfo

at line 228
string getTableName()

Return Value

string

at line 236
TimestampTriggers setTableName(string $tableName)

Parameters

string $tableName

Return Value

TimestampTriggers

at line 244
string getCustomDataEntity()

Return Value

string

at line 252
TimestampTriggers setCustomDataEntity(string $customDataEntity)

Parameters

string $customDataEntity

Return Value

TimestampTriggers

at line 260
string getCreatedDate()

Return Value

string

at line 268
TimestampTriggers setCreatedDate(string $createdDate)

Parameters

string $createdDate

Return Value

TimestampTriggers

at line 276
string getModifiedDate()

Return Value

string

at line 284
TimestampTriggers setModifiedDate(string $modifiedDate)

Parameters

string $modifiedDate

Return Value

TimestampTriggers

at line 293
array getRelations()

Return Value

array Each item is an array('table' => string, 'column' => string)

at line 301
TimestampTriggers setRelations(array $relations)

Parameters

array $relations

Return Value

TimestampTriggers

at line 314
array getAllRelations()

Get a list of all tracked relations.

This is basically the curated list ($this->relations) plus any custom data.

Return Value

array Each item is an array('table' => string, 'column' => string)