| @@ 186-230 (lines=45) @@ | ||
| 183 | * @param string $registrationCode |
|
| 184 | * @param RegistrationAuthorityCredentials[] $ras |
|
| 185 | */ |
|
| 186 | public function sendRegistrationEmailWithRas( |
|
| 187 | $locale, |
|
| 188 | $commonName, |
|
| 189 | $email, |
|
| 190 | $registrationCode, |
|
| 191 | array $ras |
|
| 192 | ) { |
|
| 193 | $subject = $this->translator->trans( |
|
| 194 | 'ss.mail.registration_email.subject', |
|
| 195 | ['%commonName%' => $commonName], |
|
| 196 | null, |
|
| 197 | $locale |
|
| 198 | ); |
|
| 199 | ||
| 200 | $emailTemplate = $this->findEmailTemplate('registration_code_with_ras', $locale, $this->fallbackLocale); |
|
| 201 | if (!$emailTemplate) { |
|
| 202 | return; |
|
| 203 | } |
|
| 204 | ||
| 205 | $parameters = [ |
|
| 206 | 'templateString' => $emailTemplate->htmlContent, |
|
| 207 | 'locale' => $locale, |
|
| 208 | 'commonName' => $commonName, |
|
| 209 | 'email' => $email, |
|
| 210 | 'registrationCode' => $registrationCode, |
|
| 211 | 'ras' => $ras, |
|
| 212 | ]; |
|
| 213 | ||
| 214 | // Rendering file template instead of string |
|
| 215 | // (https://github.com/symfony/symfony/issues/10865#issuecomment-42438248) |
|
| 216 | $body = $this->templateEngine->render( |
|
| 217 | 'SurfnetStepupMiddlewareCommandHandlingBundle:SecondFactorMailService:email.html.twig', |
|
| 218 | $parameters |
|
| 219 | ); |
|
| 220 | ||
| 221 | /** @var Message $message */ |
|
| 222 | $message = $this->mailer->createMessage(); |
|
| 223 | $message |
|
| 224 | ->setFrom($this->sender->getEmail(), $this->sender->getName()) |
|
| 225 | ->addTo($email, $commonName) |
|
| 226 | ->setSubject($subject) |
|
| 227 | ->setBody($body, 'text/html', 'utf-8'); |
|
| 228 | ||
| 229 | $this->mailer->send($message); |
|
| 230 | } |
|
| 231 | ||
| 232 | /** |
|
| 233 | * @param string $locale |
|
| @@ 239-283 (lines=45) @@ | ||
| 236 | * @param string $registrationCode |
|
| 237 | * @param RaLocation[] $raLocations |
|
| 238 | */ |
|
| 239 | public function sendRegistrationEmailWithRaLocations( |
|
| 240 | $locale, |
|
| 241 | $commonName, |
|
| 242 | $email, |
|
| 243 | $registrationCode, |
|
| 244 | array $raLocations |
|
| 245 | ) { |
|
| 246 | $subject = $this->translator->trans( |
|
| 247 | 'ss.mail.registration_email.subject', |
|
| 248 | ['%commonName%' => $commonName], |
|
| 249 | null, |
|
| 250 | $locale |
|
| 251 | ); |
|
| 252 | ||
| 253 | $emailTemplate = $this->findEmailTemplate('registration_code_with_ra_locations', $locale, $this->fallbackLocale); |
|
| 254 | if (!$emailTemplate) { |
|
| 255 | return; |
|
| 256 | } |
|
| 257 | ||
| 258 | $parameters = [ |
|
| 259 | 'templateString' => $emailTemplate->htmlContent, |
|
| 260 | 'locale' => $locale, |
|
| 261 | 'commonName' => $commonName, |
|
| 262 | 'email' => $email, |
|
| 263 | 'registrationCode' => $registrationCode, |
|
| 264 | 'raLocations' => $raLocations, |
|
| 265 | ]; |
|
| 266 | ||
| 267 | // Rendering file template instead of string |
|
| 268 | // (https://github.com/symfony/symfony/issues/10865#issuecomment-42438248) |
|
| 269 | $body = $this->templateEngine->render( |
|
| 270 | 'SurfnetStepupMiddlewareCommandHandlingBundle:SecondFactorMailService:email.html.twig', |
|
| 271 | $parameters |
|
| 272 | ); |
|
| 273 | ||
| 274 | /** @var Message $message */ |
|
| 275 | $message = $this->mailer->createMessage(); |
|
| 276 | $message |
|
| 277 | ->setFrom($this->sender->getEmail(), $this->sender->getName()) |
|
| 278 | ->addTo($email, $commonName) |
|
| 279 | ->setSubject($subject) |
|
| 280 | ->setBody($body, 'text/html', 'utf-8'); |
|
| 281 | ||
| 282 | $this->mailer->send($message); |
|
| 283 | } |
|
| 284 | ||
| 285 | /** |
|
| 286 | * @param Locale $locale |
|