Total Complexity | 5 |
Total Lines | 33 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
23 | final class PasswordResetEmailFactory extends AbstractUserEmailFactory |
||
24 | { |
||
25 | public const MESSAGE_ID_PREFIX = 'pre'; |
||
26 | |||
27 | public function create(AbstractUser $user, array $context = []): ?RawMessage |
||
28 | { |
||
29 | if (!$this->enabled) { |
||
30 | return null; |
||
31 | } |
||
32 | |||
33 | $this->initUser($user); |
||
34 | |||
35 | $token = $user->plainNewPasswordConfirmationToken; |
||
36 | $user->plainNewPasswordConfirmationToken = null; |
||
37 | if (!$token) { |
||
38 | throw new InvalidArgumentException('A new password confirmation token must be set to send the `password reset` email'); |
||
39 | } |
||
40 | |||
41 | $context['redirect_url'] = $this->getTokenUrl($token, $user->getUsername()); |
||
|
|||
42 | |||
43 | return $this->createEmailMessage($context); |
||
44 | } |
||
45 | |||
46 | protected static function getContextKeys(): ?array |
||
47 | { |
||
48 | return array_merge(parent::getContextKeys(), [ |
||
49 | 'redirect_url', |
||
50 | ]); |
||
51 | } |
||
52 | |||
53 | protected function getTemplate(): string |
||
56 | } |
||
57 | } |
||
58 |