mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
N°4947 Fix Email always picking "production" env config file (#331)
Note that the code was duplicated in both Email* impl, this is refactored : LoadConfig and m_oConfig are pulled up in Email, and SetRecipientFrom() calls are also refactored in Email
This commit is contained in:
@@ -34,6 +34,13 @@ define ('EMAIL_SEND_ERROR', 2);
|
||||
|
||||
class EMail implements iEMail
|
||||
{
|
||||
/**
|
||||
* @see self::LoadConfig()
|
||||
* @var Config
|
||||
* @since 2.7.7 3.0.2 3.1.0 N°3169 N°5102 Move attribute to children classes
|
||||
* @since 2.7.8 3.0.3 3.1.0 N°4947 pull up the attribute back to the Email class as config init is done here
|
||||
*/
|
||||
protected static $m_oConfig = null;
|
||||
protected $oMailer;
|
||||
|
||||
// Serialization formats
|
||||
@@ -46,6 +53,42 @@ class EMail implements iEMail
|
||||
$this->oMailer = EmailFactory::GetMailer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets {@see m_oConfig} if current attribute is null
|
||||
*
|
||||
* @returns \Config the current {@see m_oConfig} value
|
||||
* @throws \ConfigException
|
||||
* @throws \CoreException
|
||||
*
|
||||
* @uses utils::GetConfig()
|
||||
*
|
||||
* @since 2.7.7 3.0.2 3.1.0 N°3169 N°5102 Move method to children classes
|
||||
* @since 2.7.8 3.0.3 3.1.0 N°4947 Pull up to the parent class, and remove `$sConfigFile` param
|
||||
*/
|
||||
public function LoadConfig()
|
||||
{
|
||||
if (is_null(static::$m_oConfig)) {
|
||||
static::$m_oConfig = utils::GetConfig();
|
||||
}
|
||||
|
||||
return static::$m_oConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws \ConfigException
|
||||
* @throws \CoreException
|
||||
* @since 2.7.>8 3.0.3 3.1.0 N°4947 Method creation, to factorize same code in children classes
|
||||
*/
|
||||
protected function InitRecipientFrom()
|
||||
{
|
||||
$oConfig = $this->LoadConfig();
|
||||
$this->SetRecipientFrom(
|
||||
$oConfig->Get('email_default_sender_address'),
|
||||
$oConfig->Get('email_default_sender_label')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom serialization method
|
||||
* No longer use the brute force "serialize" method since
|
||||
@@ -146,5 +189,4 @@ class EMail implements iEMail
|
||||
{
|
||||
$this->oMailer->SetRecipientReplyTo($sAddress);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user