MailService::sendAdminOrderMail()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 36
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 25
nc 1
nop 2
dl 0
loc 36
rs 8.8571
c 0
b 0
f 0
ccs 0
cts 0
cp 0
crap 2
1
<?php
2
/*
3
 * This file is part of EC-CUBE
4
 *
5
 * Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved.
6
 *
7
 * http://www.lockon.co.jp/
8
 *
9
 * This program is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation; either version 2
12
 * of the License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
 */
23
24
namespace Eccube\Service;
25
26
use Eccube\Application;
27
use Eccube\Event\EccubeEvents;
28
use Eccube\Event\EventArgs;
29
30
class MailService
0 ignored issues
show
introduced by
Missing class doc comment
Loading history...
31
{
32
    /** @var \Eccube\Application */
33
    public $app;
34
35
36
    /** @var \Eccube\Entity\BaseInfo */
37 24
    public $BaseInfo;
0 ignored issues
show
Coding Style introduced by
Member variable "BaseInfo" is not in valid camel caps format
Loading history...
38
39 24
    public function __construct(Application $app)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
40
    {
41
        $this->app = $app;
42
        $this->BaseInfo = $app['eccube.repository.base_info']->get();
43
    }
44
45
46
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$Customer" missing
Loading history...
introduced by
Doc comment for parameter "$activateUrl" missing
Loading history...
47
     * Send customer confirm mail.
48
     *
49
     * @param $Customer 会員情報
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
50 2
     * @param $activateUrl アクティベート用url
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
51
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
52
    public function sendCustomerConfirmMail(\Eccube\Entity\Customer $Customer, $activateUrl)
53
    {
54
55 2
        log_info('仮会員登録メール送信開始');
56
57
        $body = $this->app->renderView('Mail/entry_confirm.twig', array(
58
            'Customer' => $Customer,
59 2
            'BaseInfo' => $this->BaseInfo,
60
            'activateUrl' => $activateUrl,
61
        ));
62
63
        $message = \Swift_Message::newInstance()
64
            ->setSubject('[' . $this->BaseInfo->getShopName() . '] 会員登録のご確認')
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
65
            ->setFrom(array($this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName()))
66
            ->setTo(array($Customer->getEmail()))
67
            ->setBcc($this->BaseInfo->getEmail01())
68
            ->setReplyTo($this->BaseInfo->getEmail03())
69
            ->setReturnPath($this->BaseInfo->getEmail04())
70
            ->setBody($body);
71
72
        $event = new EventArgs(
73
            array(
74
                'message' => $message,
75
                'Customer' => $Customer,
76 2
                'BaseInfo' => $this->BaseInfo,
77
                'activateUrl' => $activateUrl,
78
            ),
79
            null
80
        );
81 2
        $this->app['eccube.event.dispatcher']->dispatch(EccubeEvents::MAIL_CUSTOMER_CONFIRM, $event);
82
83
        $count = $this->app->mail($message, $failures);
84 2
85
        log_info('仮会員登録メール送信完了', array('count' => $count));
86
87
        return $count;
88
    }
89
90
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$Customer" missing
Loading history...
91
     * Send customer complete mail.
92
     *
93
     * @param $Customer 会員情報
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
94
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
95 View Code Duplication
    public function sendCustomerCompleteMail(\Eccube\Entity\Customer $Customer)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
96
    {
97
        log_info('会員登録完了メール送信開始');
98
99
        $body = $this->app->renderView('Mail/entry_complete.twig', array(
100
            'Customer' => $Customer,
101
            'BaseInfo' => $this->BaseInfo,
102
        ));
103
104
        $message = \Swift_Message::newInstance()
105 2
            ->setSubject('[' . $this->BaseInfo->getShopName() . '] 会員登録が完了しました。')
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
106
            ->setFrom(array($this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName()))
107
            ->setTo(array($Customer->getEmail()))
108
            ->setBcc($this->BaseInfo->getEmail01())
109
            ->setReplyTo($this->BaseInfo->getEmail03())
110 2
            ->setReturnPath($this->BaseInfo->getEmail04())
111
            ->setBody($body);
112
113 2
        $event = new EventArgs(
114
            array(
115
                'message' => $message,
116 2
                'Customer' => $Customer,
117
                'BaseInfo' => $this->BaseInfo,
118
            ),
119
            null
120
        );
121
        $this->app['eccube.event.dispatcher']->dispatch(EccubeEvents::MAIL_CUSTOMER_COMPLETE, $event);
122
123
        $count = $this->app->mail($message);
124
125
        log_info('会員登録完了メール送信完了', array('count' => $count));
126
127
        return $count;
128
    }
129
130
131
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$email" missing
Loading history...
introduced by
Doc comment for parameter "$Customer" missing
Loading history...
132 5
     * Send withdraw mail.
133
     *
134
     * @param $Customer 会員情報
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
135
     * @param $email 会員email
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
136
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
137 5 View Code Duplication
    public function sendCustomerWithdrawMail(\Eccube\Entity\Customer $Customer, $email)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
138
    {
139
        log_info('退会手続き完了メール送信開始');
140
141 5
        $body = $this->app->renderView('Mail/customer_withdraw_mail.twig', array(
142
            'Customer' => $Customer,
143
            'BaseInfo' => $this->BaseInfo,
144 5
        ));
145
146
        $message = \Swift_Message::newInstance()
147
            ->setSubject('[' . $this->BaseInfo->getShopName() . '] 退会手続きのご完了')
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
148
            ->setFrom(array($this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName()))
149
            ->setTo(array($email))
150
            ->setBcc($this->BaseInfo->getEmail01())
151
            ->setReplyTo($this->BaseInfo->getEmail03())
152 5
            ->setReturnPath($this->BaseInfo->getEmail04())
153
            ->setBody($body);
154
155
        $event = new EventArgs(
156
            array(
157
                'message' => $message,
158
                'Customer' => $Customer,
159
                'BaseInfo' => $this->BaseInfo,
160
                'email' => $email,
161
            ),
162 1
            null
163
        );
164
        $this->app['eccube.event.dispatcher']->dispatch(EccubeEvents::MAIL_CUSTOMER_WITHDRAW, $event);
165 1
166
        $count = $this->app->mail($message);
167
168
        log_info('退会手続き完了メール送信完了', array('count' => $count));
169
170
        return $count;
171
    }
172 5
173
174
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$formData" missing
Loading history...
175
     * Send contact mail.
176
     *
177
     * @param $formData お問い合わせ内容
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
178 5
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
179 5 View Code Duplication
    public function sendContactMail($formData)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
180
    {
181
        log_info('お問い合わせ受付メール送信開始');
182
183 5
        $body = $this->app->renderView('Mail/contact_mail.twig', array(
184
            'data' => $formData,
185
            'BaseInfo' => $this->BaseInfo,
186
        ));
187
188
        // 問い合わせ者にメール送信
189
        $message = \Swift_Message::newInstance()
190
            ->setSubject('[' . $this->BaseInfo->getShopName() . '] お問い合わせを受け付けました。')
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
191
            ->setFrom(array($this->BaseInfo->getEmail02() => $this->BaseInfo->getShopName()))
192
            ->setTo(array($formData['email']))
193
            ->setBcc($this->BaseInfo->getEmail02())
194
            ->setReplyTo($this->BaseInfo->getEmail02())
195
            ->setReturnPath($this->BaseInfo->getEmail04())
196
            ->setBody($body);
197
198
        $event = new EventArgs(
199
            array(
200
                'message' => $message,
201
                'formData' => $formData,
202
                'BaseInfo' => $this->BaseInfo,
203 2
            ),
204
            null
205
        );
206
        $this->app['eccube.event.dispatcher']->dispatch(EccubeEvents::MAIL_CONTACT, $event);
207
208
        $count = $this->app->mail($message);
209
210
        log_info('お問い合わせ受付メール送信完了', array('count' => $count));
211 2
212
        return $count;
213
    }
214
215
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$formData" missing
Loading history...
216
     * Alias of sendContactMail().
217
     *
218
     * @param $formData お問い合わせ内容
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
219
     * @see sendContactMail()
220
     * @deprecated since 3.0.0, to be removed in 3.1
221
     * @link https://github.com/EC-CUBE/ec-cube/issues/1315
222
     */
223
    public function sendrContactMail($formData)
224
    {
225
        $this->sendContactMail($formData);
226
    }
227
228
    /**
229
     * Send order mail.
230
     *
231 2
     * @param \Eccube\Entity\Order $Order 受注情報
232
     * @return string
233
     */
234
    public function sendOrderMail(\Eccube\Entity\Order $Order)
235 2
    {
236 2
        log_info('受注メール送信開始');
237
238
        $MailTemplate = $this->app['eccube.repository.mail_template']->find(1);
239
240 2
        $body = $this->app->renderView($MailTemplate->getFileName(), array(
241
            'header' => $MailTemplate->getHeader(),
242
            'footer' => $MailTemplate->getFooter(),
243
            'Order' => $Order,
244
        ));
245
246
        $message = \Swift_Message::newInstance()
247
            ->setSubject('[' . $this->BaseInfo->getShopName() . '] ' . $MailTemplate->getSubject())
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
248
            ->setFrom(array($this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName()))
249
            ->setTo(array($Order->getEmail()))
250
            ->setBcc($this->BaseInfo->getEmail01())
251
            ->setReplyTo($this->BaseInfo->getEmail03())
252
            ->setReturnPath($this->BaseInfo->getEmail04())
253
            ->setBody($body);
254
255
        $event = new EventArgs(
256
            array(
257
                'message' => $message,
258 2
                'Order' => $Order,
259
                'MailTemplate' => $MailTemplate,
260
                'BaseInfo' => $this->BaseInfo,
261
            ),
262
            null
263
        );
264
        $this->app['eccube.event.dispatcher']->dispatch(EccubeEvents::MAIL_ORDER, $event);
265 2
266
        $count = $this->app->mail($message);
267
268
        log_info('受注メール送信完了', array('count' => $count));
269
270
        return $message;
271
272
    }
273
274
275
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$activateUrl" missing
Loading history...
introduced by
Doc comment for parameter "$Customer" missing
Loading history...
276
     * Send admin customer confirm mail.
277
     *
278
     * @param $Customer 会員情報
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
279
     * @param $activateUrl アクティベート用url
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
280
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
281 View Code Duplication
    public function sendAdminCustomerConfirmMail(\Eccube\Entity\Customer $Customer, $activateUrl)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
282
    {
283 2
        log_info('仮会員登録再送メール送信開始');
284
285
        $body = $this->app->renderView('Mail/entry_confirm.twig', array(
286
            'Customer' => $Customer,
287
            'activateUrl' => $activateUrl,
288
        ));
289
290 2
        $message = \Swift_Message::newInstance()
291
            ->setSubject('[' . $this->BaseInfo->getShopName() . '] 会員登録のご確認')
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
292
            ->setFrom(array($this->BaseInfo->getEmail03() => $this->BaseInfo->getShopName()))
293
            ->setTo(array($Customer->getEmail()))
294
            ->setBcc($this->BaseInfo->getEmail01())
295
            ->setReplyTo($this->BaseInfo->getEmail03())
296
            ->setReturnPath($this->BaseInfo->getEmail04())
297
            ->setBody($body);
298
299
        $event = new EventArgs(
300
            array(
301
                'message' => $message,
302
                'Customer' => $Customer,
303
                'BaseInfo' => $this->BaseInfo,
304
                'activateUrl' => $activateUrl,
305
            ),
306
            null
307
        );
308
        $this->app['eccube.event.dispatcher']->dispatch(EccubeEvents::MAIL_ADMIN_CUSTOMER_CONFIRM, $event);
309
310
        $count = $this->app->mail($message);
311
312
        log_info('仮会員登録再送メール送信完了', array('count' => $count));
313
314
        return $count;
315
    }
316
317
318
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$Order" missing
Loading history...
introduced by
Doc comment for parameter "$formData" missing
Loading history...
319
     * Send admin order mail.
320
     *
321
     * @param $Order 受注情報
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
322
     * @param $formData 入力内容
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
323
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
324
    public function sendAdminOrderMail(\Eccube\Entity\Order $Order, $formData)
325
    {
326
        log_info('受注管理通知メール送信開始');
327
328
        $body = $this->app->renderView('Mail/order.twig', array(
329
            'header' => $formData['header'],
330
            'footer' => $formData['footer'],
331
            'Order' => $Order,
332
        ));
333
334
        $message = \Swift_Message::newInstance()
335
            ->setSubject('[' . $this->BaseInfo->getShopName() . '] ' . $formData['subject'])
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
336
            ->setFrom(array($this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName()))
337
            ->setTo(array($Order->getEmail()))
338
            ->setBcc($this->BaseInfo->getEmail01())
339
            ->setReplyTo($this->BaseInfo->getEmail03())
340
            ->setReturnPath($this->BaseInfo->getEmail04())
341
            ->setBody($body);
342
343
        $event = new EventArgs(
344
            array(
345
                'message' => $message,
346
                'Order' => $Order,
347
                'formData' => $formData,
348
                'BaseInfo' => $this->BaseInfo,
349
            ),
350
            null
351
        );
352
        $this->app['eccube.event.dispatcher']->dispatch(EccubeEvents::MAIL_ADMIN_ORDER, $event);
353
354
        $count = $this->app->mail($message);
355
356
        log_info('受注管理通知メール送信完了', array('count' => $count));
357
358
        return $message;
359
    }
360
361
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$reset_url" missing
Loading history...
introduced by
Doc comment for parameter "$Customer" missing
Loading history...
362
     * Send password reset notification mail.
363
     *
364
     * @param $Customer 会員情報
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
365
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
366
    public function sendPasswordResetNotificationMail(\Eccube\Entity\Customer $Customer, $reset_url)
367
    {
368
        log_info('パスワード再発行メール送信開始');
369
370
        $body = $this->app->renderView('Mail/forgot_mail.twig', array(
0 ignored issues
show
introduced by
Add a comma after each item in a multi-line array
Loading history...
371
            'Customer' => $Customer,
372
            'reset_url' => $reset_url
373
        ));
374
375
        $message = \Swift_Message::newInstance()
376
            ->setSubject('[' . $this->BaseInfo->getShopName() . '] パスワード変更のご確認')
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
377
            ->setFrom(array($this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName()))
378
            ->setTo(array($Customer->getEmail()))
379
            ->setReplyTo($this->BaseInfo->getEmail03())
380
            ->setReturnPath($this->BaseInfo->getEmail04())
381
            ->setBody($body);
382
383
        $event = new EventArgs(
384
            array(
385
                'message' => $message,
386
                'Customer' => $Customer,
387
                'BaseInfo' => $this->BaseInfo,
388
                'resetUrl' => $reset_url,
389
            ),
390
            null
391
        );
392
        $this->app['eccube.event.dispatcher']->dispatch(EccubeEvents::MAIL_PASSWORD_RESET, $event);
393
394
        $count = $this->app->mail($message);
395
396
        log_info('パスワード再発行メール送信完了', array('count' => $count));
397
398
        return $count;
399
    }
400
401
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$Customer" missing
Loading history...
introduced by
Doc comment for parameter "$password" missing
Loading history...
402
     * Send password reset notification mail.
403
     *
404
     * @param $Customer 会員情報
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
405
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
406 View Code Duplication
    public function sendPasswordResetCompleteMail(\Eccube\Entity\Customer $Customer, $password)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
407
    {
408
        log_info('パスワード変更完了メール送信開始');
409
410
        $body = $this->app->renderView('Mail/reset_complete_mail.twig', array(
411
            'Customer' => $Customer,
412
            'password' => $password,
413
        ));
414
415
        $message = \Swift_Message::newInstance()
416
            ->setSubject('[' . $this->BaseInfo->getShopName() . '] パスワード変更のお知らせ')
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
417
            ->setFrom(array($this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName()))
418
            ->setTo(array($Customer->getEmail()))
419
            ->setReplyTo($this->BaseInfo->getEmail03())
420
            ->setReturnPath($this->BaseInfo->getEmail04())
421
            ->setBody($body);
422
423
        $event = new EventArgs(
424
            array(
425
                'message' => $message,
426
                'Customer' => $Customer,
427
                'BaseInfo' => $this->BaseInfo,
428
                'password' => $password,
429
            ),
430
            null
431
        );
432
        $this->app['eccube.event.dispatcher']->dispatch(EccubeEvents::MAIL_PASSWORD_RESET_COMPLETE, $event);
433
434
        $count = $this->app->mail($message);
435
436
        log_info('パスワード変更完了メール送信完了', array('count' => $count));
437
438
        return $count;
439
    }
440
441
}
442