Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

Commit

Permalink
Minor fixes and improvements to the email sending
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Krämer committed Apr 12, 2016
1 parent fee870c commit 5120955
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
10 changes: 4 additions & 6 deletions src/Mailer/UsersMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
];
Expand All @@ -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'
];
Expand All @@ -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'
];
Expand All @@ -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);
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/Model/Behavior/UserBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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, [
Expand Down Expand Up @@ -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]);
}

/**
Expand All @@ -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]);
}

/**
Expand All @@ -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]);
}

}

0 comments on commit 5120955

Please sign in to comment.