From: Keith Morgan Date: Mon, 1 Apr 2013 23:19:12 +0000 (-0500) Subject: Cleaned up hook invocations. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=3c8059c83afe0533c9c67ae9983ee6dddefac3d0;p=civicrm-core.git Cleaned up hook invocations. --- 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; }