Code Duplication    Length = 38-39 lines in 4 locations

src/Eccube/Service/MailService.php 4 locations

@@ 159-196 (lines=38) @@
156
     *
157
     * @param $Customer 会員情報
158
     */
159
    public function sendCustomerCompleteMail(\Eccube\Entity\Customer $Customer)
160
    {
161
        log_info('会員登録完了メール送信開始');
162
163
        $MailTemplate = $this->mailTemplateRepository->find($this->eccubeConfig['eccube_entry_complete_mail_template_id']);
164
165
        $body = $this->twig->render($MailTemplate->getFileName(), [
166
            'header' => $MailTemplate->getMailHeader(),
167
            'footer' => $MailTemplate->getMailFooter(),
168
            'Customer' => $Customer,
169
            'BaseInfo' => $this->BaseInfo,
170
        ]);
171
172
        $message = (new \Swift_Message())
173
            ->setSubject('['.$this->BaseInfo->getShopName().'] '.$MailTemplate->getMailSubject())
174
            ->setFrom([$this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName()])
175
            ->setTo([$Customer->getEmail()])
176
            ->setBcc($this->BaseInfo->getEmail01())
177
            ->setReplyTo($this->BaseInfo->getEmail03())
178
            ->setReturnPath($this->BaseInfo->getEmail04())
179
            ->setBody($body);
180
181
        $event = new EventArgs(
182
            [
183
                'message' => $message,
184
                'Customer' => $Customer,
185
                'BaseInfo' => $this->BaseInfo,
186
            ],
187
            null
188
        );
189
        $this->eventDispatcher->dispatch(EccubeEvents::MAIL_CUSTOMER_COMPLETE, $event);
190
191
        $count = $this->mailer->send($message);
192
193
        log_info('会員登録完了メール送信完了', ['count' => $count]);
194
195
        return $count;
196
    }
197
198
    /**
199
     * Send withdraw mail.
@@ 204-242 (lines=39) @@
201
     * @param $Customer Customer
202
     * @param $email string
203
     */
204
    public function sendCustomerWithdrawMail(Customer $Customer, string $email)
205
    {
206
        log_info('退会手続き完了メール送信開始');
207
208
        $MailTemplate = $this->mailTemplateRepository->find($this->eccubeConfig['eccube_customer_withdraw_mail_template_id']);
209
210
        $body = $this->twig->render($MailTemplate->getFileName(), [
211
            'header' => $MailTemplate->getMailHeader(),
212
            'footer' => $MailTemplate->getMailFooter(),
213
            'Customer' => $Customer,
214
            'BaseInfo' => $this->BaseInfo,
215
        ]);
216
217
        $message = (new \Swift_Message())
218
            ->setSubject('['.$this->BaseInfo->getShopName().'] '.$MailTemplate->getMailSubject())
219
            ->setFrom([$this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName()])
220
            ->setTo([$email])
221
            ->setBcc($this->BaseInfo->getEmail01())
222
            ->setReplyTo($this->BaseInfo->getEmail03())
223
            ->setReturnPath($this->BaseInfo->getEmail04())
224
            ->setBody($body);
225
226
        $event = new EventArgs(
227
            [
228
                'message' => $message,
229
                'Customer' => $Customer,
230
                'BaseInfo' => $this->BaseInfo,
231
                'email' => $email,
232
            ],
233
            null
234
        );
235
        $this->eventDispatcher->dispatch(EccubeEvents::MAIL_CUSTOMER_WITHDRAW, $event);
236
237
        $count = $this->mailer->send($message);
238
239
        log_info('退会手続き完了メール送信完了', ['count' => $count]);
240
241
        return $count;
242
    }
243
244
    /**
245
     * Send contact mail.
@@ 249-287 (lines=39) @@
246
     *
247
     * @param $formData お問い合わせ内容
248
     */
249
    public function sendContactMail($formData)
250
    {
251
        log_info('お問い合わせ受付メール送信開始');
252
253
        $MailTemplate = $this->mailTemplateRepository->find($this->eccubeConfig['eccube_contact_mail_template_id']);
254
255
        $body = $this->twig->render($MailTemplate->getFileName(), [
256
            'header' => $MailTemplate->getMailHeader(),
257
            'footer' => $MailTemplate->getMailFooter(),
258
            'data' => $formData,
259
            'BaseInfo' => $this->BaseInfo,
260
        ]);
261
262
        // 問い合わせ者にメール送信
263
        $message = (new \Swift_Message())
264
            ->setSubject('['.$this->BaseInfo->getShopName().'] '.$MailTemplate->getMailSubject())
265
            ->setFrom([$this->BaseInfo->getEmail02() => $this->BaseInfo->getShopName()])
266
            ->setTo([$formData['email']])
267
            ->setBcc($this->BaseInfo->getEmail02())
268
            ->setReplyTo($this->BaseInfo->getEmail02())
269
            ->setReturnPath($this->BaseInfo->getEmail04())
270
            ->setBody($body);
271
272
        $event = new EventArgs(
273
            [
274
                'message' => $message,
275
                'formData' => $formData,
276
                'BaseInfo' => $this->BaseInfo,
277
            ],
278
            null
279
        );
280
        $this->eventDispatcher->dispatch(EccubeEvents::MAIL_CONTACT, $event);
281
282
        $count = $this->mailer->send($message);
283
284
        log_info('お問い合わせ受付メール送信完了', ['count' => $count]);
285
286
        return $count;
287
    }
288
289
    /**
290
     * Alias of sendContactMail().
@@ 310-347 (lines=38) @@
307
     *
308
     * @return string
309
     */
310
    public function sendOrderMail(\Eccube\Entity\Order $Order)
311
    {
312
        log_info('受注メール送信開始');
313
314
        $MailTemplate = $this->mailTemplateRepository->find($this->eccubeConfig['eccube_order_mail_template_id']);
315
316
        $body = $this->twig->render($MailTemplate->getFileName(), [
317
            'header' => $MailTemplate->getMailHeader(),
318
            'footer' => $MailTemplate->getMailFooter(),
319
            'Order' => $Order,
320
        ]);
321
322
        $message = (new \Swift_Message())
323
            ->setSubject('['.$this->BaseInfo->getShopName().'] '.$MailTemplate->getMailSubject())
324
            ->setFrom([$this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName()])
325
            ->setTo([$Order->getEmail()])
326
            ->setBcc($this->BaseInfo->getEmail01())
327
            ->setReplyTo($this->BaseInfo->getEmail03())
328
            ->setReturnPath($this->BaseInfo->getEmail04())
329
            ->setBody($body);
330
331
        $event = new EventArgs(
332
            [
333
                'message' => $message,
334
                'Order' => $Order,
335
                'MailTemplate' => $MailTemplate,
336
                'BaseInfo' => $this->BaseInfo,
337
            ],
338
            null
339
        );
340
        $this->eventDispatcher->dispatch(EccubeEvents::MAIL_ORDER, $event);
341
342
        $count = $this->mailer->send($message);
343
344
        log_info('受注メール送信完了', ['count' => $count]);
345
346
        return $message;
347
    }
348
349
    /**
350
     * Send admin customer confirm mail.