1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license MIT, http://opensource.org/licenses/MIT |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2014-2016 |
6
|
|
|
* @package symfony |
7
|
|
|
* @subpackage Controller |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace Aimeos\ShopBundle\Controller; |
12
|
|
|
|
13
|
|
|
use Symfony\Component\HttpFoundation\Response; |
14
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
15
|
|
|
|
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Aimeos controller for catalog related functionality. |
19
|
|
|
* |
20
|
|
|
* @package symfony |
21
|
|
|
* @subpackage Controller |
22
|
|
|
*/ |
23
|
|
|
class CatalogController extends Controller |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* Returns the view for the XHR response with the counts for the facetted search. |
27
|
|
|
* |
28
|
|
|
* @return Response Response object containing the generated output |
29
|
|
|
*/ |
30
|
|
|
public function countAction() : Response |
31
|
|
|
{ |
32
|
|
|
$params = []; |
33
|
|
|
$shop = $this->container->get( 'shop' ); |
34
|
|
|
|
35
|
|
|
foreach( $this->container->getParameter( 'aimeos_shop.page' )['catalog-count'] as $name ) |
36
|
|
|
{ |
37
|
|
|
$params['aiheader'][$name] = $shop->get( $name )->getHeader(); |
38
|
|
|
$params['aibody'][$name] = $shop->get( $name )->getBody(); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
$response = $this->render( '@AimeosShop/Catalog/count.html.twig', $params ); |
42
|
|
|
$response->headers->set( 'Content-Type', 'application/javascript' ); |
43
|
|
|
$response->headers->set( 'Cache-Control', 'public, max-age=300' ); |
44
|
|
|
return $response; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Returns the html for the catalog detail page. |
50
|
|
|
* |
51
|
|
|
* @return Response Response object containing the generated output |
52
|
|
|
*/ |
53
|
|
|
public function detailAction() : Response |
54
|
|
|
{ |
55
|
|
|
$params = []; |
56
|
|
|
$shop = $this->container->get( 'shop' ); |
57
|
|
|
|
58
|
|
|
foreach( $this->container->getParameter( 'aimeos_shop.page' )['catalog-detail'] as $name ) |
59
|
|
|
{ |
60
|
|
|
$params['aiheader'][$name] = $shop->get( $name )->getHeader(); |
61
|
|
|
$params['aibody'][$name] = $shop->get( $name )->getBody(); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
$response = $this->render( '@AimeosShop/Catalog/detail.html.twig', $params ); |
65
|
|
|
$response->headers->set( 'Cache-Control', 'private, max-age=10' ); |
66
|
|
|
return $response; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Returns the html for the catalog list page. |
72
|
|
|
* |
73
|
|
|
* @return Response Response object containing the generated output |
74
|
|
|
*/ |
75
|
|
|
public function listAction() : Response |
76
|
|
|
{ |
77
|
|
|
$params = []; |
78
|
|
|
$shop = $this->container->get( 'shop' ); |
79
|
|
|
|
80
|
|
|
foreach( $this->container->getParameter( 'aimeos_shop.page' )['catalog-list'] as $name ) |
81
|
|
|
{ |
82
|
|
|
$params['aiheader'][$name] = $shop->get( $name )->getHeader(); |
83
|
|
|
$params['aibody'][$name] = $shop->get( $name )->getBody(); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
$response = $this->render( '@AimeosShop/Catalog/list.html.twig', $params ); |
87
|
|
|
$response->headers->set( 'Cache-Control', 'private, max-age=10' ); |
88
|
|
|
return $response; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Returns the html for the catalog home page. |
94
|
|
|
* |
95
|
|
|
* @return Response Response object containing the generated output |
96
|
|
|
*/ |
97
|
|
|
public function homeAction() : Response |
98
|
|
|
{ |
99
|
|
|
$params = []; |
100
|
|
|
$shop = $this->container->get( 'shop' ); |
101
|
|
|
|
102
|
|
|
foreach( $this->container->getParameter( 'aimeos_shop.page' )['catalog-home'] as $name ) |
103
|
|
|
{ |
104
|
|
|
$params['aiheader'][$name] = $shop->get( $name )->getHeader(); |
105
|
|
|
$params['aibody'][$name] = $shop->get( $name )->getBody(); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
$response = $this->render( '@AimeosShop/Catalog/home.html.twig', $params ); |
109
|
|
|
$response->headers->set( 'Cache-Control', 'private, max-age=10' ); |
110
|
|
|
return $response; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Returns the html for the catalog tree page. |
116
|
|
|
* |
117
|
|
|
* @return Response Response object containing the generated output |
118
|
|
|
*/ |
119
|
|
|
public function treeAction() : Response |
120
|
|
|
{ |
121
|
|
|
$params = []; |
122
|
|
|
$shop = $this->container->get( 'shop' ); |
123
|
|
|
|
124
|
|
|
foreach( $this->container->getParameter( 'aimeos_shop.page' )['catalog-tree'] as $name ) |
125
|
|
|
{ |
126
|
|
|
$params['aiheader'][$name] = $shop->get( $name )->getHeader(); |
127
|
|
|
$params['aibody'][$name] = $shop->get( $name )->getBody(); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
$response = $this->render( '@AimeosShop/Catalog/tree.html.twig', $params ); |
131
|
|
|
$response->headers->set( 'Cache-Control', 'private, max-age=10' ); |
132
|
|
|
return $response; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* Returns the html body part for the catalog stock page. |
138
|
|
|
* |
139
|
|
|
* @return Response Response object containing the generated output |
140
|
|
|
*/ |
141
|
|
|
public function stockAction() : Response |
142
|
|
|
{ |
143
|
|
|
$params = []; |
144
|
|
|
$shop = $this->container->get( 'shop' ); |
145
|
|
|
|
146
|
|
|
foreach( $this->container->getParameter( 'aimeos_shop.page' )['catalog-stock'] as $name ) |
147
|
|
|
{ |
148
|
|
|
$params['aiheader'][$name] = $shop->get( $name )->getHeader(); |
149
|
|
|
$params['aibody'][$name] = $shop->get( $name )->getBody(); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
$response = $this->render( '@AimeosShop/Catalog/stock.html.twig', $params ); |
153
|
|
|
$response->headers->set( 'Content-Type', 'application/javascript' ); |
154
|
|
|
$response->headers->set( 'Cache-Control', 'public, max-age=30' ); |
155
|
|
|
return $response; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* Returns the view for the XHR response with the product information for the search suggestion. |
161
|
|
|
* |
162
|
|
|
* @return Response Response object containing the generated output |
163
|
|
|
*/ |
164
|
|
|
public function suggestAction() : Response |
165
|
|
|
{ |
166
|
|
|
$params = []; |
167
|
|
|
$shop = $this->container->get( 'shop' ); |
168
|
|
|
|
169
|
|
|
foreach( $this->container->getParameter( 'aimeos_shop.page' )['catalog-suggest'] as $name ) |
170
|
|
|
{ |
171
|
|
|
$params['aiheader'][$name] = $shop->get( $name )->getHeader(); |
172
|
|
|
$params['aibody'][$name] = $shop->get( $name )->getBody(); |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
$response = $this->render( '@AimeosShop/Catalog/suggest.html.twig', $params ); |
176
|
|
|
$response->headers->set( 'Cache-Control', 'private, max-age=300' ); |
177
|
|
|
$response->headers->set( 'Content-Type', 'application/json' ); |
178
|
|
|
return $response; |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* Returns the output of the catalog count component |
184
|
|
|
* |
185
|
|
|
* @return Response Response object containing the generated output |
186
|
|
|
*/ |
187
|
|
|
public function countComponentAction() : Response |
188
|
|
|
{ |
189
|
|
|
$client = $this->container->get( 'shop' )->get( 'catalog/count' ); |
190
|
|
|
$this->container->get( 'twig' )->addGlobal( 'aiheader', (string) $client->getHeader() ); |
191
|
|
|
|
192
|
|
|
return new Response( (string) $client->getBody() ); |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* Returns the output of the catalog detail component |
198
|
|
|
* |
199
|
|
|
* @return Response Response object containing the generated output |
200
|
|
|
*/ |
201
|
|
|
public function detailComponentAction() : Response |
202
|
|
|
{ |
203
|
|
|
$client = $this->container->get( 'shop' )->get( 'catalog/detail' ); |
204
|
|
|
$this->container->get( 'twig' )->addGlobal( 'aiheader', (string) $client->getHeader() ); |
205
|
|
|
|
206
|
|
|
return new Response( (string) $client->getBody() ); |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
|
210
|
|
|
/** |
211
|
|
|
* Returns the output of the catalog filter component |
212
|
|
|
* |
213
|
|
|
* @return Response Response object containing the generated output |
214
|
|
|
*/ |
215
|
|
|
public function filterComponentAction() : Response |
216
|
|
|
{ |
217
|
|
|
$client = $this->container->get( 'shop' )->get( 'catalog/filter' ); |
218
|
|
|
$this->container->get( 'twig' )->addGlobal( 'aiheader', (string) $client->getHeader() ); |
219
|
|
|
|
220
|
|
|
return new Response( (string) $client->getBody() ); |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
|
224
|
|
|
/** |
225
|
|
|
* Returns the output of the catalog home component |
226
|
|
|
* |
227
|
|
|
* @return Response Response object containing the generated output |
228
|
|
|
*/ |
229
|
|
|
public function homeComponentAction() : Response |
230
|
|
|
{ |
231
|
|
|
$client = $this->container->get( 'shop' )->get( 'catalog/home' ); |
232
|
|
|
$this->container->get( 'twig' )->addGlobal( 'aiheader', (string) $client->getHeader() ); |
233
|
|
|
|
234
|
|
|
return new Response( (string) $client->getBody() ); |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
|
238
|
|
|
/** |
239
|
|
|
* Returns the output of the catalog list component |
240
|
|
|
* |
241
|
|
|
* @return Response Response object containing the generated output |
242
|
|
|
*/ |
243
|
|
|
public function listComponentAction() : Response |
244
|
|
|
{ |
245
|
|
|
$client = $this->container->get( 'shop' )->get( 'catalog/lists' ); |
246
|
|
|
$this->container->get( 'twig' )->addGlobal( 'aiheader', (string) $client->getHeader() ); |
247
|
|
|
|
248
|
|
|
return new Response( (string) $client->getBody() ); |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
|
252
|
|
|
/** |
253
|
|
|
* Returns the output of the catalog session component |
254
|
|
|
* |
255
|
|
|
* @return Response Response object containing the generated output |
256
|
|
|
*/ |
257
|
|
|
public function sessionComponentAction() : Response |
258
|
|
|
{ |
259
|
|
|
$client = $this->container->get( 'shop' )->get( 'catalog/session' ); |
260
|
|
|
$this->container->get( 'twig' )->addGlobal( 'aiheader', (string) $client->getHeader() ); |
261
|
|
|
|
262
|
|
|
return new Response( (string) $client->getBody() ); |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
|
266
|
|
|
/** |
267
|
|
|
* Returns the output of the catalog stage component |
268
|
|
|
* |
269
|
|
|
* @return Response Response object containing the generated output |
270
|
|
|
*/ |
271
|
|
|
public function stageComponentAction() : Response |
272
|
|
|
{ |
273
|
|
|
$client = $this->container->get( 'shop' )->get( 'catalog/stage' ); |
274
|
|
|
$this->container->get( 'twig' )->addGlobal( 'aiheader', (string) $client->getHeader() ); |
275
|
|
|
|
276
|
|
|
return new Response( (string) $client->getBody() ); |
277
|
|
|
} |
278
|
|
|
|
279
|
|
|
|
280
|
|
|
/** |
281
|
|
|
* Returns the output of the catalog stock component |
282
|
|
|
* |
283
|
|
|
* @return Response Response object containing the generated output |
284
|
|
|
*/ |
285
|
|
|
public function stockComponentAction() : Response |
286
|
|
|
{ |
287
|
|
|
$client = $this->container->get( 'shop' )->get( 'catalog/stock' ); |
288
|
|
|
$this->container->get( 'twig' )->addGlobal( 'aiheader', (string) $client->getHeader() ); |
289
|
|
|
|
290
|
|
|
return new Response( (string) $client->getBody() ); |
291
|
|
|
} |
292
|
|
|
|
293
|
|
|
|
294
|
|
|
/** |
295
|
|
|
* Returns the output of the catalog suggest component |
296
|
|
|
* |
297
|
|
|
* @return Response Response object containing the generated output |
298
|
|
|
*/ |
299
|
|
|
public function suggestComponentAction() : Response |
300
|
|
|
{ |
301
|
|
|
$client = $this->container->get( 'shop' )->get( 'catalog/suggest' ); |
302
|
|
|
$this->container->get( 'twig' )->addGlobal( 'aiheader', (string) $client->getHeader() ); |
303
|
|
|
|
304
|
|
|
return new Response( (string) $client->getBody() ); |
305
|
|
|
} |
306
|
|
|
} |
307
|
|
|
|