From 650e7cfd5e47d5944d954662664cfdd2328abfdb Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 25 May 2018 01:52:01 +0700 Subject: [PATCH] Fixes #1042 : add support both array and Config\Email --- system/Email/Email.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/system/Email/Email.php b/system/Email/Email.php index ac5ef13d87f7..af4586b34427 100644 --- a/system/Email/Email.php +++ b/system/Email/Email.php @@ -37,6 +37,7 @@ * @filesource */ +use Config\Email as ConfigEmail; use Config\Mimes; @@ -384,7 +385,7 @@ class Email * * The constructor can be passed an array of config values * - * @param array|null $config + * @param ConfigEmail|array|null $config */ public function __construct($config = null) { @@ -400,7 +401,7 @@ public function __construct($config = null) /** * Initialize preferences * - * @param array $config + * @param ConfigEmail|array $config * * @return Email */ @@ -408,6 +409,14 @@ public function initialize($config) { $this->clear(); + if (is_array($config)) { + $configEmail = new ConfigEmail(); + foreach ($config as $key => $value) { + $configEmail->$key = $value; + } + $config = $configEmail; + } + foreach (get_class_vars(get_class($this)) as $key => $value) { if (isset($this->$key) && isset($config->$key))