@@ 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 |