Failed Conditions
Pull Request — master (#1340)
by Tsuyoshi
26:29 queued 06:42
created

ShoppingController::confirm()   D

Complexity

Conditions 9
Paths 20

Size

Total Lines 102
Code Lines 57

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 9

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 102
ccs 10
cts 10
cp 1
rs 4.8197
cc 9
eloc 57
nc 20
nop 2
crap 9

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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
25
namespace Eccube\Controller;
26
27
use Eccube\Application;
28
use Eccube\Common\Constant;
29
use Eccube\Entity\Customer;
30
use Eccube\Entity\CustomerAddress;
31
use Eccube\Entity\ShipmentItem;
32
use Eccube\Entity\Shipping;
33
use Eccube\Entity\MailHistory;
34
use Eccube\Exception\CartException;
35
use Symfony\Component\HttpFoundation\Request;
36
use Symfony\Component\HttpFoundation\Response;
37
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
38
use Symfony\Component\Validator\Constraints as Assert;
39
40
class ShoppingController extends AbstractController
0 ignored issues
show
introduced by
Missing class doc comment
Loading history...
41
{
42
43
    /**
44
     * @var string 非会員用セッションキー
45
     */
46
    private $sessionKey = 'eccube.front.shopping.nonmember';
47
48
    /**
49
     * @var string 非会員用セッションキー
50
     */
51
    private $sessionCustomerAddressKey = 'eccube.front.shopping.nonmember.customeraddress';
52
53
    /**
54
     * @var string 複数配送警告メッセージ
55
     */
56
    private $sessionMultipleKey = 'eccube.front.shopping.multiple';
57
58
    /**
59
     * @var string 受注IDキー
60
     */
61
    private $sessionOrderKey = 'eccube.front.shopping.order.id';
62
63
    /**
64
     * 購入画面表示
65
     *
66
     * @param Application $app
67
     * @param Request $request
0 ignored issues
show
introduced by
Expected 5 spaces after parameter type; 1 found
Loading history...
68
     * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
69
     */
70 19
    public function index(Application $app, Request $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
71
    {
72
        $cartService = $app['eccube.service.cart'];
73
74
        // カートチェック
75
        if (!$cartService->isLocked()) {
76
            // カートが存在しない、カートがロックされていない時はエラー
77
            return $app->redirect($app->url('cart'));
78
        }
79
80
        // カートチェック
81
        if (count($cartService->getCart()->getCartItems()) <= 0) {
82
            // カートが存在しない時はエラー
83
            return $app->redirect($app->url('cart'));
84
        }
85
86
        // 登録済みの受注情報を取得
87
        $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']);
88
89
        // 初回アクセス(受注情報がない)の場合は, 受注情報を作成
90
        if (is_null($Order)) {
91
            // 未ログインの場合, ログイン画面へリダイレクト.
92
            if (!$app->isGranted('IS_AUTHENTICATED_FULLY')) {
93
                // 非会員でも一度会員登録されていればショッピング画面へ遷移
94
                $Customer = $app['eccube.service.shopping']->getNonMember($this->sessionKey);
95
96
                if (is_null($Customer)) {
97
                    return $app->redirect($app->url('shopping_login'));
98
                }
99
            } else {
100
                $Customer = $app->user();
101 7
            }
102
103
            try {
104
                // 受注情報を作成
105
                $Order = $app['eccube.service.shopping']->createOrder($Customer);
106
            } catch (CartException $e) {
107
                $app->addRequestError($e->getMessage());
108
                return $app->redirect($app->url('cart'));
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
109 16
            }
110
111
            // セッション情報を削除
112
            $app['session']->remove($this->sessionOrderKey);
113
            $app['session']->remove($this->sessionMultipleKey);
114
        } else {
115
            // 計算処理
116
            $Order = $app['eccube.service.shopping']->getAmount($Order);
117 16
        }
118
119
        // 受注関連情報を最新状態に更新
120
        $app['orm.em']->refresh($Order);
121
122
        // form作成
123
        $form = $app['eccube.service.shopping']->getShippingForm($Order);
124
125
        // 複数配送の場合、エラーメッセージを一度だけ表示
126
        if (!$app['session']->has($this->sessionMultipleKey)) {
127
            if (count($Order->getShippings()) > 1) {
128
                $app->addRequestError('shopping.multiple.delivery');
129
            }
130
            $app['session']->set($this->sessionMultipleKey, 'multiple');
131
        }
132
133 16
        return $app->render('Shopping/index.twig', array(
134 16
            'form' => $form->createView(),
135
            'Order' => $Order,
136
        ));
137 19
    }
138
139
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$app" missing
Loading history...
introduced by
Doc comment for parameter "$request" missing
Loading history...
140
     * 購入処理
141
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
142 4
    public function confirm(Application $app, Request $request)
143
    {
144
        $cartService = $app['eccube.service.cart'];
145
146
        // カートチェック
147
        if (!$cartService->isLocked()) {
148
            // カートが存在しない、カートがロックされていない時はエラー
149
            return $app->redirect($app->url('cart'));
150
        }
151
152
        $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']);
153 4
        if (!$Order) {
154
            $app->addError('front.shopping.order.error');
155
            return $app->redirect($app->url('shopping_error'));
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
156
        }
157
158
        if ('POST' !== $request->getMethod()) {
159
            return $app->redirect($app->url('cart'));
160
        }
161
162
        // form作成
163
        $form = $app['eccube.service.shopping']->getShippingForm($Order);
164
        $form->handleRequest($request);
165
166
        if ($form->isSubmitted() && $form->isValid()) {
167
            $data = $form->getData();
168
169
            // トランザクション制御
170
            $em = $app['orm.em'];
171
            $em->getConnection()->beginTransaction();
172
            try {
173
                // 商品公開ステータスチェック、商品制限数チェック、在庫チェック
174
                $check = $app['eccube.service.shopping']->isOrderProduct($em, $Order);
175 4
                if (!$check) {
176
                    $em->getConnection()->rollback();
177
                    $em->close();
178
179
                    $app->addError('front.shopping.stock.error');
180
                    return $app->redirect($app->url('shopping_error'));
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
181
                }
182
183
                // 受注情報、配送情報を更新
184
                $app['eccube.service.shopping']->setOrderUpdate($Order, $data);
185
                // 在庫情報を更新
186
                $app['eccube.service.shopping']->setStockUpdate($em, $Order);
187
188
                if ($app->isGranted('ROLE_USER')) {
189
                    // 会員の場合、購入金額を更新
190
                    $app['eccube.service.shopping']->setCustomerUpdate($Order, $app->user());
191
                }
192
193
                $em->getConnection()->commit();
194
                $em->flush();
195
            } catch (\Exception $e) {
196
                $em->getConnection()->rollback();
197
                $em->close();
198
199
                $app->log($e);
200
201
                $app->addError('front.shopping.system.error');
202
                return $app->redirect($app->url('shopping_error'));
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
203 4
            }
204
205
            // カート削除
206
            $app['eccube.service.cart']->clear()->save();
207
208
            // メール送信
209
            $app['eccube.service.mail']->sendOrderMail($Order);
210
211
            // 受注IDをセッションにセット
212
            $app['session']->set($this->sessionOrderKey, $Order->getId());
213
214
            // 送信履歴を保存.
215
            $MailTemplate = $app['eccube.repository.mail_template']->find(1);
216
217 4
            $body = $app->renderView($MailTemplate->getFileName(), array(
218 4
                'header' => $MailTemplate->getHeader(),
219 4
                'footer' => $MailTemplate->getFooter(),
220
                'Order' => $Order,
221
            ));
222
223
            $MailHistory = new MailHistory();
224
            $MailHistory
225
                ->setSubject('[' . $app['eccube.repository.base_info']->get()->getShopName() . '] ' . $MailTemplate->getSubject())
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
226 4
                ->setMailBody($body)
227 4
                ->setMailTemplate($MailTemplate)
228
                ->setSendDate(new \DateTime())
229
                ->setOrder($Order);
230
            $app['orm.em']->persist($MailHistory);
231
            $app['orm.em']->flush($MailHistory);
232
233
            $em->close();
234
235
            // 完了画面表示
236
            return $app->redirect($app->url('shopping_complete'));
237
        }
238
239
        return $app->render('Shopping/index.twig', array(
240
            'form' => $form->createView(),
241
            'Order' => $Order,
242
        ));
243 4
    }
244
245
246
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$app" missing
Loading history...
247
     * 購入完了画面表示
248
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
249 1
    public function complete(Application $app)
250
    {
251
        // 受注IDを取得
252
        $orderId = $app['session']->get($this->sessionOrderKey);
253
254
        // 受注IDセッションを削除
255
        $app['session']->remove($this->sessionOrderKey);
256
257 1
        return $app->render('Shopping/complete.twig', array(
258
            'orderId' => $orderId,
259
        ));
260 1
    }
261
262
263
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$app" missing
Loading history...
introduced by
Doc comment for parameter "$request" missing
Loading history...
264
     * 配送業者選択処理
265
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
266 3
    public function delivery(Application $app, Request $request)
267
    {
268
        // カートチェック
269
        if (!$app['eccube.service.cart']->isLocked()) {
270
            // カートが存在しない、カートがロックされていない時はエラー
271
            return $app->redirect($app->url('cart'));
272
        }
273
274
        $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']);
275 3
        if (!$Order) {
276
            $app->addError('front.shopping.order.error');
277
            return $app->redirect($app->url('shopping_error'));
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
278
        }
279
280
        if ('POST' !== $request->getMethod()) {
281
            return $app->redirect($app->url('shopping'));
282
        }
283
284
        $form = $app['eccube.service.shopping']->getShippingForm($Order);
285
        $form->handleRequest($request);
286
287
        if ($form->isSubmitted() && $form->isValid()) {
288
            $data = $form->getData();
289
290 1
            $shippings = $data['shippings'];
291
292 1
            $productDeliveryFeeTotal = 0;
293
            $BaseInfo = $app['eccube.repository.base_info']->get();
294
295
            foreach ($shippings as $Shipping) {
296
                $Delivery = $Shipping->getDelivery();
297
298 1
                if ($Delivery) {
299
                    $deliveryFee = $app['eccube.repository.delivery_fee']->findOneBy(array(
0 ignored issues
show
introduced by
Add a comma after each item in a multi-line array
Loading history...
300
                        'Delivery' => $Delivery,
301 1
                        'Pref' => $Shipping->getPref()
302
                    ));
303
304
                    // 商品ごとの配送料合計
305
                    if (!is_null($BaseInfo->getOptionProductDeliveryFee())) {
306
                        $productDeliveryFeeTotal += $app['eccube.service.shopping']->getProductDeliveryFee($Shipping);
307
                    }
308
309
                    $Shipping->setDeliveryFee($deliveryFee);
310
                    $Shipping->setShippingDeliveryFee($deliveryFee->getFee() + $productDeliveryFeeTotal);
311
                    $Shipping->setShippingDeliveryName($Delivery->getName());
312
                }
313
            }
314
315
            // 支払い情報をセット
316 1
            $payment = $data['payment'];
317 1
            $message = $data['message'];
318
319
            $Order->setPayment($payment);
320
            $Order->setPaymentMethod($payment->getMethod());
321
            $Order->setMessage($message);
322
            $Order->setCharge($payment->getCharge());
323
324
            $Order->setDeliveryFeeTotal($app['eccube.service.shopping']->getShippingDeliveryFeeTotal($shippings));
325
326
            $total = $Order->getSubTotal() + $Order->getCharge() + $Order->getDeliveryFeeTotal();
327
328
            $Order->setTotal($total);
329
            $Order->setPaymentTotal($total);
330
331
            // 受注関連情報を最新状態に更新
332
            $app['orm.em']->flush();
333
334
            return $app->redirect($app->url('shopping'));
335
        }
336
337 2
        return $app->render('Shopping/index.twig', array(
338 2
            'form' => $form->createView(),
339
            'Order' => $Order,
340
        ));
341 3
    }
342
343
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$app" missing
Loading history...
introduced by
Doc comment for parameter "$request" missing
Loading history...
344
     * 支払い方法選択処理
345
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
346 2
    public function payment(Application $app, Request $request)
347
    {
348
        $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']);
349 2
        if (!$Order) {
350
            $app->addError('front.shopping.order.error');
351
            return $app->redirect($app->url('shopping_error'));
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
352
        }
353
354
        if ('POST' !== $request->getMethod()) {
355
            return $app->redirect($app->url('shopping'));
356
        }
357
358
        $form = $app['eccube.service.shopping']->getShippingForm($Order);
359
        $form->handleRequest($request);
360
361
        if ($form->isSubmitted() && $form->isValid()) {
362
            $data = $form->getData();
363 1
            $payment = $data['payment'];
364 1
            $message = $data['message'];
365
366
            $Order->setPayment($payment);
367
            $Order->setPaymentMethod($payment->getMethod());
368
            $Order->setMessage($message);
369
            $Order->setCharge($payment->getCharge());
370
371
            $total = $Order->getSubTotal() + $Order->getCharge() + $Order->getDeliveryFeeTotal();
372
373
            $Order->setTotal($total);
374
            $Order->setPaymentTotal($total);
375
376
            // 受注関連情報を最新状態に更新
377
            $app['orm.em']->flush();
378
379
            return $app->redirect($app->url('shopping'));
380
        }
381
382 1
        return $app->render('Shopping/index.twig', array(
383 1
            'form' => $form->createView(),
384
            'Order' => $Order,
385
        ));
386 2
    }
387
388
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$app" missing
Loading history...
introduced by
Doc comment for parameter "$request" missing
Loading history...
introduced by
Doc comment for parameter "$id" missing
Loading history...
389
     * お届け先変更がクリックされた場合の処理
390
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
391 3 View Code Duplication
    public function shippingChange(Application $app, Request $request, $id)
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...
392
    {
393
        $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']);
394 3
        if (!$Order) {
395
            $app->addError('front.shopping.order.error');
396
            return $app->redirect($app->url('shopping_error'));
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
397
        }
398
399
        if ('POST' !== $request->getMethod()) {
400
            return $app->redirect($app->url('shopping'));
401
        }
402
403
        $form = $app['eccube.service.shopping']->getShippingForm($Order);
404
        $form->handleRequest($request);
405
406
        if ($form->isSubmitted() && $form->isValid()) {
407
            $data = $form->getData();
408 3
            $message = $data['message'];
409
            $Order->setMessage($message);
410
            // 受注情報を更新
411
            $app['orm.em']->flush();
412
413
            // お届け先設定一覧へリダイレクト
414
            return $app->redirect($app->url('shopping_shipping', array('id' => $id)));
415
        }
416
417
        return $app->render('Shopping/index.twig', array(
418
            'form' => $form->createView(),
419
            'Order' => $Order,
420
        ));
421 3
    }
422
423
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$app" missing
Loading history...
introduced by
Doc comment for parameter "$request" missing
Loading history...
introduced by
Doc comment for parameter "$id" missing
Loading history...
424
     * お届け先の設定一覧からの選択
425
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
426 2
    public function shipping(Application $app, Request $request, $id)
427
    {
428
        // カートチェック
429
        if (!$app['eccube.service.cart']->isLocked()) {
430
            // カートが存在しない、カートがロックされていない時はエラー
431
            return $app->redirect($app->url('cart'));
432
        }
433
434
        if ('POST' === $request->getMethod()) {
435
            $address = $request->get('address');
436
437
            if (is_null($address)) {
438
                // 選択されていなければエラー
439
                return $app->render(
440
                    'Shopping/shipping.twig',
441
                    array(
442
                        'Customer' => $app->user(),
443
                        'shippingId' => $id,
444
                        'error' => true,
445
                    )
446
                );
447
            }
448
449
            // 選択されたお届け先情報を取得
450
            $CustomerAddress = $app['eccube.repository.customer_address']->findOneBy(array(
451
                'Customer' => $app->user(),
452
                'id' => $address,
453
            ));
454
            if (is_null($CustomerAddress)) {
455
                throw new NotFoundHttpException();
456
            }
457
458
            $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']);
459
            if (!$Order) {
460
                $app->addError('front.shopping.order.error');
461
462
                return $app->redirect($app->url('shopping_error'));
463
            }
464
465
            $Shipping = $Order->findShipping($id);
466
            if (!$Shipping) {
467
                throw new NotFoundHttpException();
468
            }
469
470
            // お届け先情報を更新
471
            $Shipping
472
                ->setFromCustomerAddress($CustomerAddress);
473
474
            // 配送料金の設定
475
            $app['eccube.service.shopping']->setShippingDeliveryFee($Shipping);
476
477
            // 配送先を更新
478
            $app['orm.em']->flush();
479
480
            return $app->redirect($app->url('shopping'));
481
        }
482
483
        return $app->render(
484 2
            'Shopping/shipping.twig',
485
            array(
486 2
                'Customer' => $app->user(),
487
                'shippingId' => $id,
488 2
                'error' => false,
489
            )
490
        );
491 2
    }
492
493
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$app" missing
Loading history...
introduced by
Doc comment for parameter "$request" missing
Loading history...
introduced by
Doc comment for parameter "$id" missing
Loading history...
494
     * お届け先の設定(非会員)がクリックされた場合の処理
495
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
496 5 View Code Duplication
    public function shippingEditChange(Application $app, Request $request, $id)
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...
497
    {
498
        $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']);
499 5
        if (!$Order) {
500
            $app->addError('front.shopping.order.error');
501
            return $app->redirect($app->url('shopping_error'));
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
502
        }
503
504
        if ('POST' !== $request->getMethod()) {
505
            return $app->redirect($app->url('shopping'));
506
        }
507
508
        $form = $app['eccube.service.shopping']->getShippingForm($Order);
509
        $form->handleRequest($request);
510
511
        if ($form->isSubmitted() && $form->isValid()) {
512
            $data = $form->getData();
513 3
            $message = $data['message'];
514
            $Order->setMessage($message);
515
            // 受注情報を更新
516
            $app['orm.em']->flush();
517
518
            // お届け先設定一覧へリダイレクト
519
            return $app->redirect($app->url('shopping_shipping_edit', array('id' => $id)));
520
        }
521
522 1
        return $app->render('Shopping/index.twig', array(
523 1
            'form' => $form->createView(),
524
            'Order' => $Order,
525
        ));
526 5
    }
527
528
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$app" missing
Loading history...
introduced by
Doc comment for parameter "$request" missing
Loading history...
introduced by
Doc comment for parameter "$id" missing
Loading history...
529
     * お届け先の設定(非会員でも使用する)
530
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
531 2
    public function shippingEdit(Application $app, Request $request, $id)
532
    {
533
        // 配送先住所最大値判定
534
        $Customer = $app->user();
535 View Code Duplication
        if ($app->isGranted('IS_AUTHENTICATED_FULLY')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
536
            $addressCurrNum = count($app->user()->getCustomerAddresses());
537
            $addressMax = $app['config']['deliv_addr_max'];
538
            if ($addressCurrNum >= $addressMax) {
539
                throw new NotFoundHttpException();
540
            }
541
        }
542
543
        // カートチェック
544
        if (!$app['eccube.service.cart']->isLocked()) {
545
            // カートが存在しない、カートがロックされていない時はエラー
546
            return $app->redirect($app->url('cart'));
547
        }
548
549
        $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']);
550 2
        if (!$Order) {
551
            $app->addError('front.shopping.order.error');
552
            return $app->redirect($app->url('shopping_error'));
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
553
        }
554
555
        $Shipping = $Order->findShipping($id);
556 2
        if (!$Shipping) {
557
            throw new NotFoundHttpException();
558
        }
559
        if ($app->isGranted('IS_AUTHENTICATED_FULLY')) {
560
            $Shipping->clearCustomerAddress();
561
        }
562
563
        $CustomerAddress = new CustomerAddress();
564
        if ($app->isGranted('IS_AUTHENTICATED_FULLY')) {
565
            $CustomerAddress->setCustomer($Customer);
566
        } else {
567
            $CustomerAddress->setFromShipping($Shipping);
568
        }
569
570
        $builder = $app['form.factory']->createBuilder('shopping_shipping', $CustomerAddress);
571
        $form = $builder->getForm();
572
        $form->handleRequest($request);
573
574
        if ($form->isSubmitted() && $form->isValid()) {
575
            // 会員の場合、お届け先情報を新規登録
576
            $Shipping->setFromCustomerAddress($CustomerAddress);
577
578 2
            if ($Customer instanceof Customer) {
0 ignored issues
show
Bug introduced by
The class Eccube\Entity\Customer does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
579
                $app['orm.em']->persist($CustomerAddress);
580
            }
581
582
            // 配送料金の設定
583
            $app['eccube.service.shopping']->setShippingDeliveryFee($Shipping);
584
585
            // 配送先を更新 
586
           $app['orm.em']->flush();
0 ignored issues
show
Coding Style introduced by
It seems like the identation of this line is off (expected at least 12 spaces, but found 11).
Loading history...
587
588
            return $app->redirect($app->url('shopping'));
589
        }
590
591 2
        return $app->render('Shopping/shipping_edit.twig', array(
592 2
            'form' => $form->createView(),
593
            'shippingId' => $id,
594
        ));
595 2
    }
596
597
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$app" missing
Loading history...
introduced by
Doc comment for parameter "$request" missing
Loading history...
598
     * お客様情報の変更(非会員)
599
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
600
    public function customer(Application $app, Request $request)
601
    {
602
        if ($request->isXmlHttpRequest()) {
603
            try {
604
                $data = $request->request->all();
605
606
                // 入力チェック
607
                $errors = $this->customerValidation($app, $data);
608
609
                foreach ($errors as $error) {
610 View Code Duplication
                    if ($error->count() != 0) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
611
                        $response = new Response(json_encode('NG'), 500);
612
                        $response->headers->set('Content-Type', 'application/json');
613
                        return $response;
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
614
                    }
615
                }
616
617
                $pref = $app['eccube.repository.master.pref']->findOneBy(array('name' => $data['customer_pref']));
618 View Code Duplication
                if (!$pref) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
619
                    $response = new Response(json_encode('NG'), 500);
620
                    $response->headers->set('Content-Type', 'application/json');
621
                    return $response;
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
622
                }
623
624
                $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']);
625
                if (!$Order) {
626
                    $app->addError('front.shopping.order.error');
627
                    return $app->redirect($app->url('shopping_error'));
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
628
                }
629
630
                $Order
631
                    ->setName01($data['customer_name01'])
632
                    ->setName02($data['customer_name02'])
633
                    ->setCompanyName($data['customer_company_name'])
634
                    ->setTel01($data['customer_tel01'])
635
                    ->setTel02($data['customer_tel02'])
636
                    ->setTel03($data['customer_tel03'])
637
                    ->setZip01($data['customer_zip01'])
638
                    ->setZip02($data['customer_zip02'])
639
                    ->setZipCode($data['customer_zip01'] . $data['customer_zip02'])
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
640
                    ->setPref($pref)
641
                    ->setAddr01($data['customer_addr01'])
642
                    ->setAddr02($data['customer_addr02'])
643
                    ->setEmail($data['customer_email']);
644
645
                // 配送先を更新
646
                $app['orm.em']->flush();
647
648
                // 受注関連情報を最新状態に更新
649
                $app['orm.em']->refresh($Order);
650
651
                $response = new Response(json_encode('OK'));
652
                $response->headers->set('Content-Type', 'application/json');
653
            } catch (\Exception $e) {
654
                $app->log($e);
655
656
                $response = new Response(json_encode('NG'), 500);
657
                $response->headers->set('Content-Type', 'application/json');
658
            }
659
660
            return $response;
661
        }
662
    }
663
664
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$app" missing
Loading history...
introduced by
Doc comment for parameter "$request" missing
Loading history...
665
     * ログイン
666
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
667 2
    public function login(Application $app, Request $request)
668
    {
669
        if (!$app['eccube.service.cart']->isLocked()) {
670
            return $app->redirect($app->url('cart'));
671
        }
672
673
        if ($app->isGranted('IS_AUTHENTICATED_FULLY')) {
674
            return $app->redirect($app->url('shopping'));
675
        }
676
677
        /* @var $form \Symfony\Component\Form\FormInterface */
678
        $builder = $app['form.factory']->createNamedBuilder('', 'customer_login');
679
680 View Code Duplication
        if ($app->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
681
            $Customer = $app->user();
682
            if ($Customer) {
683
                $builder->get('login_email')->setData($Customer->getEmail());
684
            }
685
        }
686
687
        $form = $builder->getForm();
688
689
        return $app->render('Shopping/login.twig', array(
690
            'error' => $app['security.last_error']($request),
691
            'form' => $form->createView(),
692
        ));
693 2
    }
694
695
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$app" missing
Loading history...
introduced by
Doc comment for parameter "$request" missing
Loading history...
696
     * 非会員処理
697
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
698 11
    public function nonmember(Application $app, Request $request)
699
    {
700
        $cartService = $app['eccube.service.cart'];
701
702
        // カートチェック
703
        if (!$cartService->isLocked()) {
704
            // カートが存在しない、カートがロックされていない時はエラー
705
            return $app->redirect($app->url('cart'));
706
        }
707
708
        // ログイン済みの場合は, 購入画面へリダイレクト.
709
        if ($app->isGranted('ROLE_USER')) {
710
            return $app->redirect($app->url('shopping'));
711
        }
712
713
        // カートチェック
714
        if (count($cartService->getCart()->getCartItems()) <= 0) {
715
            // カートが存在しない時はエラー
716
            return $app->redirect($app->url('cart'));
717
        }
718
719
        $Customer = new Customer();
720
        $form = $app['form.factory']->createBuilder('nonmember', $Customer)->getForm();
721
        $form->handleRequest($request);
722
723
        if ($form->isSubmitted() && $form->isValid()) {
724
            $CustomerAddress = new CustomerAddress();
725
            $CustomerAddress
726
                ->setFromCustomer($Customer);
727
            $Customer->addCustomerAddress($CustomerAddress);
728
729
            // 受注情報を取得
730
            $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']);
731
732
            // 初回アクセス(受注データがない)の場合は, 受注情報を作成
733
            if (is_null($Order)) {
734
                // 受注情報を作成
735
                try {
736
                    // 受注情報を作成
737
                    $app['eccube.service.shopping']->createOrder($Customer);
738
                } catch (CartException $e) {
739
                    $app->addRequestError($e->getMessage());
740
                    return $app->redirect($app->url('cart'));
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
741 8
                }
742
            }
743
744
            // 非会員用セッションを作成
745 8
            $nonMember = array();
746 8
            $nonMember['customer'] = $Customer;
747
            $nonMember['pref'] = $Customer->getPref()->getId();
748
            $app['session']->set($this->sessionKey, $nonMember);
749
750 8
            $customerAddresses = array();
751 8
            $customerAddresses[] = $CustomerAddress;
752
            $app['session']->set($this->sessionCustomerAddressKey, serialize($customerAddresses));
753
754
            return $app->redirect($app->url('shopping'));
755
        }
756
757 1
        return $app->render('Shopping/nonmember.twig', array(
758 1
            'form' => $form->createView(),
759
        ));
760 11
    }
761
762
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$app" missing
Loading history...
introduced by
Doc comment for parameter "$request" missing
Loading history...
763
     * 複数配送処理がクリックされた場合の処理
764
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
765 View Code Duplication
    public function shippingMultipleChange(Application $app, Request $request)
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...
766
    {
767
        $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']);
768
        if (!$Order) {
769
            $app->addError('front.shopping.order.error');
770
            return $app->redirect($app->url('shopping_error'));
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
771
        }
772
773
        if ('POST' !== $request->getMethod()) {
774
            return $app->redirect($app->url('shopping'));
775
        }
776
777
        $form = $app['eccube.service.shopping']->getShippingForm($Order);
778
        $form->handleRequest($request);
779
780
        if ($form->isSubmitted() && $form->isValid()) {
781
            $data = $form->getData();
782
            $message = $data['message'];
783
            $Order->setMessage($message);
784
            // 受注情報を更新
785
            $app['orm.em']->flush();
786
787
            // 複数配送設定へリダイレクト
788
            return $app->redirect($app->url('shopping_shipping_multiple'));
789
        }
790
791
        return $app->render('Shopping/index.twig', array(
792
            'form' => $form->createView(),
793
            'Order' => $Order,
794
        ));
795
    }
796
797
798
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$app" missing
Loading history...
introduced by
Doc comment for parameter "$request" missing
Loading history...
799
     * 複数配送処理
800
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
801
    public function shippingMultiple(Application $app, Request $request)
802
    {
803
        $cartService = $app['eccube.service.cart'];
804
805
        // カートチェック
806
        if (!$cartService->isLocked()) {
807
            // カートが存在しない、カートがロックされていない時はエラー
808
            return $app->redirect($app->url('cart'));
809
        }
810
811
        // カートチェック
812
        if (count($cartService->getCart()->getCartItems()) <= 0) {
813
            // カートが存在しない時はエラー
814
            return $app->redirect($app->url('cart'));
815
        }
816
        $Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']);
817
        if (!$Order) {
818
            $app->addError('front.shopping.order.error');
819
            return $app->redirect($app->url('shopping_error'));
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
820
        }
821
822
        // 複数配送時は商品毎でお届け先を設定する為、商品をまとめた数量を設定
823
        $compItemQuantities = array();
824 View Code Duplication
        foreach ($Order->getShippings() as $Shipping) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
825
            foreach ($Shipping->getShipmentItems() as $ShipmentItem) {
826
                $itemId = $ShipmentItem->getProductClass()->getId();
827
                $quantity = $ShipmentItem->getQuantity();
828
                if (array_key_exists($itemId, $compItemQuantities)) {
829
                    $compItemQuantities[$itemId] = $compItemQuantities[$itemId] + $quantity;
830
                } else {
831
                    $compItemQuantities[$itemId] = $quantity;
832
                }
833
            }
834
        }
835
836
        // 商品に紐づく商品情報を取得
837
        $shipmentItems = array();
838
        $productClassIds = array();
839
        foreach ($Order->getShippings() as $Shipping) {
840
            foreach ($Shipping->getShipmentItems() as $ShipmentItem) {
841
                if (!in_array($ShipmentItem->getProductClass()->getId(), $productClassIds)) {
842
                    $shipmentItems[] = $ShipmentItem;
843
                }
844
                $productClassIds[] = $ShipmentItem->getProductClass()->getId();
845
            }
846
        }
847
848
        $form = $app->form()->getForm();
849
        $form
850
            ->add('shipping_multiple', 'collection', array(
851
                'type' => 'shipping_multiple',
852
                'data' => $shipmentItems,
853
                'allow_add' => true,
854
                'allow_delete' => true,
855
            ));
856
        $form->handleRequest($request);
857
858
        $errors = array();
859
        if ($form->isSubmitted() && $form->isValid()) {
860
            $data = $form['shipping_multiple'];
861
862
            // 数量が超えていないか、同一でないとエラー
863
            $itemQuantities = array();
864
            foreach ($data as $mulitples) {
865
                /** @var \Eccube\Entity\ShipmentItem $multipleItem */
866
                $multipleItem = $mulitples->getData();
867 View Code Duplication
                foreach ($mulitples as $items) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
868
                    foreach ($items as $item) {
869
                        $quantity = $item['quantity']->getData();
870
                        $itemId = $multipleItem->getProductClass()->getId();
871
                        if (array_key_exists($itemId, $itemQuantities)) {
872
                            $itemQuantities[$itemId] = $itemQuantities[$itemId] + $quantity;
873
                        } else {
874
                            $itemQuantities[$itemId] = $quantity;
875
                        }
876
                    }
877
                }
878
            }
879
880
            foreach ($compItemQuantities as $key => $value) {
881
                if (array_key_exists($key, $itemQuantities)) {
882
                    if ($itemQuantities[$key] != $value) {
883
                        $errors[] = array('message' => '数量の数が異なっています。');
884
885
                        // 対象がなければエラー
886
                        return $app->render('Shopping/shipping_multiple.twig', array(
887
                            'form' => $form->createView(),
888
                            'shipmentItems' => $shipmentItems,
889
                            'compItemQuantities' => $compItemQuantities,
890
                            'errors' => $errors,
891
                        ));
892
                    }
893
                }
894
            }
895
896
            // お届け先情報をdelete/insert
897
            $shippings = $Order->getShippings();
898
            foreach ($shippings as $Shipping) {
899
                $Order->removeShipping($Shipping);
900
                $app['orm.em']->remove($Shipping);
901
            }
902
903
            foreach ($data as $mulitples) {
904
                /** @var \Eccube\Entity\ShipmentItem $multipleItem */
905
                $multipleItem = $mulitples->getData();
906
907
                foreach ($mulitples as $items) {
908
                    foreach ($items as $item) {
909
                        // 追加された配送先情報を作成
910
                        $Delivery = $multipleItem->getShipping()->getDelivery();
911
912
                        // 選択された情報を取得
913
                        $data = $item['customer_address']->getData();
914
                        if ($data instanceof CustomerAddress) {
0 ignored issues
show
Bug introduced by
The class Eccube\Entity\CustomerAddress does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
915
                            // 会員の場合、CustomerAddressオブジェクトを取得
916
                            $CustomerAddress = $data;
917
                        } else {
918
                            // 非会員の場合、選択されたindexが取得される
919
                            $customerAddresses = $app['session']->get($this->sessionCustomerAddressKey);
920
                            $customerAddresses = unserialize($customerAddresses);
921
                            $CustomerAddress = $customerAddresses[$data];
922
                            $pref = $app['eccube.repository.master.pref']->find($CustomerAddress->getPref()->getId());
923
                            $CustomerAddress->setPref($pref);
924
                        }
925
926
                        $Shipping = new Shipping();
927
                        $Shipping
928
                            ->setFromCustomerAddress($CustomerAddress)
929
                            ->setDelivery($Delivery)
930
                            ->setDelFlg(Constant::DISABLED)
931
                            ->setOrder($Order);
932
                        $app['orm.em']->persist($Shipping);
933
934
                        $ProductClass = $multipleItem->getProductClass();
935
                        $Product = $multipleItem->getProduct();
936
                        $quantity = $item['quantity']->getData();
937
938
                        $ShipmentItem = new ShipmentItem();
939
                        $ShipmentItem->setShipping($Shipping)
940
                            ->setOrder($Order)
941
                            ->setProductClass($ProductClass)
942
                            ->setProduct($Product)
943
                            ->setProductName($Product->getName())
944
                            ->setProductCode($ProductClass->getCode())
945
                            ->setPrice($ProductClass->getPrice02())
946
                            ->setQuantity($quantity);
947
948
                        $ClassCategory1 = $ProductClass->getClassCategory1();
949
                        if (!is_null($ClassCategory1)) {
950
                            $ShipmentItem->setClasscategoryName1($ClassCategory1->getName());
951
                            $ShipmentItem->setClassName1($ClassCategory1->getClassName()->getName());
952
                        }
953
                        $ClassCategory2 = $ProductClass->getClassCategory2();
954
                        if (!is_null($ClassCategory2)) {
955
                            $ShipmentItem->setClasscategoryName2($ClassCategory2->getName());
956
                            $ShipmentItem->setClassName2($ClassCategory2->getClassName()->getName());
957
                        }
958
                        $Shipping->addShipmentItem($ShipmentItem);
959
                        $app['orm.em']->persist($ShipmentItem);
960
961
                        // 配送料金の設定
962
                        $app['eccube.service.shopping']->setShippingDeliveryFee($Shipping);
963
                    }
964
                }
965
            }
966
            // 配送先を更新
967
            $app['orm.em']->flush();
968
969
            return $app->redirect($app->url('shopping'));
970
        }
971
972
        return $app->render('Shopping/shipping_multiple.twig', array(
973
            'form' => $form->createView(),
974
            'shipmentItems' => $shipmentItems,
975
            'compItemQuantities' => $compItemQuantities,
976
            'errors' => $errors,
977
        ));
978
    }
979
980
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$app" missing
Loading history...
introduced by
Doc comment for parameter "$request" missing
Loading history...
981
     * 非会員用複数配送設定時の新規お届け先の設定
982
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
983
    public function shippingMultipleEdit(Application $app, Request $request)
984
    {
985
        // カートチェック
986
        if (!$app['eccube.service.cart']->isLocked()) {
987
            // カートが存在しない、カートがロックされていない時はエラー
988
            return $app->redirect($app->url('cart'));
989
        }
990
991
        // 非会員用Customerを取得
992
        $Customer = $app['eccube.service.shopping']->getNonMember($this->sessionKey);
993
        $CustomerAddress = new CustomerAddress();
994
        $CustomerAddress->setCustomer($Customer);
995
        $Customer->addCustomerAddress($CustomerAddress);
996
997
        $form = $app['form.factory']->createBuilder('shopping_shipping', $CustomerAddress)->getForm();
998
        $form->handleRequest($request);
999
1000
        if ($form->isSubmitted() && $form->isValid()) {
1001
            // 非会員用のセッションに追加
1002
            $customerAddresses = $app['session']->get($this->sessionCustomerAddressKey);
1003
            $customerAddresses = unserialize($customerAddresses);
1004
            $customerAddresses[] = $CustomerAddress;
1005
            $app['session']->set($this->sessionCustomerAddressKey, serialize($customerAddresses));
1006
1007
            return $app->redirect($app->url('shopping_shipping_multiple'));
1008
        }
1009
1010
        return $app->render('Shopping/shipping_multiple_edit.twig', array(
1011
            'form' => $form->createView(),
1012
        ));
1013
    }
1014
1015
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$app" missing
Loading history...
1016
     * 購入エラー画面表示
1017
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
1018 1
    public function shoppingError(Application $app)
1019
    {
1020
        return $app->render('Shopping/shopping_error.twig');
1021 1
    }
1022
1023
    /**
1024
     * 非会員でのお客様情報変更時の入力チェック
1025
     */
1026
    private function customerValidation($app, $data)
1027
    {
1028
        // 入力チェック
1029
        $errors = array();
1030
1031
        $errors[] = $app['validator']->validateValue($data['customer_name01'], array(
0 ignored issues
show
introduced by
Add a comma after each item in a multi-line array
Loading history...
1032
            new Assert\NotBlank(),
1033
            new Assert\Length(array('max' => $app['config']['name_len'],)),
0 ignored issues
show
introduced by
Add a single space after each comma delimiter
Loading history...
1034
            new Assert\Regex(array('pattern' => '/^[^\s ]+$/u', 'message' => 'form.type.name.firstname.nothasspace'))
1035
        ));
1036
1037
        $errors[] = $app['validator']->validateValue($data['customer_name02'], array(
0 ignored issues
show
introduced by
Add a comma after each item in a multi-line array
Loading history...
1038
            new Assert\NotBlank(),
1039
            new Assert\Length(array('max' => $app['config']['name_len'], )),
1040
            new Assert\Regex(array('pattern' => '/^[^\s ]+$/u', 'message' => 'form.type.name.firstname.nothasspace'))
1041
        ));
1042
1043
        $errors[] = $app['validator']->validateValue($data['customer_company_name'], array(
1044
            new Assert\Length(array('max' => $app['config']['stext_len'])),
1045
        ));
1046
1047
        $errors[] = $app['validator']->validateValue($data['customer_tel01'], array(
1048
            new Assert\NotBlank(),
1049
            new Assert\Type(array('type' => 'numeric', 'message' => 'form.type.numeric.invalid')),
1050
            new Assert\Length(array('max' => $app['config']['tel_len'], 'min' => $app['config']['tel_len_min'])),
1051
        ));
1052
1053
        $errors[] = $app['validator']->validateValue($data['customer_tel02'], array(
1054
            new Assert\NotBlank(),
1055
            new Assert\Type(array('type' => 'numeric', 'message' => 'form.type.numeric.invalid')),
1056
            new Assert\Length(array('max' => $app['config']['tel_len'], 'min' => $app['config']['tel_len_min'])),
1057
        ));
1058
1059
        $errors[] = $app['validator']->validateValue($data['customer_tel03'], array(
1060
            new Assert\NotBlank(),
1061
            new Assert\Type(array('type' => 'numeric', 'message' => 'form.type.numeric.invalid')),
1062
            new Assert\Length(array('max' => $app['config']['tel_len'], 'min' => $app['config']['tel_len_min'])),
1063
        ));
1064
1065
        $errors[] = $app['validator']->validateValue($data['customer_zip01'], array(
1066
            new Assert\NotBlank(),
1067
            new Assert\Type(array('type' => 'numeric', 'message' => 'form.type.numeric.invalid')),
1068
            new Assert\Length(array('min' => $app['config']['zip01_len'], 'max' => $app['config']['zip01_len'])),
1069
        ));
1070
1071
        $errors[] = $app['validator']->validateValue($data['customer_zip02'], array(
1072
            new Assert\NotBlank(),
1073
            new Assert\Type(array('type' => 'numeric', 'message' => 'form.type.numeric.invalid')),
1074
            new Assert\Length(array('min' => $app['config']['zip02_len'], 'max' => $app['config']['zip02_len'])),
1075
        ));
1076
1077
        $errors[] = $app['validator']->validateValue($data['customer_addr01'], array(
1078
            new Assert\NotBlank(),
1079
            new Assert\Length(array('max' => $app['config']['address1_len'])),
1080
        ));
1081
1082
        $errors[] = $app['validator']->validateValue($data['customer_addr02'], array(
1083
            new Assert\NotBlank(),
1084
            new Assert\Length(array('max' => $app['config']['address2_len'])),
1085
        ));
1086
1087
        $errors[] = $app['validator']->validateValue($data['customer_email'], array(
1088
            new Assert\NotBlank(),
1089
            new Assert\Email(),
1090
        ));
1091
1092
        return $errors;
1093
    }
1094
}
1095