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

@@ -3,20 +3,15 @@ declare(strict_types=1);
namespace common\emails\templates;
use common\components\EmailsRenderer\RendererInterface;
use common\emails\TemplateWithRenderer;
use yii\base\InvalidCallException;
class ForgotPasswordEmail extends TemplateWithRenderer {
private $params;
/**
* @inheritdoc
* @var ForgotPasswordParams|null
*/
public function __construct($to, string $locale, ForgotPasswordParams $params, RendererInterface $renderer) {
parent::__construct($to, $locale, $renderer);
$this->params = $params;
}
private $params;
public function getSubject(): string {
return 'Ely.by Account forgot password';
@@ -26,7 +21,15 @@ class ForgotPasswordEmail extends TemplateWithRenderer {
return 'forgotPassword';
}
public function setParams(ForgotPasswordParams $params): void {
$this->params = $params;
}
public function getParams(): array {
if ($this->params === null) {
throw new InvalidCallException('You need to set params first');
}
return [
'username' => $this->params->getUsername(),
'code' => $this->params->getCode(),