From: Tim Otten Date: Wed, 26 May 2021 20:53:54 +0000 (-0700) Subject: (REF) RecurringEntity BAO - Switch EventSubscriberInterface X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=1191f87eb36192543728ef41e02cbc8581a94a10;p=civicrm-core.git (REF) RecurringEntity BAO - Switch EventSubscriberInterface This is just an example of doing declarative event-registration from a BAO. --- diff --git a/CRM/Core/BAO/RecurringEntity.php b/CRM/Core/BAO/RecurringEntity.php index fceb1237b1..750959d45b 100644 --- a/CRM/Core/BAO/RecurringEntity.php +++ b/CRM/Core/BAO/RecurringEntity.php @@ -20,7 +20,7 @@ use When\When; /** * Class CRM_Core_BAO_RecurringEntity. */ -class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { +class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity implements \Symfony\Component\EventDispatcher\EventSubscriberInterface { const RUNNING = 1; public $schedule = []; @@ -115,6 +115,14 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { const MODE_NEXT_ALL_ENTITY = 2; const MODE_ALL_ENTITY_IN_SERIES = 3; + public static function getSubscribedEvents() { + return [ + 'civi.dao.postInsert' => 'triggerInsert', + 'civi.dao.postUpdate' => 'triggerUpdate', + 'civi.dao.postDelete' => 'triggerDelete', + ]; + } + /** * Getter for status. * diff --git a/Civi/Core/Container.php b/Civi/Core/Container.php index 62f1879407..e6d1cff3b3 100644 --- a/Civi/Core/Container.php +++ b/Civi/Core/Container.php @@ -400,9 +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('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']); $dispatcher->addListener('hook_civicrm_postSave_civicrm_domain', ['\CRM_Core_BAO_Domain', 'onPostSave']); $dispatcher->addListener('hook_civicrm_unhandled_exception', [ 'CRM_Core_LegacyErrorHandler',