Skip to content
Permalink
Browse files

Clean up Email API and combined setter getter methods.

  • Loading branch information...
dereuromark committed Dec 26, 2016
1 parent 59f019b commit c2bd06eace10874aacecb5a8b29ea81dc036a184
Showing with 57 additions and 13 deletions.
  1. +57 −13 src/Mailer/Email.php
@@ -485,7 +485,7 @@ public function replyTo($email = null, $name = null)
return $this->getReplyTo();
}
return $this->setReplyTo($email. $name);
return $this->setReplyTo($email, $name);
}
/**
@@ -1829,7 +1829,7 @@ public function message($type = null)
}
/**
* Add or read transport configuration.
* Sets transport configuration.
*
* Use this method to define transports to use in delivery profiles.
* Once defined you cannot edit the configurations, and must use
@@ -1840,27 +1840,25 @@ public function message($type = null)
* closure will be evaluated for each message.
*
* The `className` is used to define the class to use for a transport.
* It can either be a short name, or a fully qualified classname
* It can either be a short name, or a fully qualified class name
*
* @param string|array $key The configuration name to read/write. Or
* @param string|array $key The configuration name to write. Or
* an array of multiple transports to set.
* @param array|\Cake\Mailer\AbstractTransport|null $config Either an array of configuration
* data, or a transport instance.
* @return array|null Either null when setting or an array of data when reading.
* data, or a transport instance. Null when using key as array.
* @return void
* @throws \BadMethodCallException When modifying an existing configuration.
*/
public static function configTransport($key, $config = null)
public static function setConfigTransport($key, $config = null)
{
if ($config === null && is_string($key)) {
return isset(static::$_transportConfig[$key]) ? static::$_transportConfig[$key] : null;
}
if ($config === null && is_array($key)) {
if (is_array($key)) {
foreach ($key as $name => $settings) {
static::configTransport($name, $settings);
static::setConfigTransport($name, $settings);
}
return null;
return;
}
if (isset(static::$_transportConfig[$key])) {
throw new BadMethodCallException(sprintf('Cannot modify an existing config "%s"', $key));
}
@@ -1878,6 +1876,52 @@ public static function configTransport($key, $config = null)
static::$_transportConfig[$key] = $config;
}
/**
* Gets current transport configuration.
*
* @return array|null Transport config.
*/
public static function getConfigTransport($key)
{
return isset(static::$_transportConfig[$key]) ? static::$_transportConfig[$key] : null;
}
/**
* Add or read transport configuration.
*
* Use this method to define transports to use in delivery profiles.
* Once defined you cannot edit the configurations, and must use
* Email::dropTransport() to flush the configuration first.
*
* When using an array of configuration data a new transport
* will be constructed for each message sent. When using a Closure, the
* closure will be evaluated for each message.
*
* The `className` is used to define the class to use for a transport.
* It can either be a short name, or a fully qualified classname
*
* @deprecated 3.4.0 Use setConfigTransport()/getConfigTransport() instead.
* @param string|array $key The configuration name to read/write. Or
* an array of multiple transports to set.
* @param array|\Cake\Mailer\AbstractTransport|null $config Either an array of configuration
* data, or a transport instance.
* @return array|null Either null when setting or an array of data when reading.
* @throws \BadMethodCallException When modifying an existing configuration.
*/
public static function configTransport($key, $config = null)
{
if ($config === null && is_string($key)) {
return static::getConfigTransport($key);
}
if ($config === null && is_array($key)) {
static::setConfigTransport($key);
return null;
}
static::setConfigTransport($key, $config);
}
/**
* Returns an array containing the named transport configurations
*

0 comments on commit c2bd06e

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