1. <?php
  2. namespace App\Controller;
  3.  
  4. class UsersController extends AppController
  5. {
  6. public function register()
  7. {
  8. $user = $this->Users->newEntity();
  9. if ($this->request->is('post')) {
  10. $user = $this->Users->patchEntity($user, $this->request->data());
  11. if ($this->Users->save($user)) {
  12. // 代わりに MailerComponent を使用する
  13. $this->loadComponent('Mailer')->getMailer('User')->send('welcome', [$user]);
  14. }
  15. }
  16. $this->set('user', $user);
  17. }
  18. }