Skip to content

Commit

Permalink
optmizing CakeEmail, and improving tests, transport class config() no…
Browse files Browse the repository at this point in the history
…w returns configs array if no array is passed
  • Loading branch information
ceeram committed Aug 29, 2011
1 parent 9300f09 commit 2efa3b0
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 142 deletions.
6 changes: 0 additions & 6 deletions app/Config/email.php.default
Expand Up @@ -85,11 +85,5 @@ class EmailConfig {
'client' => null
);

public $test = array(
'from' => array('some@example.com' => 'My website'),
'to' => array('test@example.com' => 'Testname'),
'subject' => 'Test mail subject',
'transport' => 'Debug',
);

}
6 changes: 0 additions & 6 deletions lib/Cake/Console/Templates/skel/Config/email.php.default
Expand Up @@ -85,11 +85,5 @@ class EmailConfig {
'client' => null
);

public $test = array(
'from' => array('some@example.com' => 'My website'),
'to' => array('test@example.com' => 'Testname'),
'subject' => 'Test mail subject',
'transport' => 'Debug',
);

}
9 changes: 5 additions & 4 deletions lib/Cake/Network/Email/AbstractTransport.php
Expand Up @@ -42,13 +42,14 @@ abstract public function send(CakeEmail $email);
/**
* Set the config
*
* @param array $config
* @return object $this
* @param mixed $config
* @return array Returns configs
*/
public function config($config = array()) {
if (!empty($config)) {
public function config($config = null) {
if (is_array($config)) {
$this->_config = $config;
}
return $this->_config;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Network/Email/CakeEmail.php
Expand Up @@ -942,7 +942,7 @@ public function send($content = null) {
$this->_message[] = '';
}
$contents = $this->transportClass()->send($this);
if (isset($this->_config['log']) && $this->_config['log']) {
if (!empty($this->_config['log'])) {
$level = LOG_DEBUG;
if ($this->_config['log'] !== true) {
$level = $this->_config['log'];
Expand Down Expand Up @@ -995,7 +995,7 @@ public static function deliver($to = null, $subject = null, $message = null, $tr
*/
protected function _applyConfig($config) {
if (is_string($config)) {
if (!config('email')) {
if (!class_exists('EmailConfig') && !config('email')) {
throw new SocketException(__d('cake', '%s not found.', APP . 'Config' . DS . 'email.php'));
}
$configs = new EmailConfig();
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Network/Email/DebugTransport.php
Expand Up @@ -34,7 +34,7 @@ class DebugTransport extends AbstractTransport {
public function send(CakeEmail $email) {
$headers = $email->getHeaders(array('from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc', 'subject'));
$headers = $this->_headersToString($headers);
$message = implode((array)$email->message(), "\n");
$message = implode("\n", (array)$email->message());
return array('headers' => $headers, 'message' => $message);
}

Expand Down

0 comments on commit 2efa3b0

Please sign in to comment.