(REF) RelationshipCache BAO - Switch to HookInterface
authorTim Otten <totten@civicrm.org>
Wed, 26 May 2021 07:40:22 +0000 (00:40 -0700)
committerTim Otten <totten@civicrm.org>
Wed, 26 May 2021 23:52:24 +0000 (16:52 -0700)
This is just an example of doing declarative event-registration from a BAO.

CRM/Contact/BAO/RelationshipCache.php
Civi/Core/Container.php

index c1483973e8120dfed4339228f97e1d4777a486aa..b7622dfc65155b17e582afeed4d845e5e4c3767d 100644 (file)
@@ -12,7 +12,7 @@
 /**
  * Class CRM_Contact_BAO_RelationshipCache.
  */
-class CRM_Contact_BAO_RelationshipCache extends CRM_Contact_DAO_RelationshipCache {
+class CRM_Contact_BAO_RelationshipCache extends CRM_Contact_DAO_RelationshipCache implements \Civi\Test\HookInterface {
 
   /**
    * The "mappings" array defines the values to put into `civicrm_relationship_cache`
@@ -69,7 +69,7 @@ class CRM_Contact_BAO_RelationshipCache extends CRM_Contact_DAO_RelationshipCach
    * @param \Civi\Core\Event\GenericHookEvent $e
    * @see \CRM_Utils_Hook::triggerInfo
    */
-  public static function onHookTriggerInfo($e) {
+  public static function on_hook_civicrm_triggerInfo($e) {
     $relUpdates = self::createInsertUpdateQueries();
     // Use utf8mb4_bin or utf8_bin, depending on what's in use.
     $collation = preg_replace('/^(utf8(?:mb4)?)_.*$/', '$1_bin', CRM_Core_BAO_SchemaHandler::getInUseCollation());
index fa723a77b34c209bad7028d46a618bdd5033e017..62f18794078e343db23fe68f3abaa104fb6bd68b 100644 (file)
@@ -400,7 +400,6 @@ class Container {
     $dispatcher->addListener('hook_civicrm_permissionList', ['CRM_Core_Permission_List', 'findCiviPermissions'], 950);
     $dispatcher->addListener('hook_civicrm_permissionList', ['CRM_Core_Permission_List', 'findCmsPermissions'], 925);
 
-    $dispatcher->addListener('hook_civicrm_triggerInfo', ['\CRM_Contact_BAO_RelationshipCache', 'onHookTriggerInfo']);
     $dispatcher->addListener('civi.dao.postInsert', ['\CRM_Core_BAO_RecurringEntity', 'triggerInsert']);
     $dispatcher->addListener('civi.dao.postUpdate', ['\CRM_Core_BAO_RecurringEntity', 'triggerUpdate']);
     $dispatcher->addListener('civi.dao.postDelete', ['\CRM_Core_BAO_RecurringEntity', 'triggerDelete']);