CRM-14786 - CaseType - Perform reconciliation whenever a case-type definition changes
authorTim Otten <totten@civicrm.org>
Sat, 28 Jun 2014 03:37:16 +0000 (20:37 -0700)
committerTim Otten <totten@civicrm.org>
Sat, 28 Jun 2014 03:37:16 +0000 (20:37 -0700)
CRM/Case/BAO/CaseType.php
CRM/Core/ManagedEntities.php

index 00e0547e97855ff04c5ec4acd52db4927aa1af88..ae5daeeddc474e2a163dc28dac5ff0cfbe37b1f5 100644 (file)
@@ -74,6 +74,7 @@ class CRM_Case_BAO_CaseType extends CRM_Case_DAO_CaseType {
     // function to format definition column
     if (isset($params['definition']) && is_array($params['definition'])) {
       $params['definition'] = self::convertDefinitionToXML($params['name'], $params['definition']);
+      CRM_Core_ManagedEntities::scheduleReconcilation();
     }
 
     $caseTypeDAO->copyValues($params);
index 52141b2f86c38471dd2e5d40fb57081e38de3893..10a7ff36f2080707a6fb2dc455d43e62f469258f 100644 (file)
@@ -36,6 +36,20 @@ class CRM_Core_ManagedEntities {
     return $singleton;
   }
 
+  /**
+   * Perform an asynchronous reconciliation when the transaction ends.
+   */
+  public static function scheduleReconcilation() {
+    CRM_Core_Transaction::addCallback(
+      CRM_Core_Transaction::PHASE_POST_COMMIT,
+      function () {
+        CRM_Core_ManagedEntities::singleton(TRUE)->reconcile();
+      },
+      array(),
+      'ManagedEntities::reconcile'
+    );
+  }
+
   /**
    * @param array $modules CRM_Core_Module
    * @param array $declarations per hook_civicrm_managed