Skip to content

Commit

Permalink
Cleaning more code and replicating changes into the Email class
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Oct 29, 2014
1 parent 41c0c52 commit 3a1bb52
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/Core/StaticConfigTrait.php
Expand Up @@ -84,16 +84,16 @@ public static function config($key, $config = null) {
throw new BadMethodCallException(sprintf('Cannot reconfigure existing key "%s"', $key));
}

if (is_array($config) && isset($config['url'])) {
if (is_object($config)) {
$config = ['className' => $config];
}

if (isset($config['url'])) {
$parsed = static::parseDsn($config['url']);
unset($config['url']);
$config = $parsed + $config;
}

if (is_object($config)) {
$config = ['className' => $config];
}

if (isset($config['engine']) && empty($config['className'])) {
$config['className'] = $config['engine'];
unset($config['engine']);
Expand Down
16 changes: 9 additions & 7 deletions src/Network/Email/Email.php
Expand Up @@ -1169,15 +1169,17 @@ public static function configTransport($key, $config = null) {
if (isset(static::$_transportConfig[$key])) {
throw new BadMethodCallException(sprintf('Cannot modify an existing config "%s"', $key));
}
if (is_array($config)) {
$config = static::parseDsn($config);
} elseif ($config === null && is_array($key)) {
foreach ($key as $name => $settings) {
$key[$name] = static::parseDsn($settings);
}
} elseif (is_object($config)) {

if (is_object($config)) {
$config = ['className' => $config];
}

if (isset($config['url'])) {
$parsed = static::parseDsn($config['url']);
unset($config['url']);
$config = $parsed + $config;
}

static::$_transportConfig[$key] = $config;
}

Expand Down

0 comments on commit 3a1bb52

Please sign in to comment.