Failed Conditions
Pull Request — master (#1337)
by Kentaro
17:07
created

MailService::sendOrderMail()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1
Metric Value
dl 0
loc 23
rs 9.0857
ccs 4
cts 4
cp 1
cc 1
eloc 15
nc 1
nop 1
crap 1
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
28
class MailService
0 ignored issues
show
introduced by
Missing class doc comment
Loading history...
29
{
30
    /** @var \Eccube\Application */
31
    public $app;
32
33
34
    /** @var \Eccube\Entity\BaseInfo */
35
    public $BaseInfo;
0 ignored issues
show
Coding Style introduced by
Member variable "BaseInfo" is not in valid camel caps format
Loading history...
36
37 19
    public function __construct(Application $app)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
38
    {
39 19
        $this->app = $app;
40
        $this->BaseInfo = $app['eccube.repository.base_info']->get();
41
    }
42
43
44
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$Customer" missing
Loading history...
introduced by
Doc comment for parameter "$activateUrl" missing
Loading history...
45
     * Send customer confirm mail.
46
     *
47
     * @param $Customer 会員情報
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
48
     * @param $activateUrl アクティベート用url
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
49
     */
50 2 View Code Duplication
    public function sendCustomerConfirmMail(\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...
51
    {
52
53
        $body = $this->app->renderView('Mail/entry_confirm.twig', array(
54
            'Customer' => $Customer,
55 2
            'BaseInfo' => $this->BaseInfo,
56
            'activateUrl' => $activateUrl,
57
        ));
58
59 2
        $message = \Swift_Message::newInstance()
60
            ->setSubject('[' . $this->BaseInfo->getShopName() . '] 会員登録のご確認')
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
61
            ->setFrom(array($this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName()))
62
            ->setTo(array($Customer->getEmail()))
63
            ->setBcc($this->BaseInfo->getEmail01())
64
            ->setReplyTo($this->BaseInfo->getEmail03())
65
            ->setReturnPath($this->BaseInfo->getEmail04())
66
            ->setBody($body);
67
68
        $this->app->mail($message);
69
    }
70
71
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$Customer" missing
Loading history...
72
     * Send customer complete mail.
73
     *
74
     * @param $Customer 会員情報
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
75
     */
76 2 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...
77
    {
78
79
        $body = $this->app->renderView('Mail/entry_complete.twig', array(
80
            'Customer' => $Customer,
81 2
            'BaseInfo' => $this->BaseInfo,
82
        ));
83
84 2
        $message = \Swift_Message::newInstance()
85
            ->setSubject('[' . $this->BaseInfo->getShopName() . '] 会員登録が完了しました。')
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
86
            ->setFrom(array($this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName()))
87
            ->setTo(array($Customer->getEmail()))
88
            ->setBcc($this->BaseInfo->getEmail01())
89
            ->setReplyTo($this->BaseInfo->getEmail03())
90
            ->setReturnPath($this->BaseInfo->getEmail04())
91
            ->setBody($body);
92
93
        $this->app->mail($message);
94
95
    }
96
97
98
99
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$Customer" missing
Loading history...
introduced by
Doc comment for parameter "$email" missing
Loading history...
100
     * Send withdraw mail.
101
     *
102
     * @param $Customer 会員情報
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
103
     * @param $email 会員email
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
104
     */
105 1 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...
106
    {
107
108
        $body = $this->app->renderView('Mail/customer_withdraw_mail.twig', array(
109
            'Customer' => $Customer,
110 1
            'BaseInfo' => $this->BaseInfo,
111
        ));
112
113 1
        $message = \Swift_Message::newInstance()
114
            ->setSubject('[' . $this->BaseInfo->getShopName() . '] 退会手続きのご完了')
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
115
            ->setFrom(array($this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName()))
116 1
            ->setTo(array($email))
117
            ->setBcc($this->BaseInfo->getEmail01())
118
            ->setReplyTo($this->BaseInfo->getEmail03())
119
            ->setReturnPath($this->BaseInfo->getEmail04())
120
            ->setBody($body);
121
122
        $this->app->mail($message);
123
124
    }
125
126
127
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$formData" missing
Loading history...
128
     * Send contact mail.
129
     *
130
     * @param $formData お問い合わせ内容
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
131
     */
132 5
    public function sendContactMail($formData)
133
    {
134
135
        $body = $this->app->renderView('Mail/contact_mail.twig', array(
136
            'data' => $formData,
137 5
            'BaseInfo' => $this->BaseInfo,
138
        ));
139
140
        // 問い合わせ者にメール送信
141 5
        $message = \Swift_Message::newInstance()
142
            ->setSubject('[' . $this->BaseInfo->getShopName() . '] お問い合わせを受け付けました。')
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
143
            ->setFrom(array($this->BaseInfo->getEmail02() => $this->BaseInfo->getShopName()))
144 5
            ->setTo(array($formData['email']))
145
            ->setBcc($this->BaseInfo->getEmail02())
146
            ->setReplyTo($this->BaseInfo->getEmail02())
147
            ->setReturnPath($this->BaseInfo->getEmail04())
148
            ->setBody($body);
149
150
        $this->app->mail($message);
151
152 5
    }
153
154
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$formData" missing
Loading history...
155
     * Alias of sendContactMail().
156
     *
157
     * @param $formData お問い合わせ内容
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
158
     * @see sendContactMail()
159
     * @deprecated since 3.0.0, to be removed in 3.1
160
     * @link https://github.com/EC-CUBE/ec-cube/issues/1315
161
     */
162 1
    public function sendrContactMail($formData)
163
    {
164
        $this->sendContactMail($formData);
165 1
    }
166
167
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$Order" missing
Loading history...
168
     * Send order mail.
169
     *
170
     * @param $Order 受注情報
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
171
     */
172 5
    public function sendOrderMail(\Eccube\Entity\Order $Order)
173
    {
174
175
        $MailTemplate = $this->app['eccube.repository.mail_template']->find(1);
176
177
        $body = $this->app->renderView($MailTemplate->getFileName(), array(
178 5
            'header' => $MailTemplate->getHeader(),
179 5
            'footer' => $MailTemplate->getFooter(),
180
            'Order' => $Order,
181
        ));
182
183 5
        $message = \Swift_Message::newInstance()
184
            ->setSubject('[' . $this->BaseInfo->getShopName() . '] ' . $MailTemplate->getSubject())
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
185
            ->setFrom(array($this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName()))
186
            ->setTo(array($Order->getEmail()))
187
            ->setBcc($this->BaseInfo->getEmail01())
188
            ->setReplyTo($this->BaseInfo->getEmail03())
189
            ->setReturnPath($this->BaseInfo->getEmail04())
190
            ->setBody($body);
191
192
        $this->app->mail($message);
193
194
    }
195
196
197
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$activateUrl" missing
Loading history...
introduced by
Doc comment for parameter "$Customer" missing
Loading history...
198
     * Send admin customer confirm mail.
199
     *
200
     * @param $Customer 会員情報
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
201
     * @param $activateUrl アクティベート用url
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
202
     */
203 1 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...
204
    {
205
206
        $body = $this->app->renderView('Mail/entry_confirm.twig', array(
207
            'Customer' => $Customer,
208
            'activateUrl' => $activateUrl,
209
        ));
210
211 1
        $message = \Swift_Message::newInstance()
212
            ->setSubject('[' . $this->BaseInfo->getShopName() . '] 会員登録のご確認')
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
213
            ->setFrom(array($this->BaseInfo->getEmail03() => $this->BaseInfo->getShopName()))
214
            ->setTo(array($Customer->getEmail()))
215
            ->setBcc($this->BaseInfo->getEmail01())
216
            ->setReplyTo($this->BaseInfo->getEmail03())
217
            ->setReturnPath($this->BaseInfo->getEmail04())
218
            ->setBody($body);
219
220
        $this->app->mail($message);
221
222
    }
223
224
225
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$Order" missing
Loading history...
introduced by
Doc comment for parameter "$formData" missing
Loading history...
226
     * Send admin order mail.
227
     *
228
     * @param $Order 受注情報
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
229
     * @param $formData 入力内容
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
230
     */
231 1
    public function sendAdminOrderMail(\Eccube\Entity\Order $Order, $formData)
232
    {
233
234
        $body = $this->app->renderView('Mail/order.twig', array(
235 1
            'header' => $formData['header'],
236 1
            'footer' => $formData['footer'],
237
            'Order' => $Order,
238
        ));
239
240 1
        $message = \Swift_Message::newInstance()
241
            ->setSubject('[' . $this->BaseInfo->getShopName() . '] ' . $formData['subject'])
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
242
            ->setFrom(array($this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName()))
243
            ->setTo(array($Order->getEmail()))
244
            ->setBcc($this->BaseInfo->getEmail01())
245
            ->setReplyTo($this->BaseInfo->getEmail03())
246
            ->setReturnPath($this->BaseInfo->getEmail04())
247
            ->setBody($body);
248
249
        $this->app->mail($message);
250
251
    }
252
253
    /**
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...
254
     * Send password reset notification mail.
255
     *
256
     * @param $Customer 会員情報
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
257
     */
258 1 View Code Duplication
    public function sendPasswordResetNotificationMail(\Eccube\Entity\Customer $Customer, $reset_url)
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...
259
    {
260
        $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...
261
            'Customer' => $Customer,
262
            'reset_url' => $reset_url
263
        ));
264
265 1
        $message = \Swift_Message::newInstance()
266
            ->setSubject('[' . $this->BaseInfo->getShopName() . '] パスワード変更のご確認')
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
267
            ->setFrom(array($this->BaseInfo->getEmail01() => $this->BaseInfo->getShopName()))
268
            ->setTo(array($Customer->getEmail()))
269
            ->setBcc($this->BaseInfo->getEmail01())
270
            ->setReplyTo($this->BaseInfo->getEmail03())
271
            ->setReturnPath($this->BaseInfo->getEmail04())
272
            ->setBody($body);
273
274
        $this->app->mail($message);
275
276
    }
277
278
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$password" missing
Loading history...
introduced by
Doc comment for parameter "$Customer" missing
Loading history...
279
     * Send password reset notification mail.
280
     *
281
     * @param $Customer 会員情報
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
282
     */
283 1 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...
284
    {
285
        $body = $this->app->renderView('Mail/reset_complete_mail.twig', array(
286
            'Customer' => $Customer,
287
            'password' => $password,
288
        ));
289
290 1
        $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->getEmail01() => $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
        $this->app->mail($message);
300
301
    }
302
303
}
304