Failed Conditions
Pull Request — experimental/3.1 (#2273)
by
unknown
39:32
created

CartController::removeCartNo()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 35
Code Lines 19

Duplication

Lines 35
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 19
nc 2
nop 3
dl 35
loc 35
ccs 0
cts 0
cp 0
crap 6
rs 8.8571
c 0
b 0
f 0
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\Event\EccubeEvents;
29
use Eccube\Event\EventArgs;
30
use Eccube\Exception\CartException;
31
use Symfony\Component\HttpFoundation\Request;
32
33
class CartController extends AbstractController
0 ignored issues
show
introduced by
Missing class doc comment
Loading history...
34
{
35
    /**
36
     * カート画面.
37
     *
38
     * @param Application $app
39
     * @param Request $request
0 ignored issues
show
introduced by
Expected 5 spaces after parameter type; 1 found
Loading history...
40
     * @return \Symfony\Component\HttpFoundation\Response
41
     */
42 2
    public function index(Application $app, Request $request)
43
    {
44 2
        $Cart = $app['eccube.service.cart']->getCart();
45
46
        // FRONT_CART_INDEX_INITIALIZE
47 2
        $event = new EventArgs(
48 2
            array(),
49
            $request
50
        );
51 2
        $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_INDEX_INITIALIZE, $event);
52
53
        /* @var $BaseInfo \Eccube\Entity\BaseInfo */
54
        /* @var $Cart \Eccube\Entity\Cart */
55 2
        $BaseInfo = $app['eccube.repository.base_info']->get();
56
57 2
        $isDeliveryFree = false;
58 2
        $least = 0;
59 2
        $quantity = 0;
60 2
        if ($BaseInfo->getDeliveryFreeAmount()) {
61
            if ($BaseInfo->getDeliveryFreeAmount() <= $Cart->getTotalPrice()) {
62
                // 送料無料(金額)を超えている
63
                $isDeliveryFree = true;
64
            } else {
65
                $least = $BaseInfo->getDeliveryFreeAmount() - $Cart->getTotalPrice();
66
            }
67
        }
68
69 2
        if ($BaseInfo->getDeliveryFreeQuantity()) {
70
            if ($BaseInfo->getDeliveryFreeQuantity() <= $Cart->getTotalQuantity()) {
71
                // 送料無料(個数)を超えている
72
                $isDeliveryFree = true;
73
            } else {
74
                $quantity = $BaseInfo->getDeliveryFreeQuantity() - $Cart->getTotalQuantity();
75
            }
76
        }
77
78
        // FRONT_CART_INDEX_COMPLETE
79 2
        $event = new EventArgs(
80 2
            array(),
81
            $request
82
        );
83 2
        $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_INDEX_COMPLETE, $event);
84
85 2
        if ($event->hasResponse()) {
86
            return $event->getResponse();
87
        }
88
89 2
        return $app->render(
90 2
            'Cart/index.twig',
91
            array(
92 2
                'Cart' => $Cart,
93 2
                'least' => $least,
94 2
                'quantity' => $quantity,
95 2
                'is_delivery_free' => $isDeliveryFree,
96
            )
97
        );
98
    }
99
100
    /**
101
     * カートに商品を追加する.
102
     *
103
     * @param Application $app
104
     * @param Request $request
0 ignored issues
show
introduced by
Expected 5 spaces after parameter type; 1 found
Loading history...
105
     * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
106
     */
107 38
    public function add(Application $app, Request $request)
108
    {
109 38
        $productClassId = $request->get('product_class_id');
110 38
        $quantity = $request->request->has('quantity') ? $request->get('quantity') : 1;
111
112
        // FRONT_CART_ADD_INITIALIZE
113 38
        $event = new EventArgs(
114
            array(
115 38
                'productClassId' => $productClassId,
116 38
                'quantity' => $quantity,
117
            ),
118
            $request
119
        );
120 38
        $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_ADD_INITIALIZE, $event);
121
122
        try {
0 ignored issues
show
Coding Style introduced by
Blank line found at start of control structure
Loading history...
123
124 38
            $productClassId = $event->getArgument('productClassId');
125 38
            $quantity = $event->getArgument('quantity');
126
127 38
            log_info('カート追加処理開始', array('product_class_id' => $productClassId, 'quantity' => $quantity));
128
129 38
            $app['eccube.service.cart']->addProduct($productClassId, $quantity)->save();
130
131 37
            log_info('カート追加処理完了', array('product_class_id' => $productClassId, 'quantity' => $quantity));
132
133
            // FRONT_CART_ADD_COMPLETE
134 37
            $event = new EventArgs(
135
                array(
136 37
                    'productClassId' => $productClassId,
137 37
                    'quantity' => $quantity,
138
                ),
139
                $request
140
            );
141 37
            $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_ADD_COMPLETE, $event);
142
143 37
            if ($event->hasResponse()) {
144 37
                return $event->getResponse();
145
            }
146
0 ignored issues
show
Coding Style introduced by
Blank line found at end of control structure
Loading history...
147 1
        } catch (CartException $e) {
0 ignored issues
show
Coding Style introduced by
Blank line found at start of control structure
Loading history...
148
149 1
            log_info('カート追加エラー', array($e->getMessage()));
150
151
            // FRONT_CART_ADD_EXCEPTION
152 1
            $event = new EventArgs(
153
                array(
154 1
                    'exception' => $e,
155
                ),
156
                $request
157
            );
158 1
            $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_ADD_EXCEPTION, $event);
159
160 1
            if ($event->hasResponse()) {
161
                return $event->getResponse();
162
            }
163
164 1
            $app->addRequestError($e->getMessage());
165
        }
166
167 38
        return $app->redirect($app->url('cart'));
168
    }
169
170
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$productClassId" missing
Loading history...
171
     * カートに入っている商品の個数を1増やす.
172
     *
173
     * @param Application $app
0 ignored issues
show
introduced by
Expected 4 spaces after parameter type; 1 found
Loading history...
174
     * @param Request $request
0 ignored issues
show
introduced by
Expected 8 spaces after parameter type; 1 found
Loading history...
175
     * @param $productClassId
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
176
     * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
177
     */
178 3 View Code Duplication
    public function up(Application $app, Request $request, $productClassId)
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...
179
    {
180 3
        $this->isTokenValid($app);
181
182
        // FRONT_CART_UP_INITIALIZE
183 3
        $event = new EventArgs(
184
            array(
185 3
                'productClassId' => $productClassId,
186
            ),
187
            $request
188
        );
189 3
        $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_UP_INITIALIZE, $event);
190
191
        try {
0 ignored issues
show
Coding Style introduced by
Blank line found at start of control structure
Loading history...
192
193 3
            log_info('カート加算処理開始', array('product_class_id' => $productClassId));
194
195 3
            $productClassId = $event->getArgument('productClassId');
196
197 3
            $app['eccube.service.cart']->upProductQuantity($productClassId)->save();
198
199
            // FRONT_CART_UP_COMPLETE
200 2
            $event = new EventArgs(
201
                array(
202 2
                    'productClassId' => $productClassId,
203
                ),
204
                $request
205
            );
206 2
            $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_UP_COMPLETE, $event);
207
208 2
            if ($event->hasResponse()) {
209
                return $event->getResponse();
210
            }
211
212 2
            log_info('カート加算処理完了', array('product_class_id' => $productClassId));
213
0 ignored issues
show
Coding Style introduced by
Blank line found at end of control structure
Loading history...
214 1
        } catch (CartException $e) {
0 ignored issues
show
Coding Style introduced by
Blank line found at start of control structure
Loading history...
215
216 1
            log_info('カート加算エラー', array($e->getMessage()));
217
218
            // FRONT_CART_UP_EXCEPTION
219 1
            $event = new EventArgs(
220
                array(
221 1
                    'exception' => $e,
222
                ),
223
                $request
224
            );
225 1
            $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_UP_EXCEPTION, $event);
226
227 1
            if ($event->hasResponse()) {
228
                return $event->getResponse();
229
            }
230
231 1
            $app->addRequestError($e->getMessage());
232
        }
233
234 3
        return $app->redirect($app->url('cart'));
235
    }
236
237
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$productClassId" missing
Loading history...
238
     * カートに入っている商品の個数を1減らす.
239
     * マイナスになる場合は, 商品をカートから削除する.
240
     *
241
     * @param Application $app
0 ignored issues
show
introduced by
Expected 4 spaces after parameter type; 1 found
Loading history...
242
     * @param Request $request
0 ignored issues
show
introduced by
Expected 8 spaces after parameter type; 1 found
Loading history...
243
     * @param $productClassId
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
244
     * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
245
     */
246 3 View Code Duplication
    public function down(Application $app, Request $request, $productClassId)
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...
247
    {
248 3
        $this->isTokenValid($app);
249
250
        // FRONT_CART_DOWN_INITIALIZE
251 3
        $event = new EventArgs(
252
            array(
253 3
                'productClassId' => $productClassId,
254
            ),
255
            $request
256
        );
257 3
        $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_DOWN_INITIALIZE, $event);
258
259
        try {
0 ignored issues
show
Coding Style introduced by
Blank line found at start of control structure
Loading history...
260
261 3
            log_info('カート減算処理開始', array('product_class_id' => $productClassId));
262
263 3
            $productClassId = $event->getArgument('productClassId');
264 3
            $app['eccube.service.cart']->downProductQuantity($productClassId)->save();
265
266
            // FRONT_CART_UP_COMPLETE
267 3
            $event = new EventArgs(
268
                array(
269 3
                    'productClassId' => $productClassId,
270
                ),
271
                $request
272
            );
273 3
            $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_DOWN_COMPLETE, $event);
274
275 3
            if ($event->hasResponse()) {
276
                return $event->getResponse();
277
            }
278
279 3
            log_info('カート減算処理完了', array('product_class_id' => $productClassId));
280
0 ignored issues
show
Coding Style introduced by
Blank line found at end of control structure
Loading history...
281
        } catch (CartException $e) {
282
            log_info('カート減算エラー', array($e->getMessage()));
283
284
            // FRONT_CART_DOWN_EXCEPTION
285
            $event = new EventArgs(
286
                array(
287
                    'exception' => $e,
288
                ),
289
                $request
290
            );
291
            $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_DOWN_EXCEPTION, $event);
292
293
            if ($event->hasResponse()) {
294
                return $event->getResponse();
295
            }
296
297
            $app->addRequestError($e->getMessage());
298
        }
299
300 3
        return $app->redirect($app->url('cart'));
301
    }
302
303
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$productClassId" missing
Loading history...
304
     * カートに入っている商品を削除する.
305
     *
306
     * @param Application $app
0 ignored issues
show
introduced by
Expected 4 spaces after parameter type; 1 found
Loading history...
307
     * @param Request $request
0 ignored issues
show
introduced by
Expected 8 spaces after parameter type; 1 found
Loading history...
308
     * @param $productClassId
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
309
     * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
310
     */
311 2 View Code Duplication
    public function remove(Application $app, Request $request, $productClassId)
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...
312
    {
313 2
        $this->isTokenValid($app);
314
315 2
        log_info('カート削除処理開始', array('product_class_id' => $productClassId));
316
317
        // FRONT_CART_REMOVE_INITIALIZE
318 2
        $event = new EventArgs(
319
            array(
320 2
                'productClassId' => $productClassId,
321
            ),
322
            $request
323
        );
324 2
        $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_REMOVE_INITIALIZE, $event);
325
326 2
        $productClassId = $event->getArgument('productClassId');
327 2
        $app['eccube.service.cart']->removeProduct($productClassId)->save();
328
329 2
        log_info('カート削除処理完了', array('product_class_id' => $productClassId));
330
331
        // FRONT_CART_REMOVE_COMPLETE
332 2
        $event = new EventArgs(
333
            array(
334 2
                'productClassId' => $productClassId,
335
            ),
336
            $request
337
        );
338 2
        $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_REMOVE_COMPLETE, $event);
339
340 2
        if ($event->hasResponse()) {
341
            return $event->getResponse();
342
        }
343
344 2
        return $app->redirect($app->url('cart'));
345
    }
346
347
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$cart_no" missing
Loading history...
348
     * カートに入っている商品の個数を1増やす.
349
     *
350
     * @param Application $app
351
     * @param Request $request
0 ignored issues
show
introduced by
Expected 5 spaces after parameter type; 1 found
Loading history...
352
     * @param $cart_no
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
353
     * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
354
     */
355 View Code Duplication
    public function upCartNo(Application $app, Request $request, $cart_no)
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...
356
    {
357
        $this->isTokenValid($app);
358
359
        // FRONT_CART_UP_INITIALIZE
360
        $event = new EventArgs(
361
            array(
362
                'cart_no' => $cart_no,
363
            ),
364
            $request
365
        );
366
        $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_UP_CART_NO_INITIALIZE, $event);
367
368
        try {
0 ignored issues
show
Coding Style introduced by
Blank line found at start of control structure
Loading history...
369
370
            log_info('カート加算処理開始', array('cart_no' => $cart_no));
371
372
            $cart_no = $event->getArgument('cart_no');
373
374
            $app['eccube.service.cart']->upCartNoQuantity($cart_no)->save();
375
376
            // FRONT_CART_UP_COMPLETE
377
            $event = new EventArgs(
378
                array(
379
                    'cart_no' => $cart_no,
380
                ),
381
                $request
382
            );
383
            $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_UP_CART_NO_COMPLETE, $event);
384
385
            if ($event->hasResponse()) {
386
                return $event->getResponse();
387
            }
388
389
            log_info('カート加算処理完了', array('cart_no' => $cart_no));
390
0 ignored issues
show
Coding Style introduced by
Blank line found at end of control structure
Loading history...
391
        } catch (CartException $e) {
0 ignored issues
show
Coding Style introduced by
Blank line found at start of control structure
Loading history...
392
393
            log_info('カート加算エラー', array($e->getMessage()));
394
395
            // FRONT_CART_UP_EXCEPTION
396
            $event = new EventArgs(
397
                array(
398
                    'exception' => $e,
399
                ),
400
                $request
401
            );
402
            $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_UP_CART_NO_EXCEPTION, $event);
403
404
            if ($event->hasResponse()) {
405
                return $event->getResponse();
406
            }
407
408
            $app->addRequestError($e->getMessage());
409
        }
410
411
        return $app->redirect($app->url('cart'));
412
    }
413
414
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$cart_no" missing
Loading history...
415
     * カートに入っている商品の個数を1減らす.
416
     *
417
     * @param Application $app
418
     * @param Request $request
0 ignored issues
show
introduced by
Expected 5 spaces after parameter type; 1 found
Loading history...
419
     * @param $cart_no
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
420
     * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
421
     */
422 View Code Duplication
    public function downCartNo(Application $app, Request $request, $cart_no)
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...
423
    {
424
        $this->isTokenValid($app);
425
426
        // FRONT_CART_DOWN_INITIALIZE
427
        $event = new EventArgs(
428
            array(
429
                'cart_no' => $cart_no,
430
            ),
431
            $request
432
        );
433
        $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_DOWN_CART_NO_INITIALIZE, $event);
434
435
        try {
0 ignored issues
show
Coding Style introduced by
Blank line found at start of control structure
Loading history...
436
437
            log_info('カート減算処理開始', array('cart_no' => $cart_no));
438
439
            $cart_no = $event->getArgument('cart_no');
440
441
            $app['eccube.service.cart']->downCartNoQuantity($cart_no)->save();
442
443
            // FRONT_CART_DOWN_COMPLETE
444
            $event = new EventArgs(
445
                array(
446
                    'cart_no' => $cart_no,
447
                ),
448
                $request
449
            );
450
            $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_DOWN_CART_NO_COMPLETE, $event);
451
452
            if ($event->hasResponse()) {
453
                return $event->getResponse();
454
            }
455
456
            log_info('カート減算処理完了', array('cart_no' => $cart_no));
457
0 ignored issues
show
Coding Style introduced by
Blank line found at end of control structure
Loading history...
458
        } catch (CartException $e) {
0 ignored issues
show
Coding Style introduced by
Blank line found at start of control structure
Loading history...
459
460
            log_info('カート減算エラー', array($e->getMessage()));
461
462
            // FRONT_CART_DOWN_EXCEPTION
463
            $event = new EventArgs(
464
                array(
465
                    'exception' => $e,
466
                ),
467
                $request
468
            );
469
            $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_DOWN_CART_NO_EXCEPTION, $event);
470
471
            if ($event->hasResponse()) {
472
                return $event->getResponse();
473
            }
474
475
            $app->addRequestError($e->getMessage());
476
        }
477
478
        return $app->redirect($app->url('cart'));
479
    }
480
481
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$cart_no" missing
Loading history...
482
     * カートに入っている商品を削除する.
483
     *
484
     * @param Application $app
485
     * @param Request $request
0 ignored issues
show
introduced by
Expected 5 spaces after parameter type; 1 found
Loading history...
486
     * @param $cart_no
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
487
     * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
488
     */
489 View Code Duplication
    public function removeCartNo(Application $app, Request $request, $cart_no)
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...
490
    {
491
        $this->isTokenValid($app);
492
493
        log_info('カート削除処理開始', array('cart_no' => $cart_no));
494
495
        // FRONT_CART_REMOVE_INITIALIZE
496
        $event = new EventArgs(
497
            array(
498
                'cart_no' => $cart_no,
499
            ),
500
            $request
501
        );
502
        $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_REMOVE_INITIALIZE, $event);
503
504
        $cart_no = $event->getArgument('cart_no');
505
        $app['eccube.service.cart']->removeCartNo($cart_no)->save();
506
507
        log_info('カート削除処理完了', array('cart_no' => $cart_no));
508
509
        // FRONT_CART_REMOVE_COMPLETE
510
        $event = new EventArgs(
511
            array(
512
                'cart_no' => $cart_no,
513
            ),
514
            $request
515
        );
516
        $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_REMOVE_COMPLETE, $event);
517
518
        if ($event->hasResponse()) {
519
            return $event->getResponse();
520
        }
521
522
        return $app->redirect($app->url('cart'));
523
    }
524
525
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$productClassId" missing
Loading history...
introduced by
Doc comment for parameter "$quantity" missing
Loading history...
526
     * カートに商品を個数を指定して設定する.
527
     *
528
     * @param Application $app
0 ignored issues
show
introduced by
Expected 4 spaces after parameter type; 1 found
Loading history...
529
     * @param Request $request
0 ignored issues
show
introduced by
Expected 8 spaces after parameter type; 1 found
Loading history...
530
     * @param $productClassId
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
531
     * @param $quantity
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
532
     * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
533
     * @throws CartException
534
     *
535
     * @deprecated since 3.0.0, to be removed in 3.1
536
     */
537
    public function setQuantity(Application $app, Request $request, $productClassId, $quantity)
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...
538
    {
539
        $this->isTokenValid($app);
540
541
        $app['eccube.service.cart']->setProductQuantity($productClassId, $quantity)->save();
542
543
        return $app->redirect($app->url('cart'));
544
    }
545
546
    /**
547
     * カートをロック状態に設定し、購入確認画面へ遷移する.
548
     *
549
     * @param Application $app
550
     * @param Request $request
0 ignored issues
show
introduced by
Expected 5 spaces after parameter type; 1 found
Loading history...
551
     * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
552
     */
553
    public function buystep(Application $app, Request $request)
554
    {
555
        // FRONT_CART_BUYSTEP_INITIALIZE
556
        $event = new EventArgs(
557
            array(),
558
            $request
559
        );
560
        $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_BUYSTEP_INITIALIZE, $event);
561
562
        $app['eccube.service.cart']->lock();
563
        $app['eccube.service.cart']->save();
564
565
        // FRONT_CART_BUYSTEP_COMPLETE
566
        $event = new EventArgs(
567
            array(),
568
            $request
569
        );
570
        $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CART_BUYSTEP_COMPLETE, $event);
571
572
        if ($event->hasResponse()) {
573
            return $event->getResponse();
574
        }
575
576
        return $app->redirect($app->url('shopping'));
577
    }
578
}
579