Completed
Push — sf/improvement-coverage ( b3937e...01a837 )
by Kiyotaka
51:20 queued 45:08
created

AbstractShoppingController::setPurchaseFlow()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
crap 1
1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) LOCKON CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.lockon.co.jp/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Eccube\Controller;
15
16
use Eccube\Entity\ItemHolderInterface;
17
use Eccube\Service\PurchaseFlow\PurchaseContext;
18
use Eccube\Service\PurchaseFlow\PurchaseFlow;
19
use Eccube\Service\PurchaseFlow\PurchaseFlowResult;
20
21
class AbstractShoppingController extends AbstractController
22
{
23
    /**
24
     * @var PurchaseFlow
25
     */
26
    protected $purchaseFlow;
27
28
    /**
29
     * @var PurchaseContext
30
     */
31
    protected $purchaseContext;
32
33
    /**
34
     * @var string 非会員用セッションキー
35
     */
36
    protected $sessionKey = 'eccube.front.shopping.nonmember';
37
38
    /**
39
     * @var string 非会員用セッションキー
40
     */
41
    protected $sessionCustomerAddressKey = 'eccube.front.shopping.nonmember.customeraddress';
42
43
    /**
44
     * @var string 受注IDキー
45
     */
46
    protected $sessionOrderKey = 'eccube.front.shopping.order.id';
47
48
    /**
49
     * @param PurchaseFlow $shoppingPurchaseFlow
50
     * @required
51
     */
52 59
    public function setPurchaseFlow(PurchaseFlow $shoppingPurchaseFlow)
53
    {
54 59
        $this->purchaseFlow = $shoppingPurchaseFlow;
55
    }
56
57
    /**
58
     * @param ItemHolderInterface $itemHolder
59
     *
60
     * @return PurchaseFlowResult
61
     */
62 51
    protected function validatePurchaseFlow(ItemHolderInterface $itemHolder)
63
    {
64
        /** @var PurchaseFlowResult $flowResult */
65 51
        $flowResult = $this->purchaseFlow->validate($itemHolder, new PurchaseContext($itemHolder, $itemHolder->getCustomer()));
66 51
        foreach ($flowResult->getWarning() as $warning) {
67 4
            $this->addRequestError($warning);
68
        }
69 51
        foreach ($flowResult->getErrors() as $error) {
70 6
            $this->addRequestError($error);
71
        }
72
73 51
        return $flowResult;
74
    }
75
}
76