1 | <?php |
||
15 | class Confirmation extends ConfirmationAbstract |
||
16 | { |
||
17 | /** |
||
18 | * {@inheritdoc} |
||
19 | */ |
||
20 | protected function sendToken(ConfirmationSubjectInterface $subject, $token) |
||
21 | { |
||
22 | $email = $subject->getConfirmationChannel($this->options['channel_path']); |
||
23 | |||
24 | if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
||
25 | throw new NotFoundChannelException(); |
||
26 | } |
||
27 | |||
28 | $this->sender->send( |
||
29 | $this->options['token_send_template'], |
||
30 | array($email), |
||
31 | array('subject' => $subject, 'token' => $token) |
||
32 | ); |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * {@inheritdoc} |
||
37 | */ |
||
38 | public function verify(Request $request, $token) |
||
39 | { |
||
40 | $form = $this->createVerifyForm(); |
||
41 | /** @var VerificationInterface $data */ |
||
42 | $data = $form->getData(); |
||
43 | $data->setToken($token); |
||
44 | $form->submit($request->query->all()); |
||
45 | |||
46 | if (!$form->isValid()) { |
||
47 | return $form; |
||
48 | } |
||
49 | |||
50 | if (!$this->validateTimeAware($subject = $data->getSubject())) { |
||
51 | $form->addError(new FormError('ui.trans.user.confirmation.verify.invalid_time')); |
||
52 | } |
||
53 | |||
54 | if (!$form->getErrors(true)->count()) { |
||
55 | $this->successVerify($subject); |
||
56 | } |
||
57 | |||
58 | return $form; |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * {@inheritdoc} |
||
63 | */ |
||
64 | public function createVerifyForm() |
||
65 | { |
||
66 | return $this->formFactory->create( |
||
67 | $this->options['token_verify_form'], |
||
68 | $this->getVerifyModel(), |
||
69 | array('csrf_protection' => false) |
||
70 | ); |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * {@inheritdoc} |
||
75 | */ |
||
76 | public function getResendModel() |
||
80 | |||
81 | /** |
||
82 | * {@inheritdoc} |
||
83 | */ |
||
84 | public function getVerifyModel() |
||
88 | |||
89 | /** |
||
90 | * {@inheritdoc} |
||
91 | */ |
||
92 | public function getType() |
||
96 | |||
97 | /** |
||
98 | * {@inheritdoc} |
||
99 | */ |
||
100 | protected function configureOptions(OptionsResolver $resolver) |
||
109 | } |
||
110 |