Skip to content
Permalink
Browse files

Update Email to use the StaticConfigTrait.

Fix an issue in the trait where errors would be generated by
implementing classes lacking a $_registry property.
  • Loading branch information...
markstory committed Aug 26, 2013
1 parent 4a7ede1 commit 2bed4670dee2b913fc0e35e03042855a3f7e11b0
Showing with 12 additions and 41 deletions.
  1. +1 −1 lib/Cake/Core/StaticConfigTrait.php
  2. +11 −40 lib/Cake/Network/Email/Email.php
@@ -102,7 +102,7 @@ public static function drop($config) {
if (!isset(static::$_config[$config])) {
return false;
}
if (isset(static::$_registry->{$config})) {
if (isset(static::$_registry) && isset(static::$_registry->{$config})) {
static::$_registry->unload($config);
}
unset(static::$_config[$config]);
@@ -16,6 +16,7 @@
use Cake\Core\App;
use Cake\Core\Configure;
use Cake\Core\StaticConfigTrait;
use Cake\Error;
use Cake\Log\Log;
use Cake\Network\Http\FormData\Part;
@@ -30,9 +31,19 @@
*
* This class is used for sending Internet Message Format based
* on the standard outlined in http://www.rfc-editor.org/rfc/rfc2822.txt
*
* ### Configuration
*
* Configuration for Email is managed by Email::config() and Email::configTransport().
* Email::config() can be used to add or read a configuration profile for Email instances.
* Once made configuration profiles can be used to re-use across various email messages your
* application sends.
*
*/
class Email {
use StaticConfigTrait;
/**
* Default X-Mailer
*
@@ -1132,46 +1143,6 @@ public static function dropTransport($key) {
unset(static::$_transportConfig[$key]);
}
/**
* Add or read a configuration profile for Email instances.
*
* This method is used to read or define configuration profiles for
* Email. Once made configuration profiles can be used to re-use the same
* sets of configuration across multiple email messages.
*
* @param string|array $key The name of the configuration profile to read/create
* or an array of multiple configuration profiles to set
* @param null|array $config Null to read config data, an array to set data.
* @return array|void
* @throws Cake\Error\Exception When modifying an existing configuration.
*/
public static function config($key, $config = null) {
// Read config.
if ($config === null && is_string($key)) {
return isset(static::$_config[$key]) ? static::$_config[$key] : null;
}
if ($config === null && is_array($key)) {
foreach ($key as $name => $settings) {
static::config($name, $settings);
}
return;
}
if (isset(static::$_config[$key])) {
throw new Error\Exception(__d('cake_dev', 'Cannot modify an existing config "%s"', $key));
}
static::$_config[$key] = $config;
}
/**
* Drop a configured profile.
*
* @param string $key The profile to drop.
* @return void
*/
public static function drop($key) {
unset(static::$_config[$key]);
}
/**
* Get/Set the configuration profile to use for this instance.
*

0 comments on commit 2bed467

Please sign in to comment.
You can’t perform that action at this time.