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
|
|
|
|