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 session page. |
138
|
|
|
* |
139
|
|
|
* @return Response Response object containing the generated output |
140
|
|
|
*/ |
141
|
|
|
public function sessionAction() : Response |
142
|
|
|
{ |
143
|
|
|
$params = []; |
144
|
|
|
$shop = $this->container->get( 'shop' ); |
145
|
|
|
|
146
|
|
|
foreach( $this->container->getParameter( 'aimeos_shop.page' )['catalog-session'] 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/session.html.twig', $params ); |
153
|
|
|
$response->headers->set( 'Cache-Control', 'private, max-age=10' ); |
154
|
|
|
return $response; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* Returns the html body part for the catalog stock page. |
160
|
|
|
* |
161
|
|
|
* @return Response Response object containing the generated output |
162
|
|
|
*/ |
163
|
|
|
public function stockAction() : Response |
164
|
|
|
{ |
165
|
|
|
$params = []; |
166
|
|
|
$shop = $this->container->get( 'shop' ); |
167
|
|
|
|
168
|
|
|
foreach( $this->container->getParameter( 'aimeos_shop.page' )['catalog-stock'] as $name ) |
169
|
|
|
{ |
170
|
|
|
$params['aiheader'][$name] = $shop->get( $name )->getHeader(); |
171
|
|
|
$params['aibody'][$name] = $shop->get( $name )->getBody(); |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
$response = $this->render( '@AimeosShop/Catalog/stock.html.twig', $params ); |
175
|
|
|
$response->headers->set( 'Content-Type', 'application/javascript' ); |
176
|
|
|
$response->headers->set( 'Cache-Control', 'public, max-age=30' ); |
177
|
|
|
return $response; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* Returns the view for the XHR response with the product information for the search suggestion. |
183
|
|
|
* |
184
|
|
|
* @return Response Response object containing the generated output |
185
|
|
|
*/ |
186
|
|
|
public function suggestAction() : Response |
187
|
|
|
{ |
188
|
|
|
$params = []; |
189
|
|
|
$shop = $this->container->get( 'shop' ); |
190
|
|
|
|
191
|
|
|
foreach( $this->container->getParameter( 'aimeos_shop.page' )['catalog-suggest'] as $name ) |
192
|
|
|
{ |
193
|
|
|
$params['aiheader'][$name] = $shop->get( $name )->getHeader(); |
194
|
|
|
$params['aibody'][$name] = $shop->get( $name )->getBody(); |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
$response = $this->render( '@AimeosShop/Catalog/suggest.html.twig', $params ); |
198
|
|
|
$response->headers->set( 'Cache-Control', 'private, max-age=300' ); |
199
|
|
|
$response->headers->set( 'Content-Type', 'application/json' ); |
200
|
|
|
return $response; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
|
204
|
|
|
} |
205
|
|
|
|