From c8e4bea0f8156933e67226b4261e6d56acdfe48d Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 5 Sep 2013 12:20:36 -0700 Subject: [PATCH] CRM-11958 - hook_civicrm_alterMailer - Cleanup comments/formatting ---------------------------------------- * CRM-11958: New hook implementation for altering outgoing mail configuration http://issues.civicrm.org/jira/browse/CRM-11958 --- CRM/Core/Config.php | 13 ++++---- CRM/Utils/Hook.php | 3 +- tests/phpunit/CRM/Core/Config/MailerTest.php | 33 ++++++++++++++++++++ 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/CRM/Core/Config.php b/CRM/Core/Config.php index 94dbefce4e..c7a82abac0 100644 --- a/CRM/Core/Config.php +++ b/CRM/Core/Config.php @@ -503,12 +503,10 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { } /** - * retrieve a mailer to send any mail from the applciation + * Retrieve a mailer to send any mail from the applciation * * @param boolean $persist open a persistent smtp connection, should speed up mailings - * * @access private - * * @return object */ static function &getMailer($persist = FALSE) { @@ -574,7 +572,7 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { CRM_Core_Error::debug_log_message(ts('Outbound mail has been disabled. Click Administer >> System Setting >> Outbound Email to set the OutBound Email.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1')))); CRM_Core_Session::setStatus(ts('Outbound mail has been disabled. Click Administer >> System Setting >> Outbound Email to set the OutBound Email.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1')))); } - else{ + else { CRM_Core_Error::debug_log_message(ts('There is no valid SMTP server Setting Or SendMail path setting. Click Administer >> System Setting >> Outbound Email to set the OutBound Email.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1')))); CRM_Core_Session::setStatus(ts('There is no valid SMTP server Setting Or sendMail path setting. Click Administer >> System Setting >> Outbound Email to set the OutBound Email.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/smtp', 'reset=1')))); CRM_Core_Error::debug_var('mailing_info', $mailingInfo); @@ -584,14 +582,17 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { } /** + * Create a new instance of a PEAR Mail driver + * * @param string $driver 'CRM_Mailing_BAO_Spool' or a name suitable for Mail::factory() * @param array $params - * @return Mail|NULL + * @return Mail (More specifically, a class which implements the "send()" function) */ public static function _createMailer($driver, $params) { if ($driver == 'CRM_Mailing_BAO_Spool') { $mailer = new CRM_Mailing_BAO_Spool($params); - } else { + } + else { $mailer = Mail::factory($driver, $params); } CRM_Utils_Hook::alterMail($mailer, $driver, $params); diff --git a/CRM/Utils/Hook.php b/CRM/Utils/Hook.php index c216b8190f..198664f0d7 100644 --- a/CRM/Utils/Hook.php +++ b/CRM/Utils/Hook.php @@ -1361,7 +1361,8 @@ abstract class CRM_Utils_Hook { * @see Mail::factory */ static function alterMail(&$mailer, $driver, $params) { - return self::singleton()->invoke(3, $mailer, $driver, $params, self::$_nullObject, self::$_nullObject, 'civicrm_alterMailer'); + return self::singleton() + ->invoke(3, $mailer, $driver, $params, self::$_nullObject, self::$_nullObject, 'civicrm_alterMailer'); } /** diff --git a/tests/phpunit/CRM/Core/Config/MailerTest.php b/tests/phpunit/CRM/Core/Config/MailerTest.php index 7365c3af0d..d53cc6cd46 100644 --- a/tests/phpunit/CRM/Core/Config/MailerTest.php +++ b/tests/phpunit/CRM/Core/Config/MailerTest.php @@ -1,4 +1,37 @@