CatalogController::homeAction()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 12
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
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();
0 ignored issues
show
Unused Code introduced by
The call to Aimeos\Shop\Facades\Shop::get() has too many arguments starting with $name. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

32
			$params['aiheader'][$name] = Shop::/** @scrutinizer ignore-call */ get( $name )->header();

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
33
			$params['aibody'][$name] = Shop::get( $name )->body();
34
		}
35
36
		return Response::view( Shop::template( 'catalog.count' ), $params )
0 ignored issues
show
Bug introduced by
The method template() does not exist on Aimeos\Shop\Facades\Shop. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

36
		return Response::view( Shop::/** @scrutinizer ignore-call */ template( 'catalog.count' ), $params )
Loading history...
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();
0 ignored issues
show
Unused Code introduced by
The call to Aimeos\Shop\Facades\Shop::get() has too many arguments starting with $name. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

55
				$params['aiheader'][$name] = Shop::/** @scrutinizer ignore-call */ get( $name )->header();

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
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
Unused Code introduced by
The call to config() has too many arguments starting with 30. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

60
				->header( 'Cache-Control', 'private, max-age=' . /** @scrutinizer ignore-call */ config( 'shop.cache_maxage', 30 ) );

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
Bug introduced by
'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 ignore-type  annotation

60
				->header( 'Cache-Control', 'private, max-age=' . config( /** @scrutinizer ignore-type */ 'shop.cache_maxage', 30 ) );
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();
0 ignored issues
show
Unused Code introduced by
The call to Aimeos\Shop\Facades\Shop::get() has too many arguments starting with $name. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

81
			$params['aiheader'][$name] = Shop::/** @scrutinizer ignore-call */ get( $name )->header();

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
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
Unused Code introduced by
The call to config() has too many arguments starting with 30. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

86
			->header( 'Cache-Control', 'private, max-age=' . /** @scrutinizer ignore-call */ config( 'shop.cache_maxage', 30 ) );

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
Bug introduced by
'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 ignore-type  annotation

86
			->header( 'Cache-Control', 'private, max-age=' . config( /** @scrutinizer ignore-type */ 'shop.cache_maxage', 30 ) );
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
		try
98
		{
99
			$params = ['page' => 'page-catalog-list'];
100
101
			foreach( app( 'config' )->get( 'shop.page.catalog-list' ) as $name )
102
			{
103
				$params['aiheader'][$name] = Shop::get( $name )->header();
0 ignored issues
show
Unused Code introduced by
The call to Aimeos\Shop\Facades\Shop::get() has too many arguments starting with $name. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

103
				$params['aiheader'][$name] = Shop::/** @scrutinizer ignore-call */ get( $name )->header();

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
104
				$params['aibody'][$name] = Shop::get( $name )->body();
105
			}
106
107
			return Response::view( Shop::template( 'catalog.list' ), $params )
108
				->header( 'Cache-Control', 'private, max-age=' . config( 'shop.cache_maxage', 30 ) );
0 ignored issues
show
Bug introduced by
'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 ignore-type  annotation

108
				->header( 'Cache-Control', 'private, max-age=' . config( /** @scrutinizer ignore-type */ 'shop.cache_maxage', 30 ) );
Loading history...
Unused Code introduced by
The call to config() has too many arguments starting with 30. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

108
				->header( 'Cache-Control', 'private, max-age=' . /** @scrutinizer ignore-call */ config( 'shop.cache_maxage', 30 ) );

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
109
		}
110
		catch( \Exception $e )
111
		{
112
			if( $e->getCode() >= 400 && $e->getCode() < 600 ) { abort( $e->getCode() ); }
113
			throw $e;
114
		}
115
	}
116
117
118
	/**
119
	 * Returns the html for the catalog session page.
120
	 *
121
	 * @return \Illuminate\Http\Response Response object with output and headers
122
	 */
123
	public function sessionAction()
124
	{
125
		$params = ['page' => 'page-catalog-session'];
126
127
		foreach( app( 'config' )->get( 'shop.page.catalog-session' ) as $name )
128
		{
129
			$params['aiheader'][$name] = Shop::get( $name )->header();
0 ignored issues
show
Unused Code introduced by
The call to Aimeos\Shop\Facades\Shop::get() has too many arguments starting with $name. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

129
			$params['aiheader'][$name] = Shop::/** @scrutinizer ignore-call */ get( $name )->header();

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
130
			$params['aibody'][$name] = Shop::get( $name )->body();
131
		}
132
133
		return Response::view( Shop::template( 'catalog.session' ), $params )
134
			->header( 'Cache-Control', 'no-cache' );
135
	}
136
137
138
	/**
139
	 * Returns the html body part for the catalog stock page.
140
	 *
141
	 * @return \Illuminate\Http\Response Response object with output and headers
142
	 */
143
	public function stockAction()
144
	{
145
		$params = ['page' => 'page-catalog-stock'];
146
147
		foreach( app( 'config' )->get( 'shop.page.catalog-stock' ) as $name )
148
		{
149
			$params['aiheader'][$name] = Shop::get( $name )->header();
0 ignored issues
show
Unused Code introduced by
The call to Aimeos\Shop\Facades\Shop::get() has too many arguments starting with $name. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

149
			$params['aiheader'][$name] = Shop::/** @scrutinizer ignore-call */ get( $name )->header();

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
150
			$params['aibody'][$name] = Shop::get( $name )->body();
151
		}
152
153
		return Response::view( Shop::template( 'catalog.stock' ), $params )
154
			->header( 'Content-Type', 'application/javascript' )
155
			->header( 'Cache-Control', 'public, max-age=30' );
156
	}
157
158
159
	/**
160
	 * Returns the view for the XHR response with the product information for the search suggestion.
161
	 *
162
	 * @return \Illuminate\Http\Response Response object with output and headers
163
	 */
164
	public function suggestAction()
165
	{
166
		$params = ['page' => 'page-catalog-suggest'];
167
168
		foreach( app( 'config' )->get( 'shop.page.catalog-suggest' ) as $name )
169
		{
170
			$params['aiheader'][$name] = Shop::get( $name )->header();
0 ignored issues
show
Unused Code introduced by
The call to Aimeos\Shop\Facades\Shop::get() has too many arguments starting with $name. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

170
			$params['aiheader'][$name] = Shop::/** @scrutinizer ignore-call */ get( $name )->header();

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
171
			$params['aibody'][$name] = Shop::get( $name )->body();
172
		}
173
174
		return Response::view( Shop::template( 'catalog.suggest' ), $params )
175
			->header( 'Cache-Control', 'private, max-age=' . config( 'shop.cache_maxage', 30 ) )
0 ignored issues
show
Bug introduced by
'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 ignore-type  annotation

175
			->header( 'Cache-Control', 'private, max-age=' . config( /** @scrutinizer ignore-type */ 'shop.cache_maxage', 30 ) )
Loading history...
Unused Code introduced by
The call to config() has too many arguments starting with 30. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

175
			->header( 'Cache-Control', 'private, max-age=' . /** @scrutinizer ignore-call */ config( 'shop.cache_maxage', 30 ) )

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
176
			->header( 'Content-Type', 'application/json' );
177
	}
178
179
180
	/**
181
	 * Returns the html for the catalog tree page.
182
	 *
183
	 * @return \Illuminate\Http\Response Response object with output and headers
184
	 */
185
	public function treeAction()
186
	{
187
		try
188
		{
189
			$params = ['page' => 'page-catalog-tree'];
190
191
			foreach( app( 'config' )->get( 'shop.page.catalog-tree' ) as $name )
192
			{
193
				$params['aiheader'][$name] = Shop::get( $name )->header();
0 ignored issues
show
Unused Code introduced by
The call to Aimeos\Shop\Facades\Shop::get() has too many arguments starting with $name. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

193
				$params['aiheader'][$name] = Shop::/** @scrutinizer ignore-call */ get( $name )->header();

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
194
				$params['aibody'][$name] = Shop::get( $name )->body();
195
			}
196
197
			return Response::view( Shop::template( 'catalog.tree' ), $params )
198
				->header( 'Cache-Control', 'private, max-age=' . config( 'shop.cache_maxage', 30 ) );
0 ignored issues
show
Bug introduced by
'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 ignore-type  annotation

198
				->header( 'Cache-Control', 'private, max-age=' . config( /** @scrutinizer ignore-type */ 'shop.cache_maxage', 30 ) );
Loading history...
Unused Code introduced by
The call to config() has too many arguments starting with 30. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

198
				->header( 'Cache-Control', 'private, max-age=' . /** @scrutinizer ignore-call */ config( 'shop.cache_maxage', 30 ) );

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
199
		}
200
		catch( \Exception $e )
201
		{
202
			if( $e->getCode() >= 400 && $e->getCode() < 600 ) { abort( $e->getCode() ); }
203
			throw $e;
204
		}
205
	}
206
}
207