Refactor emails models objects, rework related tests

This commit is contained in:
ErickSkrauch
2019-06-16 23:59:19 +03:00
parent 1bf249030f
commit 70d1999d55
24 changed files with 522 additions and 196 deletions

View File

@@ -1,5 +1,6 @@
<?php
declare(strict_types=1);
namespace common\tasks;
use common\emails\EmailHelper;
@@ -34,11 +35,11 @@ class SendRegistrationEmail implements RetryableJobInterface {
return $result;
}
public function getTtr() {
public function getTtr(): int {
return 30;
}
public function canRetry($attempt, $error) {
public function canRetry($attempt, $error): bool {
return true;
}
@@ -48,10 +49,10 @@ class SendRegistrationEmail implements RetryableJobInterface {
*/
public function execute($queue) {
Yii::$app->statsd->inc('queue.sendRegistrationEmail.attempt');
$params = new RegistrationEmailParams($this->username, $this->code, $this->link);
$to = EmailHelper::buildTo($this->username, $this->email);
$template = new RegistrationEmail($to, $this->locale, $params, Yii::$app->emailsRenderer);
$template->send();
$template = new RegistrationEmail(Yii::$app->mailer, Yii::$app->emailsRenderer);
$template->setLocale($this->locale);
$template->setParams(new RegistrationEmailParams($this->username, $this->code, $this->link));
$template->send(EmailHelper::buildTo($this->username, $this->email));
}
}