|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Eccube\ServiceProvider; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
6
|
|
|
use Eccube\Entity\BaseInfo; |
|
7
|
|
|
use Eccube\Entity\Customer; |
|
8
|
|
|
use Eccube\Entity\ItemHolderInterface; |
|
9
|
|
|
use Eccube\Repository\DeliveryRepository; |
|
10
|
|
|
use Eccube\Service\PurchaseFlow\Processor as Processor; |
|
11
|
|
|
use Eccube\Service\PurchaseFlow\PurchaseContext; |
|
12
|
|
|
use Eccube\Service\PurchaseFlow\PurchaseFlow; |
|
13
|
|
|
use Pimple\Container; |
|
14
|
|
|
use Pimple\ServiceProviderInterface; |
|
15
|
|
|
|
|
16
|
|
|
class PurchaseFlowServiceProvider implements ServiceProviderInterface |
|
|
|
|
|
|
17
|
|
|
{ |
|
18
|
|
|
public function register(Container $app) |
|
|
|
|
|
|
19
|
|
|
{ |
|
20
|
|
|
$app['eccube.purchase.context'] = $app->protect(function (ItemHolderInterface $origin = null, Customer $user = null) { |
|
21
|
|
|
return new PurchaseContext($origin, $user); |
|
22
|
|
|
}); |
|
23
|
|
|
|
|
24
|
|
|
$app['eccube.purchase.flow.cart.item_processors'] = function (Container $app) { |
|
25
|
|
|
$processors = new ArrayCollection(); |
|
26
|
|
|
$processors[] = new Processor\DisplayStatusValidator(); |
|
27
|
|
|
$processors[] = new Processor\SaleLimitValidator(); |
|
28
|
|
|
$processors[] = new Processor\DeliverySettingValidator($app[DeliveryRepository::class]); |
|
29
|
|
|
$processors[] = new Processor\StockValidator(); |
|
30
|
|
|
|
|
31
|
|
|
return $processors; |
|
32
|
|
|
}; |
|
33
|
|
|
|
|
34
|
|
|
$app['eccube.purchase.flow.cart.holder_processors'] = function (Container $app) { |
|
35
|
|
|
$processors = new ArrayCollection(); |
|
36
|
|
|
$processors[] = new Processor\PaymentProcessor($app[DeliveryRepository::class]); |
|
37
|
|
|
$processors[] = new Processor\PaymentTotalLimitValidator($app['config']['max_total_fee']); |
|
38
|
|
|
$processors[] = new Processor\DeliveryFeeFreeProcessor($app[BaseInfo::class]); |
|
39
|
|
|
$processors[] = new Processor\PaymentTotalNegativeValidator(); |
|
40
|
|
|
|
|
41
|
|
|
return $processors; |
|
42
|
|
|
}; |
|
43
|
|
|
|
|
44
|
|
|
$app['eccube.purchase.flow.cart'] = function (Container $app) { |
|
45
|
|
|
$flow = new PurchaseFlow(); |
|
46
|
|
|
$flow->setItemProcessors($app['eccube.purchase.flow.cart.item_processors']); |
|
47
|
|
|
$flow->setItemHolderProcessors($app['eccube.purchase.flow.cart.holder_processors']); |
|
48
|
|
|
|
|
49
|
|
|
return $flow; |
|
50
|
|
|
}; |
|
51
|
|
|
|
|
52
|
|
|
$app['eccube.purchase.flow.shopping.item_processors'] = function (Container $app) { |
|
|
|
|
|
|
53
|
|
|
$processors = new ArrayCollection(); |
|
54
|
|
|
$processors[] = new Processor\StockValidator(); |
|
55
|
|
|
$processors[] = new Processor\DisplayStatusValidator(); |
|
56
|
|
|
|
|
57
|
|
|
return $processors; |
|
58
|
|
|
}; |
|
59
|
|
|
|
|
60
|
|
View Code Duplication |
$app['eccube.purchase.flow.shopping.holder_processors'] = function (Container $app) { |
|
61
|
|
|
$processors = new ArrayCollection(); |
|
62
|
|
|
$processors[] = new Processor\PaymentTotalLimitValidator($app['config']['max_total_fee']); |
|
63
|
|
|
$processors[] = new Processor\DeliveryFeeProcessor($app['orm.em']); |
|
64
|
|
|
$processors[] = new Processor\PaymentTotalNegativeValidator(); |
|
65
|
|
|
if ($app[BaseInfo::class]->isOptionPoint()) { |
|
66
|
|
|
$processors[] = new Processor\UsePointProcessor($app['orm.em'], $app[BaseInfo::class]); |
|
67
|
|
|
$processors[] = new Processor\AddPointProcessor($app['orm.em'], $app[BaseInfo::class]); |
|
68
|
|
|
$processors[] = new Processor\SubstractPointProcessor($app[BaseInfo::class]); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
return $processors; |
|
72
|
|
|
}; |
|
73
|
|
|
|
|
74
|
|
|
$app['eccube.purchase.flow.shopping.purchase'] = function (Container $app) { |
|
75
|
|
|
$processors = new ArrayCollection(); |
|
76
|
|
|
if ($app[BaseInfo::class]->isOptionPoint()) { |
|
77
|
|
|
$processors[] = new Processor\UsePointToCustomerPurchaseProcessor(); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
return $processors; |
|
81
|
|
|
}; |
|
82
|
|
|
|
|
83
|
|
View Code Duplication |
$app['eccube.purchase.flow.shopping'] = function (Container $app) { |
|
84
|
|
|
$flow = new PurchaseFlow(); |
|
85
|
|
|
$flow->setItemProcessors($app['eccube.purchase.flow.shopping.item_processors']); |
|
86
|
|
|
$flow->setItemHolderProcessors($app['eccube.purchase.flow.shopping.holder_processors']); |
|
87
|
|
|
$flow->setPurchaseProcessors($app['eccube.purchase.flow.shopping.purchase']); |
|
88
|
|
|
|
|
89
|
|
|
return $flow; |
|
90
|
|
|
}; |
|
91
|
|
|
|
|
92
|
|
|
$app['eccube.purchase.flow.order.item_processors'] = function (Container $app) { |
|
|
|
|
|
|
93
|
|
|
$processors = new ArrayCollection(); |
|
94
|
|
|
$processors[] = new Processor\StockValidator(); |
|
95
|
|
|
|
|
96
|
|
|
return $processors; |
|
97
|
|
|
}; |
|
98
|
|
|
|
|
99
|
|
View Code Duplication |
$app['eccube.purchase.flow.order.holder_processors'] = function (Container $app) { |
|
100
|
|
|
$processors = new ArrayCollection(); |
|
101
|
|
|
$processors[] = new Processor\PaymentTotalLimitValidator($app['config']['max_total_fee']); |
|
102
|
|
|
$processors[] = new Processor\UpdateDatePurchaseProcessor($app['config']); |
|
103
|
|
|
if ($app[BaseInfo::class]->isOptionPoint()) { |
|
104
|
|
|
$processors[] = new Processor\UsePointProcessor($app['orm.em'], $app[BaseInfo::class]); |
|
105
|
|
|
$processors[] = new Processor\AddPointProcessor($app['orm.em'], $app[BaseInfo::class]); |
|
106
|
|
|
$processors[] = new Processor\SubstractPointProcessor($app[BaseInfo::class]); |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
return $processors; |
|
110
|
|
|
}; |
|
111
|
|
|
|
|
112
|
|
|
$app['eccube.purchase.flow.order.purchase'] = function (Container $app) { |
|
113
|
|
|
$processors = new ArrayCollection(); |
|
114
|
|
|
$processors[] = new Processor\AdminOrderRegisterPurchaseProcessor($app); |
|
|
|
|
|
|
115
|
|
|
|
|
116
|
|
|
return $processors; |
|
117
|
|
|
}; |
|
118
|
|
|
|
|
119
|
|
View Code Duplication |
$app['eccube.purchase.flow.order'] = function (Container $app) { |
|
120
|
|
|
$flow = new PurchaseFlow(); |
|
121
|
|
|
$flow->setItemProcessors($app['eccube.purchase.flow.order.item_processors']); |
|
122
|
|
|
$flow->setItemHolderProcessors($app['eccube.purchase.flow.order.holder_processors']); |
|
123
|
|
|
$flow->setPurchaseProcessors($app['eccube.purchase.flow.order.purchase']); |
|
124
|
|
|
|
|
125
|
|
|
return $flow; |
|
126
|
|
|
}; |
|
127
|
|
|
} |
|
128
|
|
|
} |
|
129
|
|
|
|