1 | <?php |
||||
2 | |||||
3 | /** |
||||
4 | * @license MIT, http://opensource.org/licenses/MIT |
||||
5 | * @copyright Aimeos (aimeos.org), 2015-2023 |
||||
6 | */ |
||||
7 | |||||
8 | |||||
9 | namespace Aimeos\Shop\Controller; |
||||
10 | |||||
11 | use Aimeos\Shop\Facades\Shop; |
||||
12 | use Illuminate\Routing\Controller; |
||||
13 | use Illuminate\Support\Facades\Response; |
||||
14 | |||||
15 | |||||
16 | /** |
||||
17 | * Aimeos controller for catalog related functionality. |
||||
18 | */ |
||||
19 | class CatalogController extends Controller |
||||
20 | { |
||||
21 | /** |
||||
22 | * Returns the view for the XHR response with the counts for the facetted search. |
||||
23 | * |
||||
24 | * @return \Illuminate\Http\Response Response object with output and headers |
||||
25 | */ |
||||
26 | public function countAction() |
||||
27 | { |
||||
28 | $params = ['page' => 'page-catalog-count']; |
||||
29 | |||||
30 | foreach( app( 'config' )->get( 'shop.page.catalog-count' ) as $name ) |
||||
31 | { |
||||
32 | $params['aiheader'][$name] = Shop::get( $name )->header(); |
||||
33 | $params['aibody'][$name] = Shop::get( $name )->body(); |
||||
34 | } |
||||
35 | |||||
36 | return Response::view( Shop::template( 'catalog.count' ), $params ) |
||||
37 | ->header( 'Content-Type', 'application/javascript' ) |
||||
38 | ->header( 'Cache-Control', 'public, max-age=300' ); |
||||
39 | } |
||||
40 | |||||
41 | |||||
42 | /** |
||||
43 | * Returns the html for the catalog detail page. |
||||
44 | * |
||||
45 | * @return \Illuminate\Http\Response Response object with output and headers |
||||
46 | */ |
||||
47 | public function detailAction() |
||||
48 | { |
||||
49 | try |
||||
50 | { |
||||
51 | $params = ['page' => 'page-catalog-detail']; |
||||
52 | |||||
53 | foreach( app( 'config' )->get( 'shop.page.catalog-detail' ) as $name ) |
||||
54 | { |
||||
55 | $params['aiheader'][$name] = Shop::get( $name )->header(); |
||||
56 | $params['aibody'][$name] = Shop::get( $name )->body(); |
||||
57 | } |
||||
58 | |||||
59 | return Response::view( Shop::template( 'catalog.detail' ), $params ) |
||||
60 | ->header( 'Cache-Control', 'private, max-age=' . config( 'shop.cache_maxage', 30 ) ); |
||||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
61 | } |
||||
62 | catch( \Exception $e ) |
||||
63 | { |
||||
64 | if( $e->getCode() >= 400 && $e->getCode() < 600 ) { abort( $e->getCode() ); } |
||||
65 | throw $e; |
||||
66 | } |
||||
67 | } |
||||
68 | |||||
69 | |||||
70 | /** |
||||
71 | * Returns the html for the catalog home page. |
||||
72 | * |
||||
73 | * @return \Illuminate\Http\Response Response object with output and headers |
||||
74 | */ |
||||
75 | public function homeAction() |
||||
76 | { |
||||
77 | $params = ['page' => 'page-catalog-home']; |
||||
78 | |||||
79 | foreach( app( 'config' )->get( 'shop.page.catalog-home' ) as $name ) |
||||
80 | { |
||||
81 | $params['aiheader'][$name] = Shop::get( $name )->header(); |
||||
82 | $params['aibody'][$name] = Shop::get( $name )->body(); |
||||
83 | } |
||||
84 | |||||
85 | return Response::view( Shop::template( 'catalog.home' ), $params ) |
||||
86 | ->header( 'Cache-Control', 'private, max-age=' . config( 'shop.cache_maxage', 30 ) ); |
||||
0 ignored issues
–
show
'shop.cache_maxage' of type string is incompatible with the type array expected by parameter $options of config() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
87 | } |
||||
88 | |||||
89 | |||||
90 | /** |
||||
91 | * Returns the html for the catalog list page. |
||||
92 | * |
||||
93 | * @return \Illuminate\Http\Response Response object with output and headers |
||||
94 | */ |
||||
95 | public function listAction() |
||||
96 | { |
||||
97 | $params = ['page' => 'page-catalog-list']; |
||||
98 | |||||
99 | foreach( app( 'config' )->get( 'shop.page.catalog-list' ) as $name ) |
||||
100 | { |
||||
101 | $params['aiheader'][$name] = Shop::get( $name )->header(); |
||||
102 | $params['aibody'][$name] = Shop::get( $name )->body(); |
||||
103 | } |
||||
104 | |||||
105 | return Response::view( Shop::template( 'catalog.list' ), $params ) |
||||
106 | ->header( 'Cache-Control', 'private, max-age=' . config( 'shop.cache_maxage', 30 ) ); |
||||
0 ignored issues
–
show
'shop.cache_maxage' of type string is incompatible with the type array expected by parameter $options of config() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
107 | } |
||||
108 | |||||
109 | |||||
110 | /** |
||||
111 | * Returns the html for the catalog session page. |
||||
112 | * |
||||
113 | * @return \Illuminate\Http\Response Response object with output and headers |
||||
114 | */ |
||||
115 | public function sessionAction() |
||||
116 | { |
||||
117 | $params = ['page' => 'page-catalog-session']; |
||||
118 | |||||
119 | foreach( app( 'config' )->get( 'shop.page.catalog-session' ) as $name ) |
||||
120 | { |
||||
121 | $params['aiheader'][$name] = Shop::get( $name )->header(); |
||||
122 | $params['aibody'][$name] = Shop::get( $name )->body(); |
||||
123 | } |
||||
124 | |||||
125 | return Response::view( Shop::template( 'catalog.session' ), $params ) |
||||
126 | ->header( 'Cache-Control', 'no-cache' ); |
||||
127 | } |
||||
128 | |||||
129 | |||||
130 | /** |
||||
131 | * Returns the html body part for the catalog stock page. |
||||
132 | * |
||||
133 | * @return \Illuminate\Http\Response Response object with output and headers |
||||
134 | */ |
||||
135 | public function stockAction() |
||||
136 | { |
||||
137 | $params = ['page' => 'page-catalog-stock']; |
||||
138 | |||||
139 | foreach( app( 'config' )->get( 'shop.page.catalog-stock' ) as $name ) |
||||
140 | { |
||||
141 | $params['aiheader'][$name] = Shop::get( $name )->header(); |
||||
142 | $params['aibody'][$name] = Shop::get( $name )->body(); |
||||
143 | } |
||||
144 | |||||
145 | return Response::view( Shop::template( 'catalog.stock' ), $params ) |
||||
146 | ->header( 'Content-Type', 'application/javascript' ) |
||||
147 | ->header( 'Cache-Control', 'public, max-age=30' ); |
||||
148 | } |
||||
149 | |||||
150 | |||||
151 | /** |
||||
152 | * Returns the view for the XHR response with the product information for the search suggestion. |
||||
153 | * |
||||
154 | * @return \Illuminate\Http\Response Response object with output and headers |
||||
155 | */ |
||||
156 | public function suggestAction() |
||||
157 | { |
||||
158 | $params = ['page' => 'page-catalog-suggest']; |
||||
159 | |||||
160 | foreach( app( 'config' )->get( 'shop.page.catalog-suggest' ) as $name ) |
||||
161 | { |
||||
162 | $params['aiheader'][$name] = Shop::get( $name )->header(); |
||||
163 | $params['aibody'][$name] = Shop::get( $name )->body(); |
||||
164 | } |
||||
165 | |||||
166 | return Response::view( Shop::template( 'catalog.suggest' ), $params ) |
||||
167 | ->header( 'Cache-Control', 'private, max-age=' . config( 'shop.cache_maxage', 30 ) ) |
||||
0 ignored issues
–
show
'shop.cache_maxage' of type string is incompatible with the type array expected by parameter $options of config() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
168 | ->header( 'Content-Type', 'application/json' ); |
||||
169 | } |
||||
170 | |||||
171 | |||||
172 | /** |
||||
173 | * Returns the html for the catalog tree page. |
||||
174 | * |
||||
175 | * @return \Illuminate\Http\Response Response object with output and headers |
||||
176 | */ |
||||
177 | public function treeAction() |
||||
178 | { |
||||
179 | try |
||||
180 | { |
||||
181 | $params = ['page' => 'page-catalog-tree']; |
||||
182 | |||||
183 | foreach( app( 'config' )->get( 'shop.page.catalog-tree' ) as $name ) |
||||
184 | { |
||||
185 | $params['aiheader'][$name] = Shop::get( $name )->header(); |
||||
186 | $params['aibody'][$name] = Shop::get( $name )->body(); |
||||
187 | } |
||||
188 | |||||
189 | return Response::view( Shop::template( 'catalog.tree' ), $params ) |
||||
190 | ->header( 'Cache-Control', 'private, max-age=' . config( 'shop.cache_maxage', 30 ) ); |
||||
0 ignored issues
–
show
'shop.cache_maxage' of type string is incompatible with the type array expected by parameter $options of config() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
191 | } |
||||
192 | catch( \Exception $e ) |
||||
193 | { |
||||
194 | if( $e->getCode() >= 400 && $e->getCode() < 600 ) { abort( $e->getCode() ); } |
||||
195 | throw $e; |
||||
196 | } |
||||
197 | } |
||||
198 | } |
||||
199 |