|
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\AbstractController; |
|
15
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Aimeos controller for catalog related functionality. |
|
19
|
|
|
* |
|
20
|
|
|
* @package symfony |
|
21
|
|
|
* @subpackage Controller |
|
22
|
|
|
*/ |
|
23
|
|
|
class CatalogController extends AbstractController |
|
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( \Twig\Environment $twig ) : 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 )->header(); |
|
38
|
|
|
$params['aibody'][$name] = $shop->get( $name )->body(); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
return new Response( |
|
42
|
|
|
$twig->render( '@AimeosShop/Catalog/count.html.twig', $params ), |
|
43
|
|
|
200, [ |
|
44
|
|
|
'Content-Type' => 'application/javascript', |
|
45
|
|
|
'Cache-Control' => 'public, max-age=300' |
|
46
|
|
|
] |
|
47
|
|
|
); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Returns the html for the catalog detail page. |
|
53
|
|
|
* |
|
54
|
|
|
* @return Response Response object containing the generated output |
|
55
|
|
|
*/ |
|
56
|
|
|
public function detailAction( \Twig\Environment $twig ) : Response |
|
57
|
|
|
{ |
|
58
|
|
|
$params = []; |
|
59
|
|
|
$shop = $this->container->get( 'shop' ); |
|
60
|
|
|
|
|
61
|
|
|
foreach( $this->container->getParameter( 'aimeos_shop.page' )['catalog-detail'] as $name ) |
|
62
|
|
|
{ |
|
63
|
|
|
$params['aiheader'][$name] = $shop->get( $name )->header(); |
|
64
|
|
|
$params['aibody'][$name] = $shop->get( $name )->body(); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
return new Response( |
|
68
|
|
|
$twig->render( '@AimeosShop/Catalog/detail.html.twig', $params ), |
|
69
|
|
|
200, ['Cache-Control' => 'private, max-age=10'] |
|
70
|
|
|
); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Returns the html for the catalog list page. |
|
76
|
|
|
* |
|
77
|
|
|
* @return Response Response object containing the generated output |
|
78
|
|
|
*/ |
|
79
|
|
|
public function listAction( \Twig\Environment $twig ) : Response |
|
80
|
|
|
{ |
|
81
|
|
|
$params = []; |
|
82
|
|
|
$shop = $this->container->get( 'shop' ); |
|
83
|
|
|
|
|
84
|
|
|
foreach( $this->container->getParameter( 'aimeos_shop.page' )['catalog-list'] as $name ) |
|
85
|
|
|
{ |
|
86
|
|
|
$params['aiheader'][$name] = $shop->get( $name )->header(); |
|
87
|
|
|
$params['aibody'][$name] = $shop->get( $name )->body(); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
return new Response( |
|
91
|
|
|
$twig->render( '@AimeosShop/Catalog/list.html.twig', $params ), |
|
92
|
|
|
200, ['Cache-Control' => 'private, max-age=10'] |
|
93
|
|
|
); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* Returns the html for the catalog home page. |
|
99
|
|
|
* |
|
100
|
|
|
* @return Response Response object containing the generated output |
|
101
|
|
|
*/ |
|
102
|
|
|
public function homeAction( \Twig\Environment $twig ) : Response |
|
103
|
|
|
{ |
|
104
|
|
|
$params = []; |
|
105
|
|
|
$shop = $this->container->get( 'shop' ); |
|
106
|
|
|
|
|
107
|
|
|
foreach( $this->container->getParameter( 'aimeos_shop.page' )['catalog-home'] as $name ) |
|
108
|
|
|
{ |
|
109
|
|
|
$params['aiheader'][$name] = $shop->get( $name )->header(); |
|
110
|
|
|
$params['aibody'][$name] = $shop->get( $name )->body(); |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
return new Response( |
|
114
|
|
|
$twig->render( '@AimeosShop/Catalog/home.html.twig', $params ), |
|
115
|
|
|
200, ['Cache-Control' => 'private, max-age=10'] |
|
116
|
|
|
); |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
|
|
120
|
|
|
/** |
|
121
|
|
|
* Returns the html for the catalog tree page. |
|
122
|
|
|
* |
|
123
|
|
|
* @return Response Response object containing the generated output |
|
124
|
|
|
*/ |
|
125
|
|
|
public function treeAction( \Twig\Environment $twig ) : Response |
|
126
|
|
|
{ |
|
127
|
|
|
$params = []; |
|
128
|
|
|
$shop = $this->container->get( 'shop' ); |
|
129
|
|
|
|
|
130
|
|
|
foreach( $this->container->getParameter( 'aimeos_shop.page' )['catalog-tree'] as $name ) |
|
131
|
|
|
{ |
|
132
|
|
|
$params['aiheader'][$name] = $shop->get( $name )->header(); |
|
133
|
|
|
$params['aibody'][$name] = $shop->get( $name )->body(); |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
return new Response( |
|
137
|
|
|
$twig->render( '@AimeosShop/Catalog/tree.html.twig', $params ), |
|
138
|
|
|
200, ['Cache-Control' => 'private, max-age=10'] |
|
139
|
|
|
); |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* Returns the html body part for the catalog session page. |
|
145
|
|
|
* |
|
146
|
|
|
* @return Response Response object containing the generated output |
|
147
|
|
|
*/ |
|
148
|
|
|
public function sessionAction( \Twig\Environment $twig ) : Response |
|
149
|
|
|
{ |
|
150
|
|
|
$params = []; |
|
151
|
|
|
$shop = $this->container->get( 'shop' ); |
|
152
|
|
|
|
|
153
|
|
|
foreach( $this->container->getParameter( 'aimeos_shop.page' )['catalog-session'] as $name ) |
|
154
|
|
|
{ |
|
155
|
|
|
$params['aiheader'][$name] = $shop->get( $name )->header(); |
|
156
|
|
|
$params['aibody'][$name] = $shop->get( $name )->body(); |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
return new Response( |
|
160
|
|
|
$twig->render( '@AimeosShop/Catalog/session.html.twig', $params ), |
|
161
|
|
|
200, ['Cache-Control' => 'private, max-age=10'] |
|
162
|
|
|
); |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
|
|
166
|
|
|
/** |
|
167
|
|
|
* Returns the html body part for the catalog stock page. |
|
168
|
|
|
* |
|
169
|
|
|
* @return Response Response object containing the generated output |
|
170
|
|
|
*/ |
|
171
|
|
|
public function stockAction( \Twig\Environment $twig ) : Response |
|
172
|
|
|
{ |
|
173
|
|
|
$params = []; |
|
174
|
|
|
$shop = $this->container->get( 'shop' ); |
|
175
|
|
|
|
|
176
|
|
|
foreach( $this->container->getParameter( 'aimeos_shop.page' )['catalog-stock'] as $name ) |
|
177
|
|
|
{ |
|
178
|
|
|
$params['aiheader'][$name] = $shop->get( $name )->header(); |
|
179
|
|
|
$params['aibody'][$name] = $shop->get( $name )->body(); |
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
|
|
return new Response( |
|
183
|
|
|
$twig->render( '@AimeosShop/Catalog/stock.html.twig', $params ), |
|
184
|
|
|
200, ['Cache-Control' => 'public, max-age=30'] |
|
185
|
|
|
); |
|
186
|
|
|
} |
|
187
|
|
|
|
|
188
|
|
|
|
|
189
|
|
|
/** |
|
190
|
|
|
* Returns the view for the XHR response with the product information for the search suggestion. |
|
191
|
|
|
* |
|
192
|
|
|
* @return Response Response object containing the generated output |
|
193
|
|
|
*/ |
|
194
|
|
|
public function suggestAction( \Twig\Environment $twig ) : Response |
|
195
|
|
|
{ |
|
196
|
|
|
$params = []; |
|
197
|
|
|
$shop = $this->container->get( 'shop' ); |
|
198
|
|
|
|
|
199
|
|
|
foreach( $this->container->getParameter( 'aimeos_shop.page' )['catalog-suggest'] as $name ) |
|
200
|
|
|
{ |
|
201
|
|
|
$params['aiheader'][$name] = $shop->get( $name )->header(); |
|
202
|
|
|
$params['aibody'][$name] = $shop->get( $name )->body(); |
|
203
|
|
|
} |
|
204
|
|
|
|
|
205
|
|
|
return new Response( |
|
206
|
|
|
$twig->render( '@AimeosShop/Catalog/suggest.html.twig', $params ), |
|
207
|
|
|
200, [ |
|
208
|
|
|
'Content-Type' => 'application/json', |
|
209
|
|
|
'Cache-Control' => 'private, max-age=300' |
|
210
|
|
|
] |
|
211
|
|
|
); |
|
212
|
|
|
} |
|
213
|
|
|
} |
|
214
|
|
|
|