Commit b21ffed7 authored by totten's avatar totten

CRM-20958 - Create case-activity triggers (to update case when activity changes)

parent e0a667ad
......@@ -218,6 +218,29 @@ class Container {
array('civicrm_case', 'Case')
))->addTag('kernel.event_listener', array('event' => 'hook_civicrm_triggerInfo', 'method' => 'onTriggerInfo'));
$container->setDefinition('civi.case.staticTriggers', new Definition(
'Civi\Core\SqlTrigger\StaticTriggers',
array(
array(
array(
'upgrade_check' => array('table' => 'civicrm_case', 'column' => 'modified_date'),
'table' => 'civicrm_case_activity',
'when' => 'AFTER',
'event' => array('INSERT'),
'sql' => "\nUPDATE civicrm_case SET modified_date = CURRENT_TIMESTAMP WHERE id = NEW.case_id;\n",
),
array(
'upgrade_check' => array('table' => 'civicrm_case', 'column' => 'modified_date'),
'table' => 'civicrm_activity',
'when' => 'BEFORE',
'event' => array('UPDATE', 'DELETE'),
'sql' => "\nUPDATE civicrm_case SET modified_date = CURRENT_TIMESTAMP WHERE id IN (SELECT ca.case_id FROM civicrm_case_activity ca WHERE ca.activity_id = OLD.id);\n",
),
),
)
))
->addTag('kernel.event_listener', array('event' => 'hook_civicrm_triggerInfo', 'method' => 'onTriggerInfo'));
$container->setDefinition('civi_token_compat', new Definition(
'Civi\Token\TokenCompatSubscriber',
array()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment