Completed
Push — master ( b94e09...a59c24 )
by Aimeos
02:35
created
controller/frontend/src/Controller/Frontend/Index/Standard.php 1 patch
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -29,42 +29,42 @@  discard block
 block discarded – undo
29 29
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
30 30
 	 * @since 2017.03
31 31
 	 */
32
-	public function addFilterAttribute( \Aimeos\MW\Criteria\Iface $filter, array $attrIds, array $optIds, array $oneIds )
32
+	public function addFilterAttribute(\Aimeos\MW\Criteria\Iface $filter, array $attrIds, array $optIds, array $oneIds)
33 33
 	{
34
-		if( !empty( $attrIds ) )
34
+		if (!empty($attrIds))
35 35
 		{
36
-			$attrIds = $this->validateIds( $attrIds );
36
+			$attrIds = $this->validateIds($attrIds);
37 37
 
38
-			$func = $filter->createFunction( 'index.attributeaggregate', array( $attrIds ) );
38
+			$func = $filter->createFunction('index.attributeaggregate', array($attrIds));
39 39
 			$expr = array(
40 40
 				$filter->getConditions(),
41
-				$filter->compare( '==', $func, count( $attrIds ) ),
41
+				$filter->compare('==', $func, count($attrIds)),
42 42
 			);
43
-			$filter->setConditions( $filter->combine( '&&', $expr ) );
43
+			$filter->setConditions($filter->combine('&&', $expr));
44 44
 		}
45 45
 
46
-		if( !empty( $optIds ) )
46
+		if (!empty($optIds))
47 47
 		{
48
-			$attrIds = $this->validateIds( $attrIds );
48
+			$attrIds = $this->validateIds($attrIds);
49 49
 
50
-			$func = $filter->createFunction( 'index.attributeaggregate', array( $optIds ) );
50
+			$func = $filter->createFunction('index.attributeaggregate', array($optIds));
51 51
 			$expr = array(
52 52
 				$filter->getConditions(),
53
-				$filter->compare( '>', $func, 0 ),
53
+				$filter->compare('>', $func, 0),
54 54
 			);
55
-			$filter->setConditions( $filter->combine( '&&', $expr ) );
55
+			$filter->setConditions($filter->combine('&&', $expr));
56 56
 		}
57 57
 
58
-		foreach( $oneIds as $type => $list )
58
+		foreach ($oneIds as $type => $list)
59 59
 		{
60
-			if( ( $list = $this->validateIds( (array) $list ) ) !== array() )
60
+			if (($list = $this->validateIds((array) $list)) !== array())
61 61
 			{
62
-				$func = $filter->createFunction( 'index.attributeaggregate', array( $list ) );
62
+				$func = $filter->createFunction('index.attributeaggregate', array($list));
63 63
 				$expr = array(
64 64
 					$filter->getConditions(),
65
-					$filter->compare( '>', $func, 0 ),
65
+					$filter->compare('>', $func, 0),
66 66
 				);
67
-				$filter->setConditions( $filter->combine( '&&', $expr ) );
67
+				$filter->setConditions($filter->combine('&&', $expr));
68 68
 			}
69 69
 		}
70 70
 
@@ -81,38 +81,38 @@  discard block
 block discarded – undo
81 81
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
82 82
 	 * @since 2017.03
83 83
 	 */
84
-	public function addFilterCategory( \Aimeos\MW\Criteria\Iface $filter, $catId,
85
-		$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $sort = null, $direction = '+', $listtype = 'default' )
84
+	public function addFilterCategory(\Aimeos\MW\Criteria\Iface $filter, $catId,
85
+		$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $sort = null, $direction = '+', $listtype = 'default')
86 86
 	{
87
-		$catIds = ( !is_array( $catId ) ? explode( ',', $catId ) : $catId );
87
+		$catIds = (!is_array($catId) ? explode(',', $catId) : $catId);
88 88
 
89
-		if( $level != \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE )
89
+		if ($level != \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE)
90 90
 		{
91 91
 			$list = array();
92
-			$cntl = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'catalog' );
92
+			$cntl = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'catalog');
93 93
 
94
-			foreach( $catIds as $catId )
94
+			foreach ($catIds as $catId)
95 95
 			{
96
-				$tree = $cntl->getCatalogTree( $catId, array(), $level );
97
-				$list = array_merge( $list, $this->getCatalogIdsFromTree( $tree ) );
96
+				$tree = $cntl->getCatalogTree($catId, array(), $level);
97
+				$list = array_merge($list, $this->getCatalogIdsFromTree($tree));
98 98
 			}
99 99
 
100 100
 			$catIds = $list;
101 101
 		}
102 102
 
103
-		$expr = array( $filter->compare( '==', 'index.catalog.id', array_unique( $catIds ) ) );
103
+		$expr = array($filter->compare('==', 'index.catalog.id', array_unique($catIds)));
104 104
 		$expr[] = $filter->getConditions();
105 105
 
106
-		if( $sort === 'relevance' )
106
+		if ($sort === 'relevance')
107 107
 		{
108
-			$cmpfunc = $filter->createFunction( 'index.catalog.position', array( $listtype, $catIds ) );
109
-			$expr[] = $filter->compare( '>=', $cmpfunc, 0 );
108
+			$cmpfunc = $filter->createFunction('index.catalog.position', array($listtype, $catIds));
109
+			$expr[] = $filter->compare('>=', $cmpfunc, 0);
110 110
 
111
-			$sortfunc = $filter->createFunction( 'sort:index.catalog.position', array( $listtype, $catIds ) );
112
-			$filter->setSortations( array( $filter->sort( $direction, $sortfunc ) ) );
111
+			$sortfunc = $filter->createFunction('sort:index.catalog.position', array($listtype, $catIds));
112
+			$filter->setSortations(array($filter->sort($direction, $sortfunc)));
113 113
 		}
114 114
 
115
-		$filter->setConditions( $filter->combine( '&&', $expr ) );
115
+		$filter->setConditions($filter->combine('&&', $expr));
116 116
 
117 117
 		return $filter;
118 118
 	}
@@ -127,13 +127,13 @@  discard block
 block discarded – undo
127 127
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
128 128
 	 * @since 2017.03
129 129
 	 */
130
-	public function addFilterText( \Aimeos\MW\Criteria\Iface $filter, $input, $listtype = 'default' )
130
+	public function addFilterText(\Aimeos\MW\Criteria\Iface $filter, $input, $listtype = 'default')
131 131
 	{
132 132
 		$langid = $this->getContext()->getLocale()->getLanguageId();
133
-		$cmpfunc = $filter->createFunction( 'index.text.relevance', array( $listtype, $langid, $input ) );
134
-		$expr = array( $filter->compare( '>', $cmpfunc, 0 ), $filter->getConditions() );
133
+		$cmpfunc = $filter->createFunction('index.text.relevance', array($listtype, $langid, $input));
134
+		$expr = array($filter->compare('>', $cmpfunc, 0), $filter->getConditions());
135 135
 
136
-		return $filter->setConditions( $filter->combine( '&&', $expr ) );
136
+		return $filter->setConditions($filter->combine('&&', $expr));
137 137
 	}
138 138
 
139 139
 
@@ -145,9 +145,9 @@  discard block
 block discarded – undo
145 145
 	 * @return array Associative list of key values as key and the product count for this key as value
146 146
 	 * @since 2017.03
147 147
 	 */
148
-	public function aggregate( \Aimeos\MW\Criteria\Iface $filter, $key )
148
+	public function aggregate(\Aimeos\MW\Criteria\Iface $filter, $key)
149 149
 	{
150
-		return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->aggregate( $filter, $key );
150
+		return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index')->aggregate($filter, $key);
151 151
 	}
152 152
 
153 153
 
@@ -162,46 +162,46 @@  discard block
 block discarded – undo
162 162
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
163 163
 	 * @since 2017.03
164 164
 	 */
165
-	public function createFilter( $sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default' )
165
+	public function createFilter($sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default')
166 166
 	{
167 167
 		$sortations = array();
168 168
 		$context = $this->getContext();
169 169
 
170
-		$search = \Aimeos\MShop\Factory::createManager( $context, 'index' )->createSearch( true );
171
-		$expr = array( $search->compare( '!=', 'index.catalog.id', null ) );
170
+		$search = \Aimeos\MShop\Factory::createManager($context, 'index')->createSearch(true);
171
+		$expr = array($search->compare('!=', 'index.catalog.id', null));
172 172
 
173
-		switch( $sort )
173
+		switch ($sort)
174 174
 		{
175 175
 			case 'code':
176
-				$sortations[] = $search->sort( $direction, 'product.code' );
176
+				$sortations[] = $search->sort($direction, 'product.code');
177 177
 				break;
178 178
 
179 179
 			case 'name':
180 180
 				$langid = $context->getLocale()->getLanguageId();
181 181
 
182
-				$cmpfunc = $search->createFunction( 'index.text.value', array( $listtype, $langid, 'name', 'product' ) );
183
-				$expr[] = $search->compare( '>=', $cmpfunc, '' );
182
+				$cmpfunc = $search->createFunction('index.text.value', array($listtype, $langid, 'name', 'product'));
183
+				$expr[] = $search->compare('>=', $cmpfunc, '');
184 184
 
185
-				$sortfunc = $search->createFunction( 'sort:index.text.value', array( $listtype, $langid, 'name' ) );
186
-				$sortations[] = $search->sort( $direction, $sortfunc );
185
+				$sortfunc = $search->createFunction('sort:index.text.value', array($listtype, $langid, 'name'));
186
+				$sortations[] = $search->sort($direction, $sortfunc);
187 187
 				break;
188 188
 
189 189
 			case 'price':
190 190
 				$currencyid = $context->getLocale()->getCurrencyId();
191 191
 
192
-				$cmpfunc = $search->createFunction( 'index.price.value', array( $listtype, $currencyid, 'default' ) );
193
-				$expr[] = $search->compare( '>=', $cmpfunc, '0.00' );
192
+				$cmpfunc = $search->createFunction('index.price.value', array($listtype, $currencyid, 'default'));
193
+				$expr[] = $search->compare('>=', $cmpfunc, '0.00');
194 194
 
195
-				$sortfunc = $search->createFunction( 'sort:index.price.value', array( $listtype, $currencyid, 'default' ) );
196
-				$sortations[] = $search->sort( $direction, $sortfunc );
195
+				$sortfunc = $search->createFunction('sort:index.price.value', array($listtype, $currencyid, 'default'));
196
+				$sortations[] = $search->sort($direction, $sortfunc);
197 197
 				break;
198 198
 		}
199 199
 
200 200
 		$expr[] = $search->getConditions();
201 201
 
202
-		$search->setConditions( $search->combine( '&&', $expr ) );
203
-		$search->setSortations( $sortations );
204
-		$search->setSlice( $start, $size );
202
+		$search->setConditions($search->combine('&&', $expr));
203
+		$search->setSortations($sortations);
204
+		$search->setSlice($start, $size);
205 205
 
206 206
 		return $search;
207 207
 	}
@@ -219,37 +219,37 @@  discard block
 block discarded – undo
219 219
 	 * @param string $type Type of the text like "name", "short", "long", etc.
220 220
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
221 221
 	 */
222
-	public function createTextFilter( $input, $sort = null, $direction = '+', $start = 0, $size = 25, $listtype = 'default', $type = 'name' )
222
+	public function createTextFilter($input, $sort = null, $direction = '+', $start = 0, $size = 25, $listtype = 'default', $type = 'name')
223 223
 	{
224 224
 		$locale = $this->getContext()->getLocale();
225 225
 		$langid = $locale->getLanguageId();
226 226
 
227
-		$search = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index/text' )->createSearch( true );
227
+		$search = \Aimeos\MShop\Factory::createManager($this->getContext(), 'index/text')->createSearch(true);
228 228
 
229 229
 		$expr = array(
230
-			$search->compare( '>', $search->createFunction( 'index.text.relevance', array( $listtype, $langid, $input ) ), 0 ),
231
-			$search->compare( '>', $search->createFunction( 'index.text.value', array( $listtype, $langid, $type, 'product' ) ), '' ),
230
+			$search->compare('>', $search->createFunction('index.text.relevance', array($listtype, $langid, $input)), 0),
231
+			$search->compare('>', $search->createFunction('index.text.value', array($listtype, $langid, $type, 'product')), ''),
232 232
 		);
233 233
 
234 234
 		$sortations = array();
235 235
 
236
-		switch( $sort )
236
+		switch ($sort)
237 237
 		{
238 238
 			case 'name':
239
-				$cmpfunc = $search->createFunction( 'index.text.value', array( $listtype, $langid, 'name', 'product' ) );
240
-				$expr[] = $search->compare( '>=', $cmpfunc, '' );
239
+				$cmpfunc = $search->createFunction('index.text.value', array($listtype, $langid, 'name', 'product'));
240
+				$expr[] = $search->compare('>=', $cmpfunc, '');
241 241
 
242
-				$sortfunc = $search->createFunction( 'sort:index.text.value', array( $listtype, $langid, 'name' ) );
243
-				$sortations[] = $search->sort( $direction, $sortfunc );
242
+				$sortfunc = $search->createFunction('sort:index.text.value', array($listtype, $langid, 'name'));
243
+				$sortations[] = $search->sort($direction, $sortfunc);
244 244
 				break;
245 245
 
246 246
 			case 'relevance':
247 247
 				// we don't need to sort by 'sort:index.text.relevance' because it's a boolean match (relevance is either 0 or 1)
248 248
 		}
249 249
 
250
-		$search->setConditions( $search->combine( '&&', $expr ) );
251
-		$search->setSortations( $sortations );
252
-		$search->setSlice( $start, $size );
250
+		$search->setConditions($search->combine('&&', $expr));
251
+		$search->setSortations($sortations);
252
+		$search->setSlice($start, $size);
253 253
 
254 254
 		return $search;
255 255
 	}
@@ -264,9 +264,9 @@  discard block
 block discarded – undo
264 264
 	 * @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface
265 265
 	 * @since 2017.03
266 266
 	 */
267
-	public function getItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null )
267
+	public function getItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = array('media', 'price', 'text'), &$total = null)
268 268
 	{
269
-		return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->searchItems( $filter, $domains, $total );
269
+		return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index')->searchItems($filter, $domains, $total);
270 270
 	}
271 271
 
272 272
 
@@ -276,9 +276,9 @@  discard block
 block discarded – undo
276 276
 	 * @param \Aimeos\MW\Criteria\Iface $filter Critera object which contains the filter conditions
277 277
 	 * @return array Associative list of the product ID as key and the product text as value
278 278
 	 */
279
-	public function getTextList( \Aimeos\MW\Criteria\Iface $filter )
279
+	public function getTextList(\Aimeos\MW\Criteria\Iface $filter)
280 280
 	{
281
-		return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index/text' )->searchTexts( $filter );
281
+		return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index/text')->searchTexts($filter);
282 282
 	}
283 283
 
284 284
 
@@ -288,12 +288,12 @@  discard block
 block discarded – undo
288 288
 	 * @param \Aimeos\MShop\Catalog\Item\Iface $item Catalog item with children
289 289
 	 * @return array List of catalog IDs
290 290
 	 */
291
-	protected function getCatalogIdsFromTree( \Aimeos\MShop\Catalog\Item\Iface $item )
291
+	protected function getCatalogIdsFromTree(\Aimeos\MShop\Catalog\Item\Iface $item)
292 292
 	{
293
-		$list = array( $item->getId() );
293
+		$list = array($item->getId());
294 294
 
295
-		foreach( $item->getChildren() as $child ) {
296
-			$list = array_merge( $list, $this->getCatalogIdsFromTree( $child ) );
295
+		foreach ($item->getChildren() as $child) {
296
+			$list = array_merge($list, $this->getCatalogIdsFromTree($child));
297 297
 		}
298 298
 
299 299
 		return $list;
@@ -306,13 +306,13 @@  discard block
 block discarded – undo
306 306
 	 * @param array $ids List of IDs to validate
307 307
 	 * @return array List of validated IDs
308 308
 	 */
309
-	protected function validateIds( array $ids )
309
+	protected function validateIds(array $ids)
310 310
 	{
311 311
 		$list = array();
312 312
 
313
-		foreach( $ids as $id )
313
+		foreach ($ids as $id)
314 314
 		{
315
-			if( $id != '' ) {
315
+			if ($id != '') {
316 316
 				$list[] = (int) $id;
317 317
 			}
318 318
 		}
Please login to merge, or discard this patch.