| @@ 173-218 (lines=46) @@ | ||
| 170 | * @param string $registrationCode |
|
| 171 | * @param RegistrationAuthorityCredentials[] $ras |
|
| 172 | */ |
|
| 173 | public function sendRegistrationEmailWithRas( |
|
| 174 | $locale, |
|
| 175 | $commonName, |
|
| 176 | $email, |
|
| 177 | $registrationCode, |
|
| 178 | array $ras |
|
| 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 | 'registration_code_with_ras', |
|
| 189 | $locale, |
|
| 190 | $this->fallbackLocale |
|
| 191 | ); |
|
| 192 | ||
| 193 | $parameters = [ |
|
| 194 | 'templateString' => $emailTemplate->htmlContent, |
|
| 195 | 'locale' => $locale, |
|
| 196 | 'commonName' => $commonName, |
|
| 197 | 'email' => $email, |
|
| 198 | 'registrationCode' => $registrationCode, |
|
| 199 | 'ras' => $ras, |
|
| 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 | $this->mailer->send($message); |
|
| 218 | } |
|
| 219 | ||
| 220 | /** |
|
| 221 | * @param string $locale |
|
| @@ 227-272 (lines=46) @@ | ||
| 224 | * @param string $registrationCode |
|
| 225 | * @param RaLocation[] $raLocations |
|
| 226 | */ |
|
| 227 | public function sendRegistrationEmailWithRaLocations( |
|
| 228 | $locale, |
|
| 229 | $commonName, |
|
| 230 | $email, |
|
| 231 | $registrationCode, |
|
| 232 | array $raLocations |
|
| 233 | ) { |
|
| 234 | $subject = $this->translator->trans( |
|
| 235 | 'ss.mail.registration_email.subject', |
|
| 236 | ['%commonName%' => $commonName], |
|
| 237 | 'messages', |
|
| 238 | $locale |
|
| 239 | ); |
|
| 240 | ||
| 241 | $emailTemplate = $this->emailTemplateService->findByName( |
|
| 242 | 'registration_code_with_ra_locations', |
|
| 243 | $locale, |
|
| 244 | $this->fallbackLocale |
|
| 245 | ); |
|
| 246 | ||
| 247 | $parameters = [ |
|
| 248 | 'templateString' => $emailTemplate->htmlContent, |
|
| 249 | 'locale' => $locale, |
|
| 250 | 'commonName' => $commonName, |
|
| 251 | 'email' => $email, |
|
| 252 | 'registrationCode' => $registrationCode, |
|
| 253 | 'raLocations' => $raLocations, |
|
| 254 | ]; |
|
| 255 | ||
| 256 | // Rendering file template instead of string |
|
| 257 | // (https://github.com/symfony/symfony/issues/10865#issuecomment-42438248) |
|
| 258 | $body = $this->templateEngine->render( |
|
| 259 | 'SurfnetStepupMiddlewareCommandHandlingBundle:SecondFactorMailService:email.html.twig', |
|
| 260 | $parameters |
|
| 261 | ); |
|
| 262 | ||
| 263 | /** @var Message $message */ |
|
| 264 | $message = $this->mailer->createMessage(); |
|
| 265 | $message |
|
| 266 | ->setFrom($this->sender->getEmail(), $this->sender->getName()) |
|
| 267 | ->addTo($email, $commonName) |
|
| 268 | ->setSubject($subject) |
|
| 269 | ->setBody($body, 'text/html', 'utf-8'); |
|
| 270 | ||
| 271 | $this->mailer->send($message); |
|
| 272 | } |
|
| 273 | ||
| 274 | /** |
|
| 275 | * @param Locale $locale |
|