|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* MIT License |
|
5
|
|
|
* For full license information, please view the LICENSE file that was distributed with this source code. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace SprykerEco\Client\FactFinderNg; |
|
9
|
|
|
|
|
10
|
|
|
use Elastica\ResultSet\DefaultBuilder; |
|
11
|
|
|
use GuzzleHttp\ClientInterface; |
|
12
|
|
|
use Spryker\Client\Kernel\AbstractFactory; |
|
13
|
|
|
use Spryker\Client\Search\Model\Handler\SearchHandlerInterface; |
|
14
|
|
|
use SprykerEco\Client\FactFinderNg\Api\Adapter\Http\Factory\AdapterFactory; |
|
15
|
|
|
use SprykerEco\Client\FactFinderNg\Api\Adapter\Http\Factory\AdapterFactoryInterface; |
|
16
|
|
|
use SprykerEco\Client\FactFinderNg\Api\Client\FactFinderNgHttpClient; |
|
17
|
|
|
use SprykerEco\Client\FactFinderNg\Dependency\Client\FactFinderNgToLocaleClientInterface; |
|
18
|
|
|
use SprykerEco\Client\FactFinderNg\Dependency\Client\FactFinderNgToPriceProductStorageClientInterface; |
|
19
|
|
|
use SprykerEco\Client\FactFinderNg\Dependency\Client\FactFinderNgToProductImageStorageClientInterface; |
|
20
|
|
|
use SprykerEco\Client\FactFinderNg\Dependency\Client\FactFinderNgToProductStorageClientInterface; |
|
21
|
|
|
use SprykerEco\Client\FactFinderNg\Dependency\Client\FactFinderNgToStoreClientInterface; |
|
22
|
|
|
use SprykerEco\Client\FactFinderNg\Dependency\Service\FactFinderNgToUtilEncodingServiceInterface; |
|
23
|
|
|
use SprykerEco\Client\FactFinderNg\EventTracker\CartEventTracker; |
|
24
|
|
|
use SprykerEco\Client\FactFinderNg\EventTracker\CheckoutEventTracker; |
|
25
|
|
|
use SprykerEco\Client\FactFinderNg\EventTracker\ClickEventTracker; |
|
26
|
|
|
use SprykerEco\Client\FactFinderNg\EventTracker\EventTrackerInterface; |
|
27
|
|
|
use SprykerEco\Client\FactFinderNg\Handler\FactFinderNavigationHandler; |
|
28
|
|
|
use SprykerEco\Client\FactFinderNg\Handler\FactFinderNgSearchHandler; |
|
29
|
|
|
use SprykerEco\Client\FactFinderNg\Handler\FactFinderNgSuggestHandler; |
|
30
|
|
|
use SprykerEco\Client\FactFinderNg\ImportTrigger\ImportTriggerInterface; |
|
31
|
|
|
use SprykerEco\Client\FactFinderNg\ImportTrigger\SearchImportTrigger; |
|
32
|
|
|
use SprykerEco\Client\FactFinderNg\Mapper\Elastica\FactFinderNgSearchToElasticaMapper; |
|
33
|
|
|
use SprykerEco\Client\FactFinderNg\Mapper\Elastica\FactFinderNgSuggestToElasticaMapper; |
|
34
|
|
|
use SprykerEco\Client\FactFinderNg\Mapper\Elastica\FactFinderToElasticaMapperInterface; |
|
35
|
|
|
use SprykerEco\Client\FactFinderNg\Mapper\Request\FactFinderNgRequestMapper; |
|
36
|
|
|
use SprykerEco\Client\FactFinderNg\Mapper\Request\FactFinderNgRequestMapperInterface; |
|
37
|
|
|
use SprykerEco\Client\FactFinderNg\Parser\ResponseParser; |
|
38
|
|
|
use SprykerEco\Client\FactFinderNg\Parser\ResponseParserInterface; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @method \SprykerEco\Client\FactFinderNg\FactFinderNgConfig getConfig() |
|
42
|
|
|
*/ |
|
43
|
|
|
class FactFinderNgFactory extends AbstractFactory |
|
44
|
|
|
{ |
|
45
|
|
|
/** |
|
46
|
|
|
* @return \SprykerEco\Client\FactFinderNg\Api\Adapter\Http\Factory\AdapterFactoryInterface |
|
47
|
|
|
*/ |
|
48
|
|
|
public function createAdapterFactory(): AdapterFactoryInterface |
|
49
|
|
|
{ |
|
50
|
|
|
return new AdapterFactory( |
|
51
|
|
|
$this->createFactFinderNgClient(), |
|
52
|
|
|
$this->getUtilEncodingService(), |
|
53
|
|
|
$this->getConfig() |
|
54
|
|
|
); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @return \SprykerEco\Client\FactFinderNg\Dependency\Service\FactFinderNgToUtilEncodingServiceInterface |
|
59
|
|
|
*/ |
|
60
|
|
|
public function getUtilEncodingService(): FactFinderNgToUtilEncodingServiceInterface |
|
61
|
|
|
{ |
|
62
|
|
|
return $this->getProvidedDependency(FactFinderNgDependencyProvider::SERVICE_UTIL_ENCODING); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @return \GuzzleHttp\ClientInterface |
|
67
|
|
|
*/ |
|
68
|
|
|
public function createFactFinderNgClient(): ClientInterface |
|
69
|
|
|
{ |
|
70
|
|
|
return new FactFinderNgHttpClient(); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @return \SprykerEco\Client\FactFinderNg\Mapper\Request\FactFinderNgRequestMapperInterface |
|
75
|
|
|
*/ |
|
76
|
|
|
public function createRequestMapper(): FactFinderNgRequestMapperInterface |
|
77
|
|
|
{ |
|
78
|
|
|
return new FactFinderNgRequestMapper($this->getConfig()); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @return \SprykerEco\Client\FactFinderNg\Parser\ResponseParserInterface |
|
83
|
|
|
*/ |
|
84
|
|
|
public function createResponseParser(): ResponseParserInterface |
|
85
|
|
|
{ |
|
86
|
|
|
return new ResponseParser( |
|
87
|
|
|
$this->getUtilEncodingService() |
|
88
|
|
|
); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @return \Spryker\Client\Search\Model\Handler\SearchHandlerInterface |
|
93
|
|
|
*/ |
|
94
|
|
|
public function createSearchHandler(): SearchHandlerInterface |
|
95
|
|
|
{ |
|
96
|
|
|
return new FactFinderNgSearchHandler( |
|
97
|
|
|
$this->createRequestMapper(), |
|
98
|
|
|
$this->createAdapterFactory(), |
|
99
|
|
|
$this->createResponseParser(), |
|
100
|
|
|
$this->createFactFinderNgSearchToElasticaMapper(), |
|
101
|
|
|
$this->getLocaleClient(), |
|
102
|
|
|
$this->getStoreClient(), |
|
103
|
|
|
$this->getUtilEncodingService() |
|
104
|
|
|
); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* @return \Spryker\Client\Search\Model\Handler\SearchHandlerInterface |
|
109
|
|
|
*/ |
|
110
|
|
|
public function createSuggestHandler(): SearchHandlerInterface |
|
111
|
|
|
{ |
|
112
|
|
|
return new FactFinderNgSuggestHandler( |
|
113
|
|
|
$this->createRequestMapper(), |
|
114
|
|
|
$this->createAdapterFactory(), |
|
115
|
|
|
$this->createResponseParser(), |
|
116
|
|
|
$this->createFactFinderNgSuggestToElasticaMapper(), |
|
117
|
|
|
$this->getLocaleClient(), |
|
118
|
|
|
$this->getStoreClient(), |
|
119
|
|
|
$this->getUtilEncodingService() |
|
120
|
|
|
); |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* @return \Spryker\Client\Search\Model\Handler\SearchHandlerInterface |
|
125
|
|
|
*/ |
|
126
|
|
|
public function createNavigationHandler(): SearchHandlerInterface |
|
127
|
|
|
{ |
|
128
|
|
|
return new FactFinderNavigationHandler( |
|
129
|
|
|
$this->createRequestMapper(), |
|
130
|
|
|
$this->createAdapterFactory(), |
|
131
|
|
|
$this->createResponseParser(), |
|
132
|
|
|
$this->createFactFinderNgSearchToElasticaMapper(), |
|
133
|
|
|
$this->getLocaleClient(), |
|
134
|
|
|
$this->getStoreClient(), |
|
135
|
|
|
$this->getUtilEncodingService() |
|
136
|
|
|
); |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* @return \SprykerEco\Client\FactFinderNg\Mapper\Elastica\FactFinderToElasticaMapperInterface |
|
141
|
|
|
*/ |
|
142
|
|
|
public function createFactFinderNgSearchToElasticaMapper(): FactFinderToElasticaMapperInterface |
|
143
|
|
|
{ |
|
144
|
|
|
return new FactFinderNgSearchToElasticaMapper( |
|
145
|
|
|
$this->createElasticaDefaultBuilder(), |
|
146
|
|
|
$this->getProductStorageClient(), |
|
147
|
|
|
$this->getProductImageStorageClient(), |
|
148
|
|
|
$this->getPriceProductStorageClient() |
|
149
|
|
|
); |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
/** |
|
153
|
|
|
* @return \SprykerEco\Client\FactFinderNg\Mapper\Elastica\FactFinderToElasticaMapperInterface |
|
154
|
|
|
*/ |
|
155
|
|
|
public function createFactFinderNgSuggestToElasticaMapper(): FactFinderToElasticaMapperInterface |
|
156
|
|
|
{ |
|
157
|
|
|
return new FactFinderNgSuggestToElasticaMapper( |
|
158
|
|
|
$this->createElasticaDefaultBuilder(), |
|
159
|
|
|
$this->getProductStorageClient(), |
|
160
|
|
|
$this->getProductImageStorageClient(), |
|
161
|
|
|
$this->getPriceProductStorageClient() |
|
162
|
|
|
); |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
/** |
|
166
|
|
|
* @return \Elastica\ResultSet\DefaultBuilder |
|
167
|
|
|
*/ |
|
168
|
|
|
public function createElasticaDefaultBuilder(): DefaultBuilder |
|
169
|
|
|
{ |
|
170
|
|
|
return new DefaultBuilder(); |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
/** |
|
174
|
|
|
* @return \SprykerEco\Client\FactFinderNg\Dependency\Client\FactFinderNgToProductStorageClientInterface |
|
175
|
|
|
*/ |
|
176
|
|
|
public function getProductStorageClient(): FactFinderNgToProductStorageClientInterface |
|
177
|
|
|
{ |
|
178
|
|
|
return $this->getProvidedDependency(FactFinderNgDependencyProvider::CLIENT_PRODUCT_STORAGE); |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
/** |
|
182
|
|
|
* @return \SprykerEco\Client\FactFinderNg\Dependency\Client\FactFinderNgToProductImageStorageClientInterface |
|
183
|
|
|
*/ |
|
184
|
|
|
public function getProductImageStorageClient(): FactFinderNgToProductImageStorageClientInterface |
|
185
|
|
|
{ |
|
186
|
|
|
return $this->getProvidedDependency(FactFinderNgDependencyProvider::CLIENT_PRODUCT_IMAGE_STORAGE); |
|
187
|
|
|
} |
|
188
|
|
|
|
|
189
|
|
|
/** |
|
190
|
|
|
* @return \SprykerEco\Client\FactFinderNg\Dependency\Client\FactFinderNgToPriceProductStorageClientInterface |
|
191
|
|
|
*/ |
|
192
|
|
|
public function getPriceProductStorageClient(): FactFinderNgToPriceProductStorageClientInterface |
|
193
|
|
|
{ |
|
194
|
|
|
return $this->getProvidedDependency(FactFinderNgDependencyProvider::CLIENT_PRICE_PRODUCT_STORAGE); |
|
195
|
|
|
} |
|
196
|
|
|
|
|
197
|
|
|
/** |
|
198
|
|
|
* @return \SprykerEco\Client\FactFinderNg\Dependency\Client\FactFinderNgToLocaleClientInterface |
|
199
|
|
|
*/ |
|
200
|
|
|
public function getLocaleClient(): FactFinderNgToLocaleClientInterface |
|
201
|
|
|
{ |
|
202
|
|
|
return $this->getProvidedDependency(FactFinderNgDependencyProvider::CLIENT_LOCALE); |
|
203
|
|
|
} |
|
204
|
|
|
|
|
205
|
|
|
/** |
|
206
|
|
|
* @return \SprykerEco\Client\FactFinderNg\Dependency\Client\FactFinderNgToStoreClientInterface |
|
207
|
|
|
*/ |
|
208
|
|
|
public function getStoreClient(): FactFinderNgToStoreClientInterface |
|
209
|
|
|
{ |
|
210
|
|
|
return $this->getProvidedDependency(FactFinderNgDependencyProvider::CLIENT_STORE); |
|
211
|
|
|
} |
|
212
|
|
|
|
|
213
|
|
|
/** |
|
214
|
|
|
* @return \SprykerEco\Client\FactFinderNg\ImportTrigger\ImportTriggerInterface |
|
215
|
|
|
*/ |
|
216
|
|
|
public function createSearchImportTrigger(): ImportTriggerInterface |
|
217
|
|
|
{ |
|
218
|
|
|
return new SearchImportTrigger( |
|
219
|
|
|
$this->createRequestMapper(), |
|
220
|
|
|
$this->createResponseParser(), |
|
221
|
|
|
$this->createAdapterFactory() |
|
222
|
|
|
); |
|
223
|
|
|
} |
|
224
|
|
|
|
|
225
|
|
|
/** |
|
226
|
|
|
* @return \SprykerEco\Client\FactFinderNg\EventTracker\EventTrackerInterface |
|
227
|
|
|
*/ |
|
228
|
|
|
public function createCheckoutEventTracker(): EventTrackerInterface |
|
229
|
|
|
{ |
|
230
|
|
|
return new CheckoutEventTracker( |
|
231
|
|
|
$this->createRequestMapper(), |
|
232
|
|
|
$this->createAdapterFactory(), |
|
233
|
|
|
$this->createResponseParser() |
|
234
|
|
|
); |
|
235
|
|
|
} |
|
236
|
|
|
|
|
237
|
|
|
/** |
|
238
|
|
|
* @return \SprykerEco\Client\FactFinderNg\EventTracker\EventTrackerInterface |
|
239
|
|
|
*/ |
|
240
|
|
|
public function createCartEventTracker(): EventTrackerInterface |
|
241
|
|
|
{ |
|
242
|
|
|
return new CartEventTracker( |
|
243
|
|
|
$this->createRequestMapper(), |
|
244
|
|
|
$this->createAdapterFactory(), |
|
245
|
|
|
$this->createResponseParser() |
|
246
|
|
|
); |
|
247
|
|
|
} |
|
248
|
|
|
|
|
249
|
|
|
/** |
|
250
|
|
|
* @return \SprykerEco\Client\FactFinderNg\EventTracker\EventTrackerInterface |
|
251
|
|
|
*/ |
|
252
|
|
|
public function createClickEventTracker(): EventTrackerInterface |
|
253
|
|
|
{ |
|
254
|
|
|
return new ClickEventTracker( |
|
255
|
|
|
$this->createRequestMapper(), |
|
256
|
|
|
$this->createAdapterFactory(), |
|
257
|
|
|
$this->createResponseParser() |
|
258
|
|
|
); |
|
259
|
|
|
} |
|
260
|
|
|
} |
|
261
|
|
|
|