mirror of
https://github.com/elyby/accounts.git
synced 2024-12-23 05:39:54 +05:30
Fixes ACCOUNTS-BQ. Don't use mailer in constructor
This commit is contained in:
parent
5ed6f0ce86
commit
c7d192d14e
@ -7,10 +7,9 @@ use common\emails\EmailHelper;
|
||||
use common\emails\templates\ChangeEmail;
|
||||
use common\models\confirmations\CurrentEmailConfirmation;
|
||||
use Yii;
|
||||
use yii\mail\MailerInterface;
|
||||
use yii\queue\RetryableJobInterface;
|
||||
|
||||
class SendCurrentEmailConfirmation implements RetryableJobInterface {
|
||||
final class SendCurrentEmailConfirmation implements RetryableJobInterface {
|
||||
|
||||
public mixed $email = null;
|
||||
|
||||
@ -18,11 +17,8 @@ class SendCurrentEmailConfirmation implements RetryableJobInterface {
|
||||
|
||||
public mixed $code = null;
|
||||
|
||||
public function __construct(public MailerInterface $mailer) {
|
||||
}
|
||||
|
||||
public static function createFromConfirmation(CurrentEmailConfirmation $confirmation): self {
|
||||
$result = new self(Yii::$app->mailer);
|
||||
$result = new self();
|
||||
$result->email = $confirmation->account->email;
|
||||
$result->username = $confirmation->account->username;
|
||||
$result->code = $confirmation->key;
|
||||
@ -44,7 +40,7 @@ class SendCurrentEmailConfirmation implements RetryableJobInterface {
|
||||
*/
|
||||
public function execute($queue): void {
|
||||
Yii::$app->statsd->inc('queue.sendCurrentEmailConfirmation.attempt');
|
||||
$template = new ChangeEmail($this->mailer);
|
||||
$template = new ChangeEmail(Yii::$app->mailer);
|
||||
$template->setKey($this->code);
|
||||
$template->send(EmailHelper::buildTo($this->username, $this->email));
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ use common\models\AccountQuery;
|
||||
use common\models\confirmations\CurrentEmailConfirmation;
|
||||
use common\tasks\SendCurrentEmailConfirmation;
|
||||
use common\tests\unit\TestCase;
|
||||
use Yii;
|
||||
use yii\queue\Queue;
|
||||
use yii\symfonymailer\Message;
|
||||
|
||||
@ -34,7 +33,7 @@ class SendCurrentEmailConfirmationTest extends TestCase {
|
||||
}
|
||||
|
||||
public function testExecute(): void {
|
||||
$task = new SendCurrentEmailConfirmation(Yii::$app->mailer);
|
||||
$task = new SendCurrentEmailConfirmation();
|
||||
$task->username = 'mock-username';
|
||||
$task->email = 'mock@ely.by';
|
||||
$task->code = 'GFEDCBA';
|
||||
|
Loading…
Reference in New Issue
Block a user