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