From 51209552aef1900a54dab5396e4a4456a7400756 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Kr=C3=A4mer?= Date: Wed, 13 Apr 2016 01:35:20 +0200 Subject: [PATCH] Minor fixes and improvements to the email sending --- src/Mailer/UsersMailer.php | 10 ++++------ src/Model/Behavior/UserBehavior.php | 10 +++++----- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/Mailer/UsersMailer.php b/src/Mailer/UsersMailer.php index 903f0b2..a1b8b55 100644 --- a/src/Mailer/UsersMailer.php +++ b/src/Mailer/UsersMailer.php @@ -14,7 +14,7 @@ class UsersMailer extends Mailer { */ public function verificationEmail($user, array $options = []) { $defaults = [ - 'to' => empty($user->email) ? '' : $user->email, + 'to' => $user->email, 'subject' => __d('user_tools', 'Please verify your Email'), 'template' => 'Burzum/UserTools.Users/verification_email', ]; @@ -31,7 +31,7 @@ public function verificationEmail($user, array $options = []) { */ public function passwordResetToken($user, array $options = []) { $defaults = [ - 'to' => empty($user->email) ? '' : $user->email, + 'to' => $user->email, 'subject' => __d('user_tools', 'Your password reset'), 'template' => 'Burzum/UserTools.Users/password_reset' ]; @@ -48,7 +48,7 @@ public function passwordResetToken($user, array $options = []) { */ public function sendNewPasswordEmail($user, array $options = []) { $defaults = [ - 'to' => empty($user->email) ? '' : $user->email, + 'to' => $user->email, 'subject' => __d('user_tools', 'Your new password'), 'template' => 'Burzum/UserTools.Users/new_password' ]; @@ -64,9 +64,7 @@ public function sendNewPasswordEmail($user, array $options = []) { */ protected function _applyOptions($options) { foreach ($options as $method => $value) { - if (method_exists($this, $method)) { - $this->{$method}($value); - } + $this->{$method}($value); } } diff --git a/src/Model/Behavior/UserBehavior.php b/src/Model/Behavior/UserBehavior.php index 2d59d03..d83d73c 100644 --- a/src/Model/Behavior/UserBehavior.php +++ b/src/Model/Behavior/UserBehavior.php @@ -42,7 +42,7 @@ class UserBehavior extends Behavior { 'defaultValidation' => true, 'useUuid' => true, 'passwordHasher' => 'Default', - 'mailer' => 'Burzum/UserTools.Users', + 'mailer' => 'Burzum\UserTools\Mailer\UsersMailer', 'passwordMinLength' => 6, 'register' => [ 'defaultRole' => null, @@ -331,7 +331,7 @@ public function register(EntityInterface $entity, $options = []) { } if ($options['afterRegister'] === true) { - $entity = $this->_afterRegister($result, $options); + $this->_afterRegister($result, $options); } $event = new Event('User.afterRegister', $this, [ @@ -652,7 +652,7 @@ public function passwordHasher() { */ public function sendPasswordResetToken(EntityInterface $user, $options = []) { $options = Hash::merge($this->_config['sendPasswordResetToken'], $options); - $this->getMailer($this->config('mailer'))->send('passwordResetToken', $user, $options); + $this->getMailer($this->config('mailer'))->send('passwordResetToken', [$user, $options]); } /** @@ -664,7 +664,7 @@ public function sendPasswordResetToken(EntityInterface $user, $options = []) { */ public function sendNewPasswordEmail(EntityInterface $user, $options = []) { $options = Hash::merge($this->_config['sendNewPasswordEmail'], $options); - $this->getMailer($this->config('mailer'))->send('verificationEmail', $user, $options); + $this->getMailer($this->config('mailer'))->send('verificationEmail', [$user, $options]); } /** @@ -676,7 +676,7 @@ public function sendNewPasswordEmail(EntityInterface $user, $options = []) { */ public function sendVerificationEmail(EntityInterface $user, $options = []) { $options = Hash::merge($this->_config['sendVerificationEmail'], $options); - $this->getMailer($this->config('mailer'))->send('verificationEmail', $user, $options); + $this->getMailer($this->config('mailer'))->send('verificationEmail', [$user, $options]); } }