Documentation

TimestampTriggers
in package

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.

Tags
copyright

CiviCRM LLC https://civicrm.org/licensing

Table of Contents

Properties

$createdDate  : string
$customDataEntity  : string
$modifiedDate  : string
$relations  : array<string|int, mixed>
$tableName  : string

Methods

__construct()  : mixed
TimestampTriggers constructor.
alterTriggerInfo()  : mixed
Add our list of triggers to the global list.
create()  : TimestampTriggers
generateTimestampTriggers()  : mixed
Generate triggers to update the timestamp.
getAllRelations()  : array<string|int, mixed>
Get a list of all tracked relations.
getCreatedDate()  : string
getCustomDataEntity()  : string
getModifiedDate()  : string
getRelations()  : array<string|int, mixed>
getTableName()  : string
onTriggerInfo()  : mixed
Add our list of triggers to the global list.
setCreatedDate()  : TimestampTriggers
setCustomDataEntity()  : TimestampTriggers
setModifiedDate()  : TimestampTriggers
setRelations()  : TimestampTriggers
setTableName()  : TimestampTriggers

Properties

$createdDate

private string $createdDate

SQL column name. Ex: 'created_date'.

$customDataEntity

private string $customDataEntity

An entity name (from civicrm_custom_group.extends). Ex: 'Contact', 'Activity'.

$modifiedDate

private string $modifiedDate

SQL column name. Ex: 'modified_date'.

$relations

private array<string|int, mixed> $relations

Ex: $relations[0] == array('table' => 'civicrm_bar', 'column' => 'foo_id');

$tableName

private string $tableName

SQL table name. Ex: 'civicrm_contact', 'civicrm_activity'.

Methods

__construct()

TimestampTriggers constructor.

public __construct(string $tableName, string $customDataEntity[, string $createdDate = 'created_date' ][, string $modifiedDate = 'modified_date' ][, array<string|int, mixed> $relations = [] ]) : mixed
Parameters
$tableName : string

SQL table name. Ex: 'civicrm_contact', 'civicrm_activity'.

$customDataEntity : string

An entity name (from civicrm_custom_group.extends). Ex: 'Contact', 'Activity'.

$createdDate : string = 'created_date'

SQL column name. Ex: 'created_date'.

$modifiedDate : string = 'modified_date'

SQL column name. Ex: 'modified_date'.

$relations : array<string|int, mixed> = []

Ex: $relations[0] == array('table' => 'civicrm_bar', 'column' => 'foo_id');

alterTriggerInfo()

Add our list of triggers to the global list.

public alterTriggerInfo(array<string|int, mixed> &$info[, string|null $tableFilter = NULL ]) : mixed
Parameters
$info : array<string|int, mixed>

See hook_civicrm_triggerInfo.

$tableFilter : string|null = NULL

See hook_civicrm_triggerInfo.

Tags
see
CRM_Utils_Hook::triggerInfo
see
CRM_Core_DAO::triggerRebuild

create()

public static create(string $tableName, string $customDataEntity) : TimestampTriggers
Parameters
$tableName : string

SQL table name. Ex: 'civicrm_contact', 'civicrm_activity'.

$customDataEntity : string

An entity name (from civicrm_custom_group.extends). Ex: 'Contact', 'Activity'.

Return values
TimestampTriggers

generateTimestampTriggers()

Generate triggers to update the timestamp.

public generateTimestampTriggers(array<string|int, mixed> &$info, string|null $tableFilter, array<string|int, mixed> $relatedTableNames, string $contactRefColumn) : mixed

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
$info : array<string|int, mixed>

Reference to the array where generated trigger information is being stored

$tableFilter : string|null

Name of the table for which triggers are being generated, or NULL if all tables

$relatedTableNames : array<string|int, mixed>

Array of all core or all custom table names extending civicrm_FOO

$contactRefColumn : string

'contact_id' if processing core tables, 'entity_id' if processing custom tables

Tags
link
https://issues.civicrm.org/jira/browse/CRM-15602
see
triggerInfo

getAllRelations()

Get a list of all tracked relations.

public getAllRelations() : array<string|int, mixed>

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

Return values
array<string|int, mixed>

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

getCustomDataEntity()

public getCustomDataEntity() : string
Return values
string

getRelations()

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

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


        
On this page

Search results