Passed
Push — master ( 47e71f...6544b6 )
by Aimeos
05:03
created

CatalogController::treeAction()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 8
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 14
rs 10
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
	 * Returns the output of the catalog count component
206
	 *
207
	 * @return Response Response object containing the generated output
208
	 */
209
	public function countComponentAction() : Response
210
	{
211
		$client = $this->container->get( 'shop' )->get( 'catalog/count' );
212
		$this->container->get( 'twig' )->addGlobal( 'aiheader', (string) $client->getHeader() );
213
214
		return new Response( (string) $client->getBody() );
215
	}
216
217
218
	/**
219
	 * Returns the output of the catalog detail component
220
	 *
221
	 * @return Response Response object containing the generated output
222
	 */
223
	public function detailComponentAction() : Response
224
	{
225
		$client = $this->container->get( 'shop' )->get( 'catalog/detail' );
226
		$this->container->get( 'twig' )->addGlobal( 'aiheader', (string) $client->getHeader() );
227
228
		return new Response( (string) $client->getBody() );
229
	}
230
231
232
	/**
233
	 * Returns the output of the catalog filter component
234
	 *
235
	 * @return Response Response object containing the generated output
236
	 */
237
	public function filterComponentAction() : Response
238
	{
239
		$client = $this->container->get( 'shop' )->get( 'catalog/filter' );
240
		$this->container->get( 'twig' )->addGlobal( 'aiheader', (string) $client->getHeader() );
241
242
		return new Response( (string) $client->getBody() );
243
	}
244
245
246
	/**
247
	 * Returns the output of the catalog home component
248
	 *
249
	 * @return Response Response object containing the generated output
250
	 */
251
	public function homeComponentAction() : Response
252
	{
253
		$client = $this->container->get( 'shop' )->get( 'catalog/home' );
254
		$this->container->get( 'twig' )->addGlobal( 'aiheader', (string) $client->getHeader() );
255
256
		return new Response( (string) $client->getBody() );
257
	}
258
259
260
	/**
261
	 * Returns the output of the catalog list component
262
	 *
263
	 * @return Response Response object containing the generated output
264
	 */
265
	public function listComponentAction() : Response
266
	{
267
		$client = $this->container->get( 'shop' )->get( 'catalog/lists' );
268
		$this->container->get( 'twig' )->addGlobal( 'aiheader', (string) $client->getHeader() );
269
270
		return new Response( (string) $client->getBody() );
271
	}
272
273
274
	/**
275
	 * Returns the output of the catalog session component
276
	 *
277
	 * @return Response Response object containing the generated output
278
	 */
279
	public function sessionComponentAction() : Response
280
	{
281
		$client = $this->container->get( 'shop' )->get( 'catalog/session' );
282
		$this->container->get( 'twig' )->addGlobal( 'aiheader', (string) $client->getHeader() );
283
284
		return new Response( (string) $client->getBody() );
285
	}
286
287
288
	/**
289
	 * Returns the output of the catalog stage component
290
	 *
291
	 * @return Response Response object containing the generated output
292
	 */
293
	public function stageComponentAction() : Response
294
	{
295
		$client = $this->container->get( 'shop' )->get( 'catalog/stage' );
296
		$this->container->get( 'twig' )->addGlobal( 'aiheader', (string) $client->getHeader() );
297
298
		return new Response( (string) $client->getBody() );
299
	}
300
301
302
	/**
303
	 * Returns the output of the catalog stock component
304
	 *
305
	 * @return Response Response object containing the generated output
306
	 */
307
	public function stockComponentAction() : Response
308
	{
309
		$client = $this->container->get( 'shop' )->get( 'catalog/stock' );
310
		$this->container->get( 'twig' )->addGlobal( 'aiheader', (string) $client->getHeader() );
311
312
		return new Response( (string) $client->getBody() );
313
	}
314
315
316
	/**
317
	 * Returns the output of the catalog suggest component
318
	 *
319
	 * @return Response Response object containing the generated output
320
	 */
321
	public function suggestComponentAction() : Response
322
	{
323
		$client = $this->container->get( 'shop' )->get( 'catalog/suggest' );
324
		$this->container->get( 'twig' )->addGlobal( 'aiheader', (string) $client->getHeader() );
325
326
		return new Response( (string) $client->getBody() );
327
	}
328
}
329