Skip to content

Commit

Permalink
Merge pull request #953 from cakephp/fix-email-docs
Browse files Browse the repository at this point in the history
Update examples in code snippets
  • Loading branch information
othercorey authored Sep 3, 2023
2 parents a280c2c + c380dc9 commit e72d22a
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions templates/MailPreview/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ class UserMailer extends Mailer
{
public function welcome($user)
{
return $this // Returning the chain is a good idea :)
->to($user->email)
->subject(sprintf("Welcome %s", $user->name))
->template("welcome_mail") // By default template with same name as method name is used.
->layout("custom")
->set(["user" => $user]);
$mailer = $this->setTo($user->email)
->setSubject(sprintf("Welcome %s", $user->name))
->setViewVars(["user" => $user]);
$mailer->viewBuilder()
->setTemplate("welcome_mail") // By default template with same name as method name is used.
->setLayout("custom");
return $mailer;
}
}';
highlight_string($code);
Expand All @@ -75,9 +76,10 @@ public function welcome()
{
$this->loadModel("Users");
$user = $this->Users->find()->first();
return $this->getMailer("User")
->welcome($user)
->set(["activationToken" => "dummy-token"]);
->setViewVars(["activationToken" => "dummy-token"]);
}
}';
highlight_string($code);
Expand Down

0 comments on commit e72d22a

Please sign in to comment.