|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved. |
|
5
|
|
|
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace SprykerShop\Yves\CartPage; |
|
9
|
|
|
|
|
10
|
|
|
use Spryker\Yves\Kernel\AbstractFactory; |
|
11
|
|
|
use SprykerShop\Yves\CartPage\Dependency\Client\CartPageToAvailabilityStorageClientInterface; |
|
12
|
|
|
use SprykerShop\Yves\CartPage\Dependency\Client\CartPageToProductStorageClientInterface; |
|
13
|
|
|
use SprykerShop\Yves\CartPage\Dependency\Client\CartPageToQuoteClientInterface; |
|
14
|
|
|
use SprykerShop\Yves\CartPage\Dependency\Client\CartPageToZedRequestClientInterface; |
|
15
|
|
|
use SprykerShop\Yves\CartPage\Handler\CartItemHandler; |
|
16
|
|
|
use SprykerShop\Yves\CartPage\Mapper\CartItemsAttributeMapper; |
|
17
|
|
|
use SprykerShop\Yves\CartPage\Mapper\CartItemsAvailabilityMapper; |
|
18
|
|
|
use SprykerShop\Yves\CartPage\Model\CartItemReader; |
|
19
|
|
|
use SprykerShop\Yves\CartPage\Plugin\Provider\AttributeVariantsProvider; |
|
20
|
|
|
|
|
21
|
|
|
class CartPageFactory extends AbstractFactory |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* @return \SprykerShop\Yves\CartPage\Dependency\Client\CartPageToCartClientInterface |
|
25
|
|
|
*/ |
|
26
|
|
|
public function getCartClient() |
|
27
|
|
|
{ |
|
28
|
|
|
return $this->getProvidedDependency(CartPageDependencyProvider::CLIENT_CART); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @return \SprykerShop\Yves\CartPage\Dependency\Client\CartPageToQuoteClientInterface |
|
33
|
|
|
*/ |
|
34
|
|
|
public function getQuoteClient(): CartPageToQuoteClientInterface |
|
35
|
|
|
{ |
|
36
|
|
|
return $this->getProvidedDependency(CartPageDependencyProvider::CLIENT_QUOTE); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @return \SprykerShop\Yves\CartPage\Handler\CartItemHandlerInterface |
|
41
|
|
|
*/ |
|
42
|
|
|
public function createCartItemHandler() |
|
43
|
|
|
{ |
|
44
|
|
|
return new CartItemHandler( |
|
45
|
|
|
$this->getCartClient(), |
|
46
|
|
|
$this->getProductStorageClient(), |
|
47
|
|
|
$this->getZedRequestClient() |
|
48
|
|
|
); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @return \Spryker\Yves\Kernel\Application |
|
53
|
|
|
*/ |
|
54
|
|
|
public function getApplication() |
|
55
|
|
|
{ |
|
56
|
|
|
return $this->getProvidedDependency(CartPageDependencyProvider::PLUGIN_APPLICATION); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @return \Spryker\Yves\Messenger\FlashMessenger\FlashMessengerInterface |
|
61
|
|
|
*/ |
|
62
|
|
|
public function getFlashMessenger() |
|
63
|
|
|
{ |
|
64
|
|
|
return $this->getApplication()['flash_messenger']; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @return string |
|
69
|
|
|
*/ |
|
70
|
|
|
public function getLocale() |
|
71
|
|
|
{ |
|
72
|
|
|
return $this->getApplication()['locale']; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @return \Symfony\Component\HttpFoundation\Request |
|
77
|
|
|
*/ |
|
78
|
|
|
public function getRequest() |
|
79
|
|
|
{ |
|
80
|
|
|
return $this->getApplication()['request']; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @return \SprykerShop\Yves\CartPage\Dependency\Plugin\CartVariantAttributeMapperPluginInterface |
|
85
|
|
|
*/ |
|
86
|
|
|
public function getCartVariantAttributeMapperPlugin() |
|
87
|
|
|
{ |
|
88
|
|
|
return $this->getProvidedDependency(CartPageDependencyProvider::PLUGIN_CART_VARIANT); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @return mixed |
|
93
|
|
|
*/ |
|
94
|
|
|
public function getCartPageWidgetPlugins() |
|
95
|
|
|
{ |
|
96
|
|
|
return $this->getProvidedDependency(CartPageDependencyProvider::PLUGIN_CART_PAGE_WIDGETS); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* @return \SprykerShop\Yves\CartPage\Plugin\Provider\AttributeVariantsProvider |
|
101
|
|
|
*/ |
|
102
|
|
|
public function createCartItemsAttributeProvider() |
|
103
|
|
|
{ |
|
104
|
|
|
return new AttributeVariantsProvider( |
|
105
|
|
|
$this->getCartVariantAttributeMapperPlugin(), |
|
106
|
|
|
$this->createCartItemHandler() |
|
107
|
|
|
); |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* @return \SprykerShop\Yves\CartPage\Dependency\Client\CartPageToProductStorageClientInterface |
|
112
|
|
|
*/ |
|
113
|
|
|
public function getProductStorageClient(): CartPageToProductStorageClientInterface |
|
114
|
|
|
{ |
|
115
|
|
|
return $this->getProvidedDependency(CartPageDependencyProvider::CLIENT_PRODUCT_STORAGE); |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* @return \SprykerShop\Yves\CartPage\Dependency\Client\CartPageToAvailabilityStorageClientInterface |
|
120
|
|
|
*/ |
|
121
|
|
|
public function getAvailabilityStorageClient(): CartPageToAvailabilityStorageClientInterface |
|
122
|
|
|
{ |
|
123
|
|
|
return $this->getProvidedDependency(CartPageDependencyProvider::CLIENT_AVAILABILITY_STORAGE); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* @return \SprykerShop\Yves\CartPage\Dependency\Client\CartPageToZedRequestClientInterface |
|
128
|
|
|
*/ |
|
129
|
|
|
public function getZedRequestClient(): CartPageToZedRequestClientInterface |
|
130
|
|
|
{ |
|
131
|
|
|
return $this->getProvidedDependency(CartPageDependencyProvider::CLIENT_ZED_REQUEST); |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
/** |
|
135
|
|
|
* @return \SprykerShop\Yves\CartPage\Model\CartItemReaderInterface |
|
136
|
|
|
*/ |
|
137
|
|
|
public function createCartItemReader() |
|
138
|
|
|
{ |
|
139
|
|
|
return new CartItemReader($this->getCartItemTransformerPlugins()); |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
/** |
|
143
|
|
|
* @return \SprykerShop\Yves\CartPage\Dependency\Plugin\CartItemTransformerPluginInterface[] |
|
144
|
|
|
*/ |
|
145
|
|
|
public function getCartItemTransformerPlugins() |
|
146
|
|
|
{ |
|
147
|
|
|
return $this->getProvidedDependency(CartPageDependencyProvider::PLUGIN_CART_ITEM_TRANSFORMERS); |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
/** |
|
151
|
|
|
* @return \SprykerShop\Yves\CartPageExtension\Dependency\Plugin\PreAddToCartPluginInterface[] |
|
152
|
|
|
*/ |
|
153
|
|
|
public function getPreAddToCartPlugins(): array |
|
154
|
|
|
{ |
|
155
|
|
|
return $this->getProvidedDependency(CartPageDependencyProvider::PLUGIN_PRE_ADD_TO_CART); |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
/** |
|
159
|
|
|
* @return \SprykerShop\Yves\CartPage\Mapper\CartItemsAttributeMapper |
|
160
|
|
|
*/ |
|
161
|
|
|
public function createCartItemsAttributeMapper() |
|
162
|
|
|
{ |
|
163
|
|
|
return new CartItemsAttributeMapper( |
|
164
|
|
|
$this->getProductStorageClient(), |
|
165
|
|
|
$this->createCartItemsAvailabilityMapper() |
|
166
|
|
|
); |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
/** |
|
170
|
|
|
* @return \SprykerShop\Yves\CartPage\Mapper\CartItemsAvailabilityMapper |
|
171
|
|
|
*/ |
|
172
|
|
|
public function createCartItemsAvailabilityMapper() |
|
173
|
|
|
{ |
|
174
|
|
|
return new CartItemsAvailabilityMapper($this->getAvailabilityStorageClient()); |
|
175
|
|
|
} |
|
176
|
|
|
} |
|
177
|
|
|
|