From: Tim Otten Date: Wed, 6 May 2020 02:17:03 +0000 (-0700) Subject: dev/core#1744 - ActionSchedule - Simplify event naming X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=bc2feeb1aafa471a82ccd9809a108ed3820b99e4;p=civicrm-core.git dev/core#1744 - ActionSchedule - Simplify event naming --- diff --git a/CRM/Core/BAO/ActionSchedule.php b/CRM/Core/BAO/ActionSchedule.php index 6a1472390d..c1d7ec1a10 100644 --- a/CRM/Core/BAO/ActionSchedule.php +++ b/CRM/Core/BAO/ActionSchedule.php @@ -36,7 +36,7 @@ class CRM_Core_BAO_ActionSchedule extends CRM_Core_DAO_ActionSchedule { if ($_action_mapping === NULL) { $event = \Civi::dispatcher() - ->dispatch(\Civi\ActionSchedule\Events::MAPPINGS, + ->dispatch('civi.actionSchedule.getMappings', new \Civi\ActionSchedule\Event\MappingRegisterEvent()); $_action_mapping = $event->getMappings(); } @@ -516,7 +516,7 @@ FROM civicrm_action_schedule cas \Civi::dispatcher() ->dispatch( - \Civi\ActionSchedule\Events::MAILING_QUERY, + 'civi.actionSchedule.prepareMailingQuery', new \Civi\ActionSchedule\Event\MailingQueryEvent($actionSchedule, $mapping, $select) ); diff --git a/Civi/ActionSchedule/Event/MailingQueryEvent.php b/Civi/ActionSchedule/Event/MailingQueryEvent.php index e8b136e84d..0158b41e7d 100644 --- a/Civi/ActionSchedule/Event/MailingQueryEvent.php +++ b/Civi/ActionSchedule/Event/MailingQueryEvent.php @@ -37,6 +37,8 @@ use Symfony\Component\EventDispatcher\Event; * * (Note: When adding more JOINs, it seems typical to use !casMailingJoinType, although * some hard-code a LEFT JOIN. Don't have an explanation for why.) + * + * Event name: 'civi.actionSchedule.prepareMailingQuery' */ class MailingQueryEvent extends Event { diff --git a/Civi/ActionSchedule/Event/MappingRegisterEvent.php b/Civi/ActionSchedule/Event/MappingRegisterEvent.php index d3a29c3c5a..ef8c7f3750 100644 --- a/Civi/ActionSchedule/Event/MappingRegisterEvent.php +++ b/Civi/ActionSchedule/Event/MappingRegisterEvent.php @@ -9,6 +9,8 @@ use Symfony\Component\EventDispatcher\Event; * @package Civi\ActionSchedule\Event * * Register any available mappings. + * + * Event name: 'civi.actionSchedule.getMappings' */ class MappingRegisterEvent extends Event { diff --git a/Civi/ActionSchedule/Events.php b/Civi/ActionSchedule/Events.php index 3ff1a385e1..7c74d56c14 100644 --- a/Civi/ActionSchedule/Events.php +++ b/Civi/ActionSchedule/Events.php @@ -4,15 +4,14 @@ namespace Civi\ActionSchedule; class Events { /** - * Register any available mappings. - * - * @see EntityListEvent + * @see \Civi\ActionSchedule\Event\MappingRegisterEvent + * @deprecated - You may simply use the event name directly. dev/core#1744 */ const MAPPINGS = 'civi.actionSchedule.getMappings'; /** - * Prepare the pre-mailing query. This query loads details about - * the contact/entity so that they're available for mail-merge. + * @see \Civi\ActionSchedule\Event\MailingQueryEvent + * @deprecated - You may simply use the event name directly. dev/core#1744 */ const MAILING_QUERY = 'civi.actionSchedule.prepareMailingQuery'; diff --git a/Civi/Core/Container.php b/Civi/Core/Container.php index 7493eff178..da029cfa4e 100644 --- a/Civi/Core/Container.php +++ b/Civi/Core/Container.php @@ -362,12 +362,12 @@ class Container { 'CRM_Core_LegacyErrorHandler', 'handleException', ], -200); - $dispatcher->addListener(\Civi\ActionSchedule\Events::MAPPINGS, ['CRM_Activity_ActionMapping', 'onRegisterActionMappings']); - $dispatcher->addListener(\Civi\ActionSchedule\Events::MAPPINGS, ['CRM_Contact_ActionMapping', 'onRegisterActionMappings']); - $dispatcher->addListener(\Civi\ActionSchedule\Events::MAPPINGS, ['CRM_Contribute_ActionMapping_ByPage', 'onRegisterActionMappings']); - $dispatcher->addListener(\Civi\ActionSchedule\Events::MAPPINGS, ['CRM_Contribute_ActionMapping_ByType', 'onRegisterActionMappings']); - $dispatcher->addListener(\Civi\ActionSchedule\Events::MAPPINGS, ['CRM_Event_ActionMapping', 'onRegisterActionMappings']); - $dispatcher->addListener(\Civi\ActionSchedule\Events::MAPPINGS, ['CRM_Member_ActionMapping', 'onRegisterActionMappings']); + $dispatcher->addListener('civi.actionSchedule.getMappings', ['CRM_Activity_ActionMapping', 'onRegisterActionMappings']); + $dispatcher->addListener('civi.actionSchedule.getMappings', ['CRM_Contact_ActionMapping', 'onRegisterActionMappings']); + $dispatcher->addListener('civi.actionSchedule.getMappings', ['CRM_Contribute_ActionMapping_ByPage', 'onRegisterActionMappings']); + $dispatcher->addListener('civi.actionSchedule.getMappings', ['CRM_Contribute_ActionMapping_ByType', 'onRegisterActionMappings']); + $dispatcher->addListener('civi.actionSchedule.getMappings', ['CRM_Event_ActionMapping', 'onRegisterActionMappings']); + $dispatcher->addListener('civi.actionSchedule.getMappings', ['CRM_Member_ActionMapping', 'onRegisterActionMappings']); return $dispatcher; } diff --git a/Civi/Token/AbstractTokenSubscriber.php b/Civi/Token/AbstractTokenSubscriber.php index 4f16782876..024f855b3e 100644 --- a/Civi/Token/AbstractTokenSubscriber.php +++ b/Civi/Token/AbstractTokenSubscriber.php @@ -43,7 +43,7 @@ abstract class AbstractTokenSubscriber implements EventSubscriberInterface { return [ 'civi.token.list' => 'registerTokens', 'civi.token.eval' => 'evaluateTokens', - \Civi\ActionSchedule\Events::MAILING_QUERY => 'alterActionScheduleQuery', + 'civi.actionSchedule.prepareMailingQuery' => 'alterActionScheduleQuery', ]; }