From 9407546428fd44e96a457c67fe81b568e724911b Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 3 Mar 2017 14:43:27 -0800 Subject: [PATCH 1/3] CRM-20224 - CRM_Core_DAO - Rename internal events (`DAO::foo-bar` vs `civi.dao.fooBar`) If you look at the list of events emitted through the EventDispatcher, you'll find several different formats for the names: ``` actionSchedule.getMappings actionSchedule.prepareMailingQuery api.authorize api.exception api.prepare api.resolve api.respond civi.core.install civi.token.eval civi.token.list civi.token.render DAO::post-delete DAO::post-insert DAO::post-update hook_civicrm_caseChange hook_civicrm_post::Activity hook_civicrm_post::Case hook_civicrm_unhandled_exception ``` This patch renames events using the `DAO::foo-bar` convention. Based on grepping universe, I don't believe any extensions rely on the `DAO::*` events. --- CRM/Core/DAO.php | 6 +++--- Civi/Core/Container.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index 2c4d8992b7a1..351819f1787f 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -480,7 +480,7 @@ public function save($hook = TRUE) { if ($hook) { $event = new \Civi\Core\DAO\Event\PostUpdate($this); - \Civi::service('dispatcher')->dispatch("DAO::post-update", $event); + \Civi::service('dispatcher')->dispatch("civi.dao.postUpdate", $event); } } else { @@ -488,7 +488,7 @@ public function save($hook = TRUE) { if ($hook) { $event = new \Civi\Core\DAO\Event\PostUpdate($this); - \Civi::service('dispatcher')->dispatch("DAO::post-insert", $event); + \Civi::service('dispatcher')->dispatch("civi.dao.postInsert", $event); } } $this->free(); @@ -529,7 +529,7 @@ public function delete($useWhere = FALSE) { $result = parent::delete($useWhere); $event = new \Civi\Core\DAO\Event\PostDelete($this, $result); - \Civi::service('dispatcher')->dispatch("DAO::post-delete", $event); + \Civi::service('dispatcher')->dispatch("civi.dao.postDelete", $event); $this->free(); return $result; diff --git a/Civi/Core/Container.php b/Civi/Core/Container.php index 76076375a657..d95b62aac13f 100644 --- a/Civi/Core/Container.php +++ b/Civi/Core/Container.php @@ -245,9 +245,9 @@ public function createEventDispatcher($container) { $dispatcher->addListener('hook_civicrm_post::Case', array('\Civi\CCase\Events', 'fireCaseChange')); $dispatcher->addListener('hook_civicrm_caseChange', array('\Civi\CCase\Events', 'delegateToXmlListeners')); $dispatcher->addListener('hook_civicrm_caseChange', array('\Civi\CCase\SequenceListener', 'onCaseChange_static')); - $dispatcher->addListener('DAO::post-insert', array('\CRM_Core_BAO_RecurringEntity', 'triggerInsert')); - $dispatcher->addListener('DAO::post-update', array('\CRM_Core_BAO_RecurringEntity', 'triggerUpdate')); - $dispatcher->addListener('DAO::post-delete', array('\CRM_Core_BAO_RecurringEntity', 'triggerDelete')); + $dispatcher->addListener('civi.dao.postInsert', array('\CRM_Core_BAO_RecurringEntity', 'triggerInsert')); + $dispatcher->addListener('civi.dao.postUpdate', array('\CRM_Core_BAO_RecurringEntity', 'triggerUpdate')); + $dispatcher->addListener('civi.dao.postDelete', array('\CRM_Core_BAO_RecurringEntity', 'triggerDelete')); $dispatcher->addListener('hook_civicrm_unhandled_exception', array( 'CRM_Core_LegacyErrorHandler', 'handleException', From f247addc55ecf9e35dbd1afd8c8da044bef7a3c3 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 7 Mar 2017 00:14:55 -0800 Subject: [PATCH 2/3] CRM-20224 - Civi\API\Events - Rename internal events (`api.foo` vs `civi.api.foo`) If you look at the list of events emitted through the EventDispatcher, you'll find several different formats for the names: ``` actionSchedule.getMappings actionSchedule.prepareMailingQuery api.authorize api.exception api.prepare api.resolve api.respond civi.core.install civi.token.eval civi.token.list civi.token.render DAO::post-delete DAO::post-insert DAO::post-update hook_civicrm_caseChange hook_civicrm_post::Activity hook_civicrm_post::Case hook_civicrm_unhandled_exception ``` This patch renames events using the `api.foo` convention. Based on grepping universe, I don't believe any extensions rely on the `DAO::*` events. --- Civi/API/Events.php | 10 +++++----- Civi/API/Subscriber/WrapperAdapter.php | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Civi/API/Events.php b/Civi/API/Events.php index c6abcb011f45..1dd734927820 100644 --- a/Civi/API/Events.php +++ b/Civi/API/Events.php @@ -45,7 +45,7 @@ class Events { * * @see AuthorizeEvent */ - const AUTHORIZE = 'api.authorize'; + const AUTHORIZE = 'civi.api.authorize'; /** * Determine which API provider executes the given request. For successful @@ -54,28 +54,28 @@ class Events { * * @see ResolveEvent */ - const RESOLVE = 'api.resolve'; + const RESOLVE = 'civi.api.resolve'; /** * Apply pre-execution logic * * @see PrepareEvent */ - const PREPARE = 'api.prepare'; + const PREPARE = 'civi.api.prepare'; /** * Apply post-execution logic * * @see RespondEvent */ - const RESPOND = 'api.respond'; + const RESPOND = 'civi.api.respond'; /** * Handle any exceptions. * * @see ExceptionEvent */ - const EXCEPTION = 'api.exception'; + const EXCEPTION = 'civi.api.exception'; /** * Weight - Early diff --git a/Civi/API/Subscriber/WrapperAdapter.php b/Civi/API/Subscriber/WrapperAdapter.php index 00274a932f3a..9340b3b720eb 100644 --- a/Civi/API/Subscriber/WrapperAdapter.php +++ b/Civi/API/Subscriber/WrapperAdapter.php @@ -33,7 +33,7 @@ /** * This is a wrapper for the legacy "API Wrapper" interface which allows * wrappers to run through the new kernel. It translates from dispatcher events - * ('api.prepare', 'api.respond') to wrapper calls ('fromApiInput', 'toApiOutput'). + * ('civi.api.prepare', 'civi.api.respond') to wrapper calls ('fromApiInput', 'toApiOutput'). */ class WrapperAdapter implements EventSubscriberInterface { From fa6fce2f06fba0d4a7c5454e34c0184589f8be05 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 7 Mar 2017 00:17:32 -0800 Subject: [PATCH 3/3] CRM-20224 - Civi\ActionSchedule\Events - Rename internal events (`actionSchedule.fooBar` vs `civi.actionSchedule.fooBar`) If you look at the list of events emitted through the EventDispatcher, you'll find several different formats for the names: ``` actionSchedule.getMappings actionSchedule.prepareMailingQuery api.authorize api.exception api.prepare api.resolve api.respond civi.core.install civi.token.eval civi.token.list civi.token.render DAO::post-delete DAO::post-insert DAO::post-update hook_civicrm_caseChange hook_civicrm_post::Activity hook_civicrm_post::Case hook_civicrm_unhandled_exception ``` This patch renames events using the `actionSchedule.fooBar` convention. Based on grepping universe, I don't believe any extensions rely on the `DAO::*` events. --- Civi/ActionSchedule/Events.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Civi/ActionSchedule/Events.php b/Civi/ActionSchedule/Events.php index 15e49f71db83..3ff1a385e132 100644 --- a/Civi/ActionSchedule/Events.php +++ b/Civi/ActionSchedule/Events.php @@ -8,12 +8,12 @@ class Events { * * @see EntityListEvent */ - const MAPPINGS = 'actionSchedule.getMappings'; + 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. */ - const MAILING_QUERY = 'actionSchedule.prepareMailingQuery'; + const MAILING_QUERY = 'civi.actionSchedule.prepareMailingQuery'; }