@@ 98-145 (lines=48) @@ | ||
95 | * @param DateTime $expirationDate |
|
96 | * @param RegistrationAuthorityCredentials[] $ras |
|
97 | */ |
|
98 | public function sendRegistrationEmailWithRas( |
|
99 | $locale, |
|
100 | $commonName, |
|
101 | $email, |
|
102 | $registrationCode, |
|
103 | DateTime $expirationDate, |
|
104 | array $ras |
|
105 | ) { |
|
106 | $subject = $this->translator->trans( |
|
107 | 'ss.mail.registration_email.subject', |
|
108 | ['%commonName%' => $commonName], |
|
109 | 'messages', |
|
110 | $locale |
|
111 | ); |
|
112 | ||
113 | $emailTemplate = $this->emailTemplateService->findByName( |
|
114 | 'registration_code_with_ras', |
|
115 | $locale, |
|
116 | $this->fallbackLocale |
|
117 | ); |
|
118 | ||
119 | $parameters = [ |
|
120 | 'templateString' => $emailTemplate->htmlContent, |
|
121 | 'locale' => $locale, |
|
122 | 'commonName' => $commonName, |
|
123 | 'email' => $email, |
|
124 | 'registrationCode' => $registrationCode, |
|
125 | 'expirationDate' => $expirationDate, |
|
126 | 'ras' => $ras, |
|
127 | ]; |
|
128 | ||
129 | // Rendering file template instead of string |
|
130 | // (https://github.com/symfony/symfony/issues/10865#issuecomment-42438248) |
|
131 | $body = $this->templateEngine->render( |
|
132 | 'SurfnetStepupMiddlewareCommandHandlingBundle:SecondFactorMailService:email.html.twig', |
|
133 | $parameters |
|
134 | ); |
|
135 | ||
136 | /** @var Message $message */ |
|
137 | $message = $this->mailer->createMessage(); |
|
138 | $message |
|
139 | ->setFrom($this->sender->getEmail(), $this->sender->getName()) |
|
140 | ->addTo($email, $commonName) |
|
141 | ->setSubject($subject) |
|
142 | ->setBody($body, 'text/html', 'utf-8'); |
|
143 | ||
144 | $this->mailer->send($message); |
|
145 | } |
|
146 | ||
147 | /** |
|
148 | * @param string $locale |
|
@@ 155-202 (lines=48) @@ | ||
152 | * @param DateTime $expirationDate |
|
153 | * @param RaLocation[] $raLocations |
|
154 | */ |
|
155 | public function sendRegistrationEmailWithRaLocations( |
|
156 | $locale, |
|
157 | $commonName, |
|
158 | $email, |
|
159 | $registrationCode, |
|
160 | DateTime $expirationDate, |
|
161 | array $raLocations |
|
162 | ) { |
|
163 | $subject = $this->translator->trans( |
|
164 | 'ss.mail.registration_email.subject', |
|
165 | ['%commonName%' => $commonName], |
|
166 | 'messages', |
|
167 | $locale |
|
168 | ); |
|
169 | ||
170 | $emailTemplate = $this->emailTemplateService->findByName( |
|
171 | 'registration_code_with_ra_locations', |
|
172 | $locale, |
|
173 | $this->fallbackLocale |
|
174 | ); |
|
175 | ||
176 | $parameters = [ |
|
177 | 'templateString' => $emailTemplate->htmlContent, |
|
178 | 'locale' => $locale, |
|
179 | 'commonName' => $commonName, |
|
180 | 'email' => $email, |
|
181 | 'registrationCode' => $registrationCode, |
|
182 | 'expirationDate' => $expirationDate, |
|
183 | 'raLocations' => $raLocations, |
|
184 | ]; |
|
185 | ||
186 | // Rendering file template instead of string |
|
187 | // (https://github.com/symfony/symfony/issues/10865#issuecomment-42438248) |
|
188 | $body = $this->templateEngine->render( |
|
189 | 'SurfnetStepupMiddlewareCommandHandlingBundle:SecondFactorMailService:email.html.twig', |
|
190 | $parameters |
|
191 | ); |
|
192 | ||
193 | /** @var Message $message */ |
|
194 | $message = $this->mailer->createMessage(); |
|
195 | $message |
|
196 | ->setFrom($this->sender->getEmail(), $this->sender->getName()) |
|
197 | ->addTo($email, $commonName) |
|
198 | ->setSubject($subject) |
|
199 | ->setBody($body, 'text/html', 'utf-8'); |
|
200 | ||
201 | $this->mailer->send($message); |
|
202 | } |
|
203 | } |
|
204 |
@@ 172-218 (lines=47) @@ | ||
169 | * @param $registrationCode |
|
170 | * @return int |
|
171 | */ |
|
172 | private function sendReminderWithInstitution( |
|
173 | $locale, |
|
174 | $commonName, |
|
175 | $email, |
|
176 | $requestedAt, |
|
177 | $registrationCode, |
|
178 | $raLocations |
|
179 | ) { |
|
180 | $subject = $this->translator->trans( |
|
181 | 'ss.mail.registration_email.subject', |
|
182 | ['%commonName%' => $commonName], |
|
183 | 'messages', |
|
184 | $locale |
|
185 | ); |
|
186 | ||
187 | $emailTemplate = $this->emailTemplateService->findByName( |
|
188 | 'second_factor_verification_reminder_with_ra_locations', |
|
189 | $locale, |
|
190 | $this->fallbackLocale |
|
191 | ); |
|
192 | ||
193 | $parameters = [ |
|
194 | 'templateString' => $emailTemplate->htmlContent, |
|
195 | 'locale' => $locale, |
|
196 | 'commonName' => $commonName, |
|
197 | 'expirationDate' => $requestedAt, |
|
198 | 'registrationCode' => $registrationCode, |
|
199 | 'raLocations' => $raLocations, |
|
200 | ]; |
|
201 | ||
202 | // Rendering file template instead of string |
|
203 | // (https://github.com/symfony/symfony/issues/10865#issuecomment-42438248) |
|
204 | $body = $this->templateEngine->render( |
|
205 | 'SurfnetStepupMiddlewareCommandHandlingBundle:SecondFactorMailService:email.html.twig', |
|
206 | $parameters |
|
207 | ); |
|
208 | ||
209 | /** @var Message $message */ |
|
210 | $message = $this->mailer->createMessage(); |
|
211 | $message |
|
212 | ->setFrom($this->sender->getEmail(), $this->sender->getName()) |
|
213 | ->addTo($email, $commonName) |
|
214 | ->setSubject($subject) |
|
215 | ->setBody($body, 'text/html', 'utf-8'); |
|
216 | ||
217 | return $this->mailer->send($message); |
|
218 | } |
|
219 | ||
220 | private function sendReminderWithRas( |
|
221 | $locale, |
|
@@ 220-266 (lines=47) @@ | ||
217 | return $this->mailer->send($message); |
|
218 | } |
|
219 | ||
220 | private function sendReminderWithRas( |
|
221 | $locale, |
|
222 | $commonName, |
|
223 | $email, |
|
224 | $requestedAt, |
|
225 | $registrationCode, |
|
226 | array $ras |
|
227 | ) { |
|
228 | $subject = $this->translator->trans( |
|
229 | 'ss.mail.registration_email.subject', |
|
230 | ['%commonName%' => $commonName], |
|
231 | 'messages', |
|
232 | $locale |
|
233 | ); |
|
234 | ||
235 | $emailTemplate = $this->emailTemplateService->findByName( |
|
236 | 'second_factor_verification_reminder_with_ras', |
|
237 | $locale, |
|
238 | $this->fallbackLocale |
|
239 | ); |
|
240 | ||
241 | $parameters = [ |
|
242 | 'templateString' => $emailTemplate->htmlContent, |
|
243 | 'locale' => $locale, |
|
244 | 'commonName' => $commonName, |
|
245 | 'expirationDate' => $requestedAt, |
|
246 | 'registrationCode' => $registrationCode, |
|
247 | 'ras' => $ras, |
|
248 | ]; |
|
249 | ||
250 | // Rendering file template instead of string |
|
251 | // (https://github.com/symfony/symfony/issues/10865#issuecomment-42438248) |
|
252 | $body = $this->templateEngine->render( |
|
253 | 'SurfnetStepupMiddlewareCommandHandlingBundle:SecondFactorMailService:email.html.twig', |
|
254 | $parameters |
|
255 | ); |
|
256 | ||
257 | /** @var Message $message */ |
|
258 | $message = $this->mailer->createMessage(); |
|
259 | $message |
|
260 | ->setFrom($this->sender->getEmail(), $this->sender->getName()) |
|
261 | ->addTo($email, $commonName) |
|
262 | ->setSubject($subject) |
|
263 | ->setBody($body, 'text/html', 'utf-8'); |
|
264 | ||
265 | return $this->mailer->send($message); |
|
266 | } |
|
267 | } |
|
268 |