Skip to content

Commit

Permalink
Remove usage of deprecated methods in Mailer and Email class.
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark authored and dereuromark committed Jan 5, 2017
1 parent c2bd06e commit 5ba2c3a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
11 changes: 6 additions & 5 deletions src/Mailer/Email.php
Expand Up @@ -342,7 +342,7 @@ public function __construct($config = null)
$config = static::config('default');
}
if ($config) {
$this->profile($config);
$this->setProfile($config);
}
if (empty($this->headerCharset)) {
$this->headerCharset = $this->charset;
Expand Down Expand Up @@ -999,6 +999,7 @@ public function getSubject()
/**
* Get/Set Subject.
*
* @deprecated 3.4.0 Use setSubject()/getSubject() instead.
* @param string|null $subject Subject string.
* @return string|self
*/
Expand Down Expand Up @@ -2009,7 +2010,7 @@ public function send($content = null)

$this->_message = $this->_render($this->_wrap($content));

$transport = $this->transport();
$transport = $this->getTransport();
if (!$transport) {
$msg = 'Cannot send email, transport was not defined. Did you call transport() or define ' .
' a transport in the set profile?';
Expand Down Expand Up @@ -2070,13 +2071,13 @@ public static function deliver($to = null, $subject = null, $message = null, $tr
/* @var \Cake\Mailer\Email $instance */
$instance = new $class($transportConfig);
if ($to !== null) {
$instance->to($to);
$instance->setTo($to);
}
if ($subject !== null) {
$instance->subject($subject);
$instance->setSubject($subject);
}
if (is_array($message)) {
$instance->viewVars($message);
$instance->setViewVars($message);
$message = null;
} elseif ($message === null && array_key_exists('message', $config = $instance->profile())) {
$message = $config['message'];
Expand Down
7 changes: 4 additions & 3 deletions src/Mailer/Mailer.php
Expand Up @@ -33,8 +33,8 @@
* public function resetPassword($user)
* {
* $this
* ->subject('Reset Password')
* ->to($user->email)
* ->setSubject('Reset Password')
* ->setTo($user->email)
* ->set(['token' => $user->token]);
* }
* }
Expand Down Expand Up @@ -173,6 +173,7 @@ public function getName()
/**
* Sets layout to use.
*
* @deprecated 3.4.0 Use setLayout() which sets the layout on the email class instead.
* @param string $layout Name of the layout to use.
* @return self object.
*/
Expand Down Expand Up @@ -216,7 +217,7 @@ public function __call($method, $args)
*/
public function set($key, $value = null)
{
$this->_email->viewVars(is_string($key) ? [$key => $value] : $key);
$this->_email->setViewVars(is_string($key) ? [$key => $value] : $key);

return $this;
}
Expand Down

0 comments on commit 5ba2c3a

Please sign in to comment.