Issues (76)

src/Aimeos/Shop/Controller/CatalogController.php (7 issues)

Check for undefined variables.

Best Practice Comprehensibility Minor
1
<?php
2
3
/**
4
 * @license MIT, http://opensource.org/licenses/MIT
5
 * @copyright Aimeos (aimeos.org), 2015-2016
6
 * @package laravel
7
 * @subpackage Controller
8
 */
9
10
11
namespace Aimeos\Shop\Controller;
12
13
use Aimeos\Shop\Facades\Shop;
14
use Illuminate\Routing\Controller;
15
use Illuminate\Support\Facades\Response;
16
17
18
/**
19
 * Aimeos controller for catalog related functionality.
20
 *
21
 * @package laravel
22
 * @subpackage Controller
23
 */
24
class CatalogController extends Controller
25
{
26
	/**
27
	 * Returns the view for the XHR response with the counts for the facetted search.
28
	 *
29
	 * @return \Illuminate\Http\Response Response object with output and headers
30
	 */
31
	public function countAction()
32
	{
33
		foreach( app( 'config' )->get( 'shop.page.catalog-count' ) as $name )
34
		{
35
			$params['aiheader'][$name] = Shop::get( $name )->getHeader();
36
			$params['aibody'][$name] = Shop::get( $name )->getBody();
37
		}
38
39
		return Response::view( Shop::template( 'catalog.count' ), $params )
0 ignored issues
show
Comprehensibility Best Practice introduced by Andreas
The variable $params seems to be defined by a foreach iteration on line 33. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
40
			->header( 'Content-Type', 'application/javascript' )
41
			->header( 'Cache-Control', 'public, max-age=300' );
42
	}
43
44
45
	/**
46
	 * Returns the html for the catalog detail page.
47
	 *
48
	 * @return \Illuminate\Http\Response Response object with output and headers
49
	 */
50
	public function detailAction()
51
	{
52
		foreach( app( 'config' )->get( 'shop.page.catalog-detail' ) as $name )
53
		{
54
			try {
55
				$params['aiheader'][$name] = Shop::get( $name )->getHeader();
56
				$params['aibody'][$name] = Shop::get( $name )->getBody();
57
			} catch( \Exception $e ) {
58
				if( $e->getCode() === 404 ) { abort( 404 ); }
59
				throw $e;
60
			}
61
		}
62
63
		return Response::view( Shop::template( 'catalog.detail' ), $params )
0 ignored issues
show
Comprehensibility Best Practice introduced by Andreas
The variable $params seems to be defined by a foreach iteration on line 52. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
64
			->header( 'Cache-Control', 'private, max-age=10' );
65
	}
66
67
68
	/**
69
	 * Returns the html for the catalog home page.
70
	 *
71
	 * @return \Illuminate\Http\Response Response object with output and headers
72
	 */
73
	public function homeAction()
74
	{
75
		foreach( app( 'config' )->get( 'shop.page.catalog-home' ) as $name )
76
		{
77
			$params['aiheader'][$name] = Shop::get( $name )->getHeader();
78
			$params['aibody'][$name] = Shop::get( $name )->getBody();
79
		}
80
81
		return Response::view( Shop::template( 'catalog.home' ), $params )
0 ignored issues
show
Comprehensibility Best Practice introduced by Andreas
The variable $params seems to be defined by a foreach iteration on line 75. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
82
			->header( 'Cache-Control', 'private, max-age=10' );
83
	}
84
85
86
	/**
87
	 * Returns the html for the catalog list page.
88
	 *
89
	 * @return \Illuminate\Http\Response Response object with output and headers
90
	 */
91
	public function listAction()
92
	{
93
		foreach( app( 'config' )->get( 'shop.page.catalog-list' ) as $name )
94
		{
95
			$params['aiheader'][$name] = Shop::get( $name )->getHeader();
96
			$params['aibody'][$name] = Shop::get( $name )->getBody();
97
		}
98
99
		return Response::view( Shop::template( 'catalog.list' ), $params )
0 ignored issues
show
Comprehensibility Best Practice introduced by Andreas
The variable $params seems to be defined by a foreach iteration on line 93. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
100
			->header( 'Cache-Control', 'private, max-age=10' );
101
	}
102
103
104
	/**
105
	 * Returns the html for the catalog session page.
106
	 *
107
	 * @return \Illuminate\Http\Response Response object with output and headers
108
	 */
109
	public function sessionAction()
110
	{
111
		foreach( app( 'config' )->get( 'shop.page.catalog-session' ) as $name )
112
		{
113
			$params['aiheader'][$name] = Shop::get( $name )->getHeader();
114
			$params['aibody'][$name] = Shop::get( $name )->getBody();
115
		}
116
117
		return Response::view( Shop::template( 'catalog.session' ), $params )
0 ignored issues
show
Comprehensibility Best Practice introduced by Andreas
The variable $params seems to be defined by a foreach iteration on line 111. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
118
			->header( 'Cache-Control', 'no-cache' );
119
	}
120
121
122
	/**
123
	 * Returns the html body part for the catalog stock page.
124
	 *
125
	 * @return \Illuminate\Http\Response Response object with output and headers
126
	 */
127
	public function stockAction()
128
	{
129
		foreach( app( 'config' )->get( 'shop.page.catalog-stock' ) as $name )
130
		{
131
			$params['aiheader'][$name] = Shop::get( $name )->getHeader();
132
			$params['aibody'][$name] = Shop::get( $name )->getBody();
133
		}
134
135
		return Response::view( Shop::template( 'catalog.stock' ), $params )
136
			->header( 'Content-Type', 'application/javascript' )
137
			->header( 'Cache-Control', 'public, max-age=30' );
138
	}
139
140
141
	/**
142
	 * Returns the view for the XHR response with the product information for the search suggestion.
143
	 *
144
	 * @return \Illuminate\Http\Response Response object with output and headers
145
	 */
146
	public function suggestAction()
147
	{
148
		foreach( app( 'config' )->get( 'shop.page.catalog-suggest' ) as $name )
149
		{
150
			$params['aiheader'][$name] = Shop::get( $name )->getHeader();
151
			$params['aibody'][$name] = Shop::get( $name )->getBody();
152
		}
153
154
		return Response::view( Shop::template( 'catalog.suggest' ), $params )
0 ignored issues
show
Comprehensibility Best Practice introduced by Andreas
The variable $params seems to be defined by a foreach iteration on line 148. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
155
			->header( 'Cache-Control', 'private, max-age=300' )
156
			->header( 'Content-Type', 'application/json' );
157
	}
158
159
160
	/**
161
	 * Returns the html for the catalog tree page.
162
	 *
163
	 * @return \Illuminate\Http\Response Response object with output and headers
164
	 */
165
	public function treeAction()
166
	{
167
		foreach( app( 'config' )->get( 'shop.page.catalog-tree' ) as $name )
168
		{
169
			$params['aiheader'][$name] = Shop::get( $name )->getHeader();
170
			$params['aibody'][$name] = Shop::get( $name )->getBody();
171
		}
172
173
		return Response::view( Shop::template( 'catalog.tree' ), $params )
0 ignored issues
show
Comprehensibility Best Practice introduced by Andreas
The variable $params seems to be defined by a foreach iteration on line 167. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
174
			->header( 'Cache-Control', 'private, max-age=10' );
175
	}
176
}
177