From 3c8059c83afe0533c9c67ae9983ee6dddefac3d0 Mon Sep 17 00:00:00 2001 From: Keith Morgan Date: Mon, 1 Apr 2013 18:19:12 -0500 Subject: [PATCH] Cleaned up hook invocations. --- CRM/Core/BAO/MessageTemplates.php | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/CRM/Core/BAO/MessageTemplates.php b/CRM/Core/BAO/MessageTemplates.php index 07f61d5b9f..0963e940a1 100644 --- a/CRM/Core/BAO/MessageTemplates.php +++ b/CRM/Core/BAO/MessageTemplates.php @@ -84,27 +84,15 @@ class CRM_Core_BAO_MessageTemplates extends CRM_Core_DAO_MessageTemplates { * @return object */ static function add(&$params) { - $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE); - - if (CRM_Utils_Array::value('id', $params)) { - CRM_Utils_Hook::pre('edit', 'MessageTemplate', $params['id'], $params); - } - else { - CRM_Utils_Hook::pre('create', 'MessageTemplate', NULL, $params); - } + $hook = empty($params['id']) ? 'create' : 'edit'; + CRM_Utils_Hook::pre($hook, 'MessageTemplate', CRM_Utils_Array::value('id', $params), $params); + $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE); $messageTemplates = new CRM_Core_DAO_MessageTemplates(); $messageTemplates->copyValues($params); - $messageTemplates->save(); - if (CRM_Utils_Array::value('id', $params)) { - CRM_Utils_Hook::post('edit', 'MessageTemplate', $messageTemplates->id, $messageTemplates); - } - else { - CRM_Utils_Hook::post('create', 'MessageTemplate', $messageTemplates->id, $messageTemplates); - } - + CRM_Utils_Hook::post($hook, 'MessageTemplate', $messageTemplates>id, $messageTemplates); return $messageTemplates; } -- 2.25.1