Skip to content

Commit

Permalink
Fixes codeigniter4#1042 : add support both array and Config\Email
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed May 24, 2018
1 parent 81cb807 commit 650e7cf
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions system/Email/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* @filesource
*/

use Config\Email as ConfigEmail;
use Config\Mimes;


Expand Down Expand Up @@ -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)
{
Expand All @@ -400,14 +401,22 @@ public function __construct($config = null)
/**
* Initialize preferences
*
* @param array $config
* @param ConfigEmail|array $config
*
* @return Email
*/
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))
Expand Down

0 comments on commit 650e7cf

Please sign in to comment.