1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2016 |
6
|
|
|
* @package Slim |
7
|
|
|
* @subpackage Controller |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Aimeos\Slim\Controller; |
11
|
|
|
|
12
|
|
|
use Psr\Container\ContainerInterface; |
13
|
|
|
use Psr\Http\Message\ServerRequestInterface; |
14
|
|
|
use Psr\Http\Message\ResponseInterface; |
15
|
|
|
|
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Aimeos controller for catalog related functionality. |
19
|
|
|
* |
20
|
|
|
* @package Slim |
21
|
|
|
* @subpackage Controller |
22
|
|
|
*/ |
23
|
|
|
class Catalog |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* Returns the view for the XHR response with the counts for the facetted search. |
27
|
|
|
* |
28
|
|
|
* @param ContainerInterface $container Dependency injection container |
29
|
|
|
* @param ServerRequestInterface $request Request object |
30
|
|
|
* @param ResponseInterface $response Response object |
31
|
|
|
* @param array $args Associative list of route parameters |
32
|
|
|
* @return ResponseInterface $response Modified response object with generated output |
33
|
|
|
*/ |
34
|
|
|
public static function countAction( ContainerInterface $container, ServerRequestInterface $request, |
35
|
|
|
ResponseInterface $response, array $args ) : ResponseInterface |
36
|
|
|
{ |
37
|
|
|
$contents = $container->get( 'shop' )->get( 'catalog-count', $request, $response, $args ); |
38
|
|
|
$response = $container->get( 'view' )->render( $response, 'Catalog/count.html.twig', $contents ); |
39
|
|
|
|
40
|
|
|
return $response->withHeader( 'Content-Type', 'application/javascript' ) |
41
|
|
|
->withHeader( 'Cache-Control', 'max-age=300' ); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Returns the html for the catalog detail page. |
47
|
|
|
* |
48
|
|
|
* @param ContainerInterface $container Dependency injection container |
49
|
|
|
* @param ServerRequestInterface $request Request object |
50
|
|
|
* @param ResponseInterface $response Response object |
51
|
|
|
* @param array $args Associative list of route parameters |
52
|
|
|
* @return ResponseInterface $response Modified response object with generated output |
53
|
|
|
*/ |
54
|
|
|
public static function detailAction( ContainerInterface $container, ServerRequestInterface $request, |
55
|
|
|
ResponseInterface $response, array $args ) : ResponseInterface |
56
|
|
|
{ |
57
|
|
|
$contents = $container->get( 'shop' )->get( 'catalog-detail', $request, $response, $args ); |
58
|
|
|
return $container->get( 'view' )->render( $response, 'Catalog/detail.html.twig', $contents ) |
59
|
|
|
->withHeader( 'Cache-Control', 'max-age=3600' ); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Returns the html for the catalog list page. |
65
|
|
|
* |
66
|
|
|
* @param ContainerInterface $container Dependency injection container |
67
|
|
|
* @param ServerRequestInterface $request Request object |
68
|
|
|
* @param ResponseInterface $response Response object |
69
|
|
|
* @param array $args Associative list of route parameters |
70
|
|
|
* @return ResponseInterface $response Modified response object with generated output |
71
|
|
|
*/ |
72
|
|
|
public static function listAction( ContainerInterface $container, ServerRequestInterface $request, |
73
|
|
|
ResponseInterface $response, array $args ) : ResponseInterface |
74
|
|
|
{ |
75
|
|
|
$contents = $container->get( 'shop' )->get( 'catalog-list', $request, $response, $args ); |
76
|
|
|
return $container->get( 'view' )->render( $response, 'Catalog/list.html.twig', $contents ) |
77
|
|
|
->withHeader( 'Cache-Control', 'max-age=3600' ); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Returns the html body part for the catalog stock page. |
83
|
|
|
* |
84
|
|
|
* @param ContainerInterface $container Dependency injection container |
85
|
|
|
* @param ServerRequestInterface $request Request object |
86
|
|
|
* @param ResponseInterface $response Response object |
87
|
|
|
* @param array $args Associative list of route parameters |
88
|
|
|
* @return ResponseInterface $response Modified response object with generated output |
89
|
|
|
*/ |
90
|
|
|
public static function stockAction( ContainerInterface $container, ServerRequestInterface $request, |
91
|
|
|
ResponseInterface $response, array $args ) : ResponseInterface |
92
|
|
|
{ |
93
|
|
|
$contents = $container->get( 'shop' )->get( 'catalog-stock', $request, $response, $args ); |
94
|
|
|
$response = $container->get( 'view' )->render( $response, 'Catalog/stock.html.twig', $contents ); |
95
|
|
|
|
96
|
|
|
return $response->withHeader( 'Cache-Control', 'max-age=30' ) |
97
|
|
|
->withHeader( 'Content-Type', 'application/javascript' ); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Returns the view for the XHR response with the product information for the search suggestion. |
103
|
|
|
* |
104
|
|
|
* @param ContainerInterface $container Dependency injection container |
105
|
|
|
* @param ServerRequestInterface $request Request object |
106
|
|
|
* @param ResponseInterface $response Response object |
107
|
|
|
* @param array $args Associative list of route parameters |
108
|
|
|
* @return ResponseInterface $response Modified response object with generated output |
109
|
|
|
*/ |
110
|
|
|
public static function suggestAction( ContainerInterface $container, ServerRequestInterface $request, |
111
|
|
|
ResponseInterface $response, array $args ) : ResponseInterface |
112
|
|
|
{ |
113
|
|
|
$contents = $container->get( 'shop' )->get( 'catalog-suggest', $request, $response, $args ); |
114
|
|
|
$response = $container->get( 'view' )->render( $response, 'Catalog/suggest.html.twig', $contents ); |
115
|
|
|
|
116
|
|
|
return $response->withHeader( 'Content-Type', 'application/json' ) |
117
|
|
|
->withHeader( 'Cache-Control', 'max-age=300' ); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Returns the html for the catalog list page. |
123
|
|
|
* |
124
|
|
|
* @param ContainerInterface $container Dependency injection container |
125
|
|
|
* @param ServerRequestInterface $request Request object |
126
|
|
|
* @param ResponseInterface $response Response object |
127
|
|
|
* @param array $args Associative list of route parameters |
128
|
|
|
* @return ResponseInterface $response Modified response object with generated output |
129
|
|
|
*/ |
130
|
|
|
public static function treeAction( ContainerInterface $container, ServerRequestInterface $request, |
131
|
|
|
ResponseInterface $response, array $args ) : ResponseInterface |
132
|
|
|
{ |
133
|
|
|
$contents = $container->get( 'shop' )->get( 'catalog-tree', $request, $response, $args ); |
134
|
|
|
return $container->get( 'view' )->render( $response, 'Catalog/tree.html.twig', $contents ) |
135
|
|
|
->withHeader( 'Cache-Control', 'max-age=3600' ); |
136
|
|
|
} |
137
|
|
|
} |