CatalogController::treeAction()   A
last analyzed

Complexity

Conditions 5
Paths 14

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 10
nc 14
nop 0
dl 0
loc 19
rs 9.6111
c 0
b 0
f 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
		$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();
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

101
			$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...
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
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

106
			->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

106
			->header( 'Cache-Control', 'private, max-age=' . config( /** @scrutinizer ignore-type */ 'shop.cache_maxage', 30 ) );
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();
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

121
			$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...
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();
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

141
			$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...
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();
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

162
			$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...
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
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

167
			->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

167
			->header( 'Cache-Control', 'private, max-age=' . config( /** @scrutinizer ignore-type */ 'shop.cache_maxage', 30 ) )
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();
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

185
				$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...
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
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

190
				->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

190
				->header( 'Cache-Control', 'private, max-age=' . config( /** @scrutinizer ignore-type */ 'shop.cache_maxage', 30 ) );
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