Completed
Push — master ( 92e0c1...ae96d3 )
by Aimeos
02:09
created
controller/frontend/tests/Controller/Frontend/Product/StandardTest.php 1 patch
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -17,22 +17,22 @@  discard block
 block discarded – undo
17 17
 	protected function setUp()
18 18
 	{
19 19
 		$this->context = \TestHelperFrontend::getContext();
20
-		$this->object = new \Aimeos\Controller\Frontend\Product\Standard( $this->context );
20
+		$this->object = new \Aimeos\Controller\Frontend\Product\Standard($this->context);
21 21
 	}
22 22
 
23 23
 
24 24
 	protected function tearDown()
25 25
 	{
26
-		unset( $this->object );
26
+		unset($this->object);
27 27
 	}
28 28
 
29 29
 
30 30
 	public function testAggregate()
31 31
 	{
32 32
 		$filter = $this->object->createFilter();
33
-		$list = $this->object->aggregate( $filter, 'index.attribute.id' );
33
+		$list = $this->object->aggregate($filter, 'index.attribute.id');
34 34
 
35
-		$this->assertGreaterThan( 0, count( $list ) );
35
+		$this->assertGreaterThan(0, count($list));
36 36
 	}
37 37
 
38 38
 
@@ -40,113 +40,113 @@  discard block
 block discarded – undo
40 40
 	{
41 41
 		$filter = $this->object->createFilter();
42 42
 
43
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
44
-		$this->assertEquals( [], $filter->getSortations() );
45
-		$this->assertEquals( 0, $filter->getSliceStart() );
46
-		$this->assertEquals( 100, $filter->getSliceSize() );
43
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter);
44
+		$this->assertEquals([], $filter->getSortations());
45
+		$this->assertEquals(0, $filter->getSliceStart());
46
+		$this->assertEquals(100, $filter->getSliceSize());
47 47
 	}
48 48
 
49 49
 
50 50
 	public function testCreateFilterIgnoreDates()
51 51
 	{
52
-		$this->context->getConfig()->set( 'controller/frontend/product/ignore-dates', true );
52
+		$this->context->getConfig()->set('controller/frontend/product/ignore-dates', true);
53 53
 
54 54
 		$filter = $this->object->createFilter();
55 55
 
56
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
56
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter);
57 57
 	}
58 58
 
59 59
 
60 60
 	public function testAddFilterAttribute()
61 61
 	{
62 62
 		$filter = $this->object->createFilter();
63
-		$filter = $this->object->addFilterAttribute( $filter, array( 0, 1 ), [], [] );
63
+		$filter = $this->object->addFilterAttribute($filter, array(0, 1), [], []);
64 64
 
65 65
 		$list = $filter->getConditions()->getExpressions();
66 66
 
67
-		if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) {
68
-			throw new \RuntimeException( 'Wrong expression' );
67
+		if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) {
68
+			throw new \RuntimeException('Wrong expression');
69 69
 		}
70 70
 
71
-		$this->assertEquals( 'index.attributeaggregate([0,1])', $list[0]->getName() );
72
-		$this->assertEquals( 2, $list[0]->getValue() );
71
+		$this->assertEquals('index.attributeaggregate([0,1])', $list[0]->getName());
72
+		$this->assertEquals(2, $list[0]->getValue());
73 73
 	}
74 74
 
75 75
 
76 76
 	public function testAddFilterAttributeOptions()
77 77
 	{
78 78
 		$filter = $this->object->createFilter();
79
-		$filter = $this->object->addFilterAttribute( $filter, [], array( 1 ), [] );
79
+		$filter = $this->object->addFilterAttribute($filter, [], array(1), []);
80 80
 
81 81
 		$list = $filter->getConditions()->getExpressions();
82 82
 
83
-		if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) {
84
-			throw new \RuntimeException( 'Wrong expression' );
83
+		if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) {
84
+			throw new \RuntimeException('Wrong expression');
85 85
 		}
86 86
 
87
-		$this->assertEquals( 'index.attributeaggregate([1])', $list[0]->getName() );
88
-		$this->assertEquals( 0, $list[0]->getValue() );
87
+		$this->assertEquals('index.attributeaggregate([1])', $list[0]->getName());
88
+		$this->assertEquals(0, $list[0]->getValue());
89 89
 	}
90 90
 
91 91
 
92 92
 	public function testAddFilterAttributeOne()
93 93
 	{
94 94
 		$filter = $this->object->createFilter();
95
-		$filter = $this->object->addFilterAttribute( $filter, [], [], array( 'test' => array( 2 ) ) );
95
+		$filter = $this->object->addFilterAttribute($filter, [], [], array('test' => array(2)));
96 96
 
97 97
 		$list = $filter->getConditions()->getExpressions();
98 98
 
99
-		if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) {
100
-			throw new \RuntimeException( 'Wrong expression' );
99
+		if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) {
100
+			throw new \RuntimeException('Wrong expression');
101 101
 		}
102 102
 
103
-		$this->assertEquals( 'index.attributeaggregate([2])', $list[0]->getName() );
104
-		$this->assertEquals( 0, $list[0]->getValue() );
103
+		$this->assertEquals('index.attributeaggregate([2])', $list[0]->getName());
104
+		$this->assertEquals(0, $list[0]->getValue());
105 105
 	}
106 106
 
107 107
 
108 108
 	public function testAddFilterCategory()
109 109
 	{
110 110
 		$context = \TestHelperFrontend::getContext();
111
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'catalog' );
111
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'catalog');
112 112
 
113
-		$catId = $manager->findItem( 'root' )->getId();
113
+		$catId = $manager->findItem('root')->getId();
114 114
 		$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST;
115 115
 
116 116
 		$filter = $this->object->createFilter();
117
-		$filter = $this->object->addFilterCategory( $filter, $catId, $level );
117
+		$filter = $this->object->addFilterCategory($filter, $catId, $level);
118 118
 
119 119
 		$list = $filter->getConditions()->getExpressions();
120 120
 
121
-		if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) {
122
-			throw new \RuntimeException( 'Wrong expression' );
121
+		if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) {
122
+			throw new \RuntimeException('Wrong expression');
123 123
 		}
124 124
 
125
-		$this->assertEquals( 'index.catalog.id', $list[0]->getName() );
126
-		$this->assertEquals( 3, count( $list[0]->getValue() ) );
127
-		$this->assertEquals( [], $filter->getSortations() );
125
+		$this->assertEquals('index.catalog.id', $list[0]->getName());
126
+		$this->assertEquals(3, count($list[0]->getValue()));
127
+		$this->assertEquals([], $filter->getSortations());
128 128
 	}
129 129
 
130 130
 
131 131
 	public function testAddFilterText()
132 132
 	{
133 133
 		$filter = $this->object->createFilter();
134
-		$filter = $this->object->addFilterText( $filter, 'Espresso' );
134
+		$filter = $this->object->addFilterText($filter, 'Espresso');
135 135
 
136
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
136
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter);
137 137
 
138 138
 		$list = $filter->getConditions()->getExpressions();
139 139
 
140 140
 
141
-		if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) {
142
-			throw new \RuntimeException( 'Wrong expression' );
141
+		if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) {
142
+			throw new \RuntimeException('Wrong expression');
143 143
 		}
144
-		$this->assertEquals( 'index.text.relevance("default","de","Espresso")', $list[0]->getName() );
145
-		$this->assertEquals( 0, $list[0]->getValue() );
144
+		$this->assertEquals('index.text.relevance("default","de","Espresso")', $list[0]->getName());
145
+		$this->assertEquals(0, $list[0]->getValue());
146 146
 
147
-		$this->assertEquals( [], $filter->getSortations() );
148
-		$this->assertEquals( 0, $filter->getSliceStart() );
149
-		$this->assertEquals( 100, $filter->getSliceSize() );
147
+		$this->assertEquals([], $filter->getSortations());
148
+		$this->assertEquals(0, $filter->getSliceStart());
149
+		$this->assertEquals(100, $filter->getSliceSize());
150 150
 	}
151 151
 
152 152
 
@@ -155,160 +155,160 @@  discard block
 block discarded – undo
155 155
 		$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE;
156 156
 
157 157
 		$filter = $this->object->createFilter();
158
-		$filter = $this->object->addFilterCategory( $filter, 0, $level, 'relevance', '-', 'test' );
158
+		$filter = $this->object->addFilterCategory($filter, 0, $level, 'relevance', '-', 'test');
159 159
 
160
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
160
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter);
161 161
 
162 162
 		$sort = $filter->getSortations();
163
-		if( ( $item = reset( $sort ) ) === false ) {
164
-			throw new \RuntimeException( 'Sortation not set' );
163
+		if (($item = reset($sort)) === false) {
164
+			throw new \RuntimeException('Sortation not set');
165 165
 		}
166 166
 
167
-		$this->assertEquals( 'sort:index.catalog.position("test",["0"])', $item->getName() );
168
-		$this->assertEquals( '-', $item->getOperator() );
167
+		$this->assertEquals('sort:index.catalog.position("test",["0"])', $item->getName());
168
+		$this->assertEquals('-', $item->getOperator());
169 169
 	}
170 170
 
171 171
 
172 172
 	public function testCreateFilterSortRelevanceText()
173 173
 	{
174
-		$filter = $this->object->createFilter( 'relevance', '-', 1, 2, 'test' );
175
-		$filter = $this->object->addFilterText( $filter, 'Espresso' );
174
+		$filter = $this->object->createFilter('relevance', '-', 1, 2, 'test');
175
+		$filter = $this->object->addFilterText($filter, 'Espresso');
176 176
 
177
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
178
-		$this->assertEquals( [], $filter->getSortations() );
179
-		$this->assertEquals( 1, $filter->getSliceStart() );
180
-		$this->assertEquals( 2, $filter->getSliceSize() );
177
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter);
178
+		$this->assertEquals([], $filter->getSortations());
179
+		$this->assertEquals(1, $filter->getSliceStart());
180
+		$this->assertEquals(2, $filter->getSliceSize());
181 181
 	}
182 182
 
183 183
 
184 184
 	public function testCreateFilterSortCode()
185 185
 	{
186
-		$filter = $this->object->createFilter( 'code' );
186
+		$filter = $this->object->createFilter('code');
187 187
 
188
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
188
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter);
189 189
 
190 190
 		$sort = $filter->getSortations();
191
-		if( ( $item = reset( $sort ) ) === false ) {
192
-			throw new \RuntimeException( 'Sortation not set' );
191
+		if (($item = reset($sort)) === false) {
192
+			throw new \RuntimeException('Sortation not set');
193 193
 		}
194 194
 
195
-		$this->assertEquals( 'product.code', $item->getName() );
195
+		$this->assertEquals('product.code', $item->getName());
196 196
 	}
197 197
 
198 198
 
199 199
 	public function testCreateFilterSortName()
200 200
 	{
201
-		$filter = $this->object->createFilter( 'name' );
201
+		$filter = $this->object->createFilter('name');
202 202
 
203
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
203
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter);
204 204
 
205 205
 		$sort = $filter->getSortations();
206
-		if( ( $item = reset( $sort ) ) === false ) {
207
-			throw new \RuntimeException( 'Sortation not set' );
206
+		if (($item = reset($sort)) === false) {
207
+			throw new \RuntimeException('Sortation not set');
208 208
 		}
209 209
 
210
-		$this->assertEquals( 'sort:index.text.value("default","de","name")', $item->getName() );
210
+		$this->assertEquals('sort:index.text.value("default","de","name")', $item->getName());
211 211
 	}
212 212
 
213 213
 
214 214
 	public function testCreateFilterSortPrice()
215 215
 	{
216
-		$filter = $this->object->createFilter( 'price' );
216
+		$filter = $this->object->createFilter('price');
217 217
 
218
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
218
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter);
219 219
 
220 220
 		$sort = $filter->getSortations();
221
-		if( ( $item = reset( $sort ) ) === false ) {
222
-			throw new \RuntimeException( 'Sortation not set' );
221
+		if (($item = reset($sort)) === false) {
222
+			throw new \RuntimeException('Sortation not set');
223 223
 		}
224 224
 
225
-		$this->assertStringStartsWith( 'sort:index.price.value("default","EUR","default")', $item->getName() );
225
+		$this->assertStringStartsWith('sort:index.price.value("default","EUR","default")', $item->getName());
226 226
 	}
227 227
 
228 228
 
229 229
 	public function testCreateFilterSortInvalid()
230 230
 	{
231
-		$filter = $this->object->createFilter( '', 'failure' );
231
+		$filter = $this->object->createFilter('', 'failure');
232 232
 
233
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
234
-		$this->assertEquals( [], $filter->getSortations() );
233
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter);
234
+		$this->assertEquals([], $filter->getSortations());
235 235
 	}
236 236
 
237 237
 
238 238
 	public function testGetItem()
239 239
 	{
240 240
 		$context = \TestHelperFrontend::getContext();
241
-		$id = \Aimeos\MShop\Factory::createManager( $context, 'product' )->findItem( 'CNC' )->getId();
241
+		$id = \Aimeos\MShop\Factory::createManager($context, 'product')->findItem('CNC')->getId();
242 242
 
243
-		$result = $this->object->getItem( $id );
243
+		$result = $this->object->getItem($id);
244 244
 
245
-		$this->assertInstanceOf( '\Aimeos\MShop\Product\Item\Iface', $result );
246
-		$this->assertGreaterThan( 0, $result->getPropertyItems() );
247
-		$this->assertGreaterThan( 0, $result->getRefItems( 'attribute' ) );
248
-		$this->assertGreaterThan( 0, $result->getRefItems( 'media' ) );
249
-		$this->assertGreaterThan( 0, $result->getRefItems( 'price' ) );
250
-		$this->assertGreaterThan( 0, $result->getRefItems( 'product' ) );
251
-		$this->assertGreaterThan( 0, $result->getRefItems( 'text' ) );
245
+		$this->assertInstanceOf('\Aimeos\MShop\Product\Item\Iface', $result);
246
+		$this->assertGreaterThan(0, $result->getPropertyItems());
247
+		$this->assertGreaterThan(0, $result->getRefItems('attribute'));
248
+		$this->assertGreaterThan(0, $result->getRefItems('media'));
249
+		$this->assertGreaterThan(0, $result->getRefItems('price'));
250
+		$this->assertGreaterThan(0, $result->getRefItems('product'));
251
+		$this->assertGreaterThan(0, $result->getRefItems('text'));
252 252
 	}
253 253
 
254 254
 
255 255
 	public function testGetItems()
256 256
 	{
257 257
 		$context = \TestHelperFrontend::getContext();
258
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'product' );
258
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'product');
259 259
 
260 260
 		$search = $manager->createSearch();
261
-		$search->setConditions( $search->compare( '==', 'product.code', array( 'CNC', 'CNE' ) ) );
261
+		$search->setConditions($search->compare('==', 'product.code', array('CNC', 'CNE')));
262 262
 
263 263
 		$ids = [];
264
-		foreach( $manager->searchItems( $search ) as $productItem ) {
264
+		foreach ($manager->searchItems($search) as $productItem) {
265 265
 			$ids[] = $productItem->getId();
266 266
 		}
267 267
 
268 268
 
269
-		$result = $this->object->getItems( $ids );
269
+		$result = $this->object->getItems($ids);
270 270
 
271
-		$this->assertEquals( 2, count( $result ) );
271
+		$this->assertEquals(2, count($result));
272 272
 
273
-		foreach( $result as $productItem ) {
274
-			$this->assertInstanceOf( '\Aimeos\MShop\Product\Item\Iface', $productItem );
273
+		foreach ($result as $productItem) {
274
+			$this->assertInstanceOf('\Aimeos\MShop\Product\Item\Iface', $productItem);
275 275
 		}
276 276
 	}
277 277
 
278 278
 
279 279
 	public function testSearchItemsCategory()
280 280
 	{
281
-		$catalogManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager( \TestHelperFrontend::getContext() );
281
+		$catalogManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager(\TestHelperFrontend::getContext());
282 282
 		$search = $catalogManager->createSearch();
283 283
 
284
-		$search->setConditions( $search->compare( '==', 'catalog.code', 'new' ) );
285
-		$search->setSlice( 0, 1 );
286
-		$items = $catalogManager->searchItems( $search );
284
+		$search->setConditions($search->compare('==', 'catalog.code', 'new'));
285
+		$search->setSlice(0, 1);
286
+		$items = $catalogManager->searchItems($search);
287 287
 
288
-		if( ( $item = reset( $items ) ) === false ) {
289
-			throw new \RuntimeException( 'Product item not found' );
288
+		if (($item = reset($items)) === false) {
289
+			throw new \RuntimeException('Product item not found');
290 290
 		}
291 291
 
292
-		$filter = $this->object->createFilter( 'position', '+', 1, 1 );
293
-		$filter = $this->object->addFilterCategory( $filter, $item->getId() );
292
+		$filter = $this->object->createFilter('position', '+', 1, 1);
293
+		$filter = $this->object->addFilterCategory($filter, $item->getId());
294 294
 
295 295
 		$total = 0;
296
-		$results = $this->object->searchItems( $filter, [], $total );
296
+		$results = $this->object->searchItems($filter, [], $total);
297 297
 
298
-		$this->assertEquals( 3, $total );
299
-		$this->assertEquals( 1, count( $results ) );
298
+		$this->assertEquals(3, $total);
299
+		$this->assertEquals(1, count($results));
300 300
 	}
301 301
 
302 302
 
303 303
 	public function testSearchItemsText()
304 304
 	{
305
-		$filter = $this->object->createFilter( 'relevance', '+', 0, 1, 'unittype13' );
306
-		$filter = $this->object->addFilterText( $filter, 'Expresso', 'relevance', '+', 'unittype13' );
305
+		$filter = $this->object->createFilter('relevance', '+', 0, 1, 'unittype13');
306
+		$filter = $this->object->addFilterText($filter, 'Expresso', 'relevance', '+', 'unittype13');
307 307
 
308 308
 		$total = 0;
309
-		$results = $this->object->searchItems( $filter, [], $total );
309
+		$results = $this->object->searchItems($filter, [], $total);
310 310
 
311
-		$this->assertEquals( 2, $total );
312
-		$this->assertEquals( 1, count( $results ) );
311
+		$this->assertEquals(2, $total);
312
+		$this->assertEquals(1, count($results));
313 313
 	}
314 314
 }
Please login to merge, or discard this patch.
controller/frontend/src/Controller/Frontend/Product/Standard.php 2 patches
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -31,42 +31,42 @@  discard block
 block discarded – undo
31 31
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
32 32
 	 * @since 2017.03
33 33
 	 */
34
-	public function addFilterAttribute( \Aimeos\MW\Criteria\Iface $filter, array $attrIds, array $optIds, array $oneIds )
34
+	public function addFilterAttribute(\Aimeos\MW\Criteria\Iface $filter, array $attrIds, array $optIds, array $oneIds)
35 35
 	{
36
-		if( !empty( $attrIds ) )
36
+		if (!empty($attrIds))
37 37
 		{
38
-			$attrIds = $this->validateIds( $attrIds );
38
+			$attrIds = $this->validateIds($attrIds);
39 39
 
40
-			$func = $filter->createFunction( 'index.attributeaggregate', array( $attrIds ) );
40
+			$func = $filter->createFunction('index.attributeaggregate', array($attrIds));
41 41
 			$expr = array(
42
-				$filter->compare( '==', $func, count( $attrIds ) ),
42
+				$filter->compare('==', $func, count($attrIds)),
43 43
 				$filter->getConditions(),
44 44
 			);
45
-			$filter->setConditions( $filter->combine( '&&', $expr ) );
45
+			$filter->setConditions($filter->combine('&&', $expr));
46 46
 		}
47 47
 
48
-		if( !empty( $optIds ) )
48
+		if (!empty($optIds))
49 49
 		{
50
-			$optIds = $this->validateIds( $optIds );
50
+			$optIds = $this->validateIds($optIds);
51 51
 
52
-			$func = $filter->createFunction( 'index.attributeaggregate', array( $optIds ) );
52
+			$func = $filter->createFunction('index.attributeaggregate', array($optIds));
53 53
 			$expr = array(
54
-				$filter->compare( '>', $func, 0 ),
54
+				$filter->compare('>', $func, 0),
55 55
 				$filter->getConditions(),
56 56
 			);
57
-			$filter->setConditions( $filter->combine( '&&', $expr ) );
57
+			$filter->setConditions($filter->combine('&&', $expr));
58 58
 		}
59 59
 
60
-		foreach( $oneIds as $type => $list )
60
+		foreach ($oneIds as $type => $list)
61 61
 		{
62
-			if( ( $list = $this->validateIds( (array) $list ) ) !== [] )
62
+			if (($list = $this->validateIds((array) $list)) !== [])
63 63
 			{
64
-				$func = $filter->createFunction( 'index.attributeaggregate', array( $list ) );
64
+				$func = $filter->createFunction('index.attributeaggregate', array($list));
65 65
 				$expr = array(
66
-					$filter->compare( '>', $func, 0 ),
66
+					$filter->compare('>', $func, 0),
67 67
 					$filter->getConditions(),
68 68
 				);
69
-				$filter->setConditions( $filter->combine( '&&', $expr ) );
69
+				$filter->setConditions($filter->combine('&&', $expr));
70 70
 			}
71 71
 		}
72 72
 
@@ -86,38 +86,38 @@  discard block
 block discarded – undo
86 86
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
87 87
 	 * @since 2017.03
88 88
 	 */
89
-	public function addFilterCategory( \Aimeos\MW\Criteria\Iface $filter, $catId,
90
-		$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $sort = null, $direction = '+', $listtype = 'default' )
89
+	public function addFilterCategory(\Aimeos\MW\Criteria\Iface $filter, $catId,
90
+		$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $sort = null, $direction = '+', $listtype = 'default')
91 91
 	{
92
-		$catIds = ( !is_array( $catId ) ? explode( ',', $catId ) : $catId );
92
+		$catIds = (!is_array($catId) ? explode(',', $catId) : $catId);
93 93
 
94
-		if( $level != \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE )
94
+		if ($level != \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE)
95 95
 		{
96 96
 			$list = [];
97
-			$cntl = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'catalog' );
97
+			$cntl = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'catalog');
98 98
 
99
-			foreach( $catIds as $catId )
99
+			foreach ($catIds as $catId)
100 100
 			{
101
-				$tree = $cntl->getCatalogTree( $catId, [], $level );
102
-				$list = array_merge( $list, $this->getCatalogIdsFromTree( $tree ) );
101
+				$tree = $cntl->getCatalogTree($catId, [], $level);
102
+				$list = array_merge($list, $this->getCatalogIdsFromTree($tree));
103 103
 			}
104 104
 
105 105
 			$catIds = $list;
106 106
 		}
107 107
 
108
-		$expr = array( $filter->compare( '==', 'index.catalog.id', array_unique( $catIds ) ) );
108
+		$expr = array($filter->compare('==', 'index.catalog.id', array_unique($catIds)));
109 109
 		$expr[] = $filter->getConditions();
110 110
 
111
-		if( $sort === 'relevance' )
111
+		if ($sort === 'relevance')
112 112
 		{
113
-			$cmpfunc = $filter->createFunction( 'index.catalog.position', array( $listtype, $catIds ) );
114
-			$expr[] = $filter->compare( '>=', $cmpfunc, 0 );
113
+			$cmpfunc = $filter->createFunction('index.catalog.position', array($listtype, $catIds));
114
+			$expr[] = $filter->compare('>=', $cmpfunc, 0);
115 115
 
116
-			$sortfunc = $filter->createFunction( 'sort:index.catalog.position', array( $listtype, $catIds ) );
117
-			$filter->setSortations( array( $filter->sort( $direction, $sortfunc ) ) );
116
+			$sortfunc = $filter->createFunction('sort:index.catalog.position', array($listtype, $catIds));
117
+			$filter->setSortations(array($filter->sort($direction, $sortfunc)));
118 118
 		}
119 119
 
120
-		$filter->setConditions( $filter->combine( '&&', $expr ) );
120
+		$filter->setConditions($filter->combine('&&', $expr));
121 121
 
122 122
 		return $filter;
123 123
 	}
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
135 135
 	 * @since 2017.03
136 136
 	 */
137
-	public function addFilterText( \Aimeos\MW\Criteria\Iface $filter, $input, $sort = null, $direction = '+', $listtype = 'default' )
137
+	public function addFilterText(\Aimeos\MW\Criteria\Iface $filter, $input, $sort = null, $direction = '+', $listtype = 'default')
138 138
 	{
139 139
 		$langid = $this->getContext()->getLocale()->getLanguageId();
140
-		$cmpfunc = $filter->createFunction( 'index.text.relevance', array( $listtype, $langid, $input ) );
141
-		$expr = array( $filter->compare( '>', $cmpfunc, 0 ), $filter->getConditions() );
140
+		$cmpfunc = $filter->createFunction('index.text.relevance', array($listtype, $langid, $input));
141
+		$expr = array($filter->compare('>', $cmpfunc, 0), $filter->getConditions());
142 142
 
143
-		return $filter->setConditions( $filter->combine( '&&', $expr ) );
143
+		return $filter->setConditions($filter->combine('&&', $expr));
144 144
 	}
145 145
 
146 146
 
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
 	 * @return array Associative list of key values as key and the product count for this key as value
153 153
 	 * @since 2017.03
154 154
 	 */
155
-	public function aggregate( \Aimeos\MW\Criteria\Iface $filter, $key )
155
+	public function aggregate(\Aimeos\MW\Criteria\Iface $filter, $key)
156 156
 	{
157
-		return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->aggregate( $filter, $key );
157
+		return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index')->aggregate($filter, $key);
158 158
 	}
159 159
 
160 160
 
@@ -169,11 +169,11 @@  discard block
 block discarded – undo
169 169
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
170 170
 	 * @since 2017.03
171 171
 	 */
172
-	public function createFilter( $sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default' )
172
+	public function createFilter($sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default')
173 173
 	{
174 174
 		$sortations = [];
175 175
 		$context = $this->getContext();
176
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'index' );
176
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'index');
177 177
 
178 178
 
179 179
 		/** controller/frontend/order/ignore-dates
@@ -188,51 +188,51 @@  discard block
 block discarded – undo
188 188
 		 * @since 2017.08
189 189
 		 * @category Developer
190 190
 		 */
191
-		if( $context->getConfig()->get( 'controller/frontend/product/ignore-dates', false ) )
191
+		if ($context->getConfig()->get('controller/frontend/product/ignore-dates', false))
192 192
 		{
193 193
 			$search = $manager->createSearch();
194
-			$search->setConditions( $search->compare( '>', 'product.status', 0 ) );
194
+			$search->setConditions($search->compare('>', 'product.status', 0));
195 195
 		}
196 196
 		else
197 197
 		{
198
-			$search = $manager->createSearch( true );
198
+			$search = $manager->createSearch(true);
199 199
 		}
200 200
 
201 201
 
202
-		$expr = array( $search->compare( '!=', 'index.catalog.id', null ) );
202
+		$expr = array($search->compare('!=', 'index.catalog.id', null));
203 203
 
204
-		switch( $sort )
204
+		switch ($sort)
205 205
 		{
206 206
 			case 'code':
207
-				$sortations[] = $search->sort( $direction, 'product.code' );
207
+				$sortations[] = $search->sort($direction, 'product.code');
208 208
 				break;
209 209
 
210 210
 			case 'name':
211 211
 				$langid = $context->getLocale()->getLanguageId();
212 212
 
213
-				$cmpfunc = $search->createFunction( 'index.text.value', array( $listtype, $langid, 'name', 'product' ) );
214
-				$expr[] = $search->compare( '>=', $cmpfunc, '' );
213
+				$cmpfunc = $search->createFunction('index.text.value', array($listtype, $langid, 'name', 'product'));
214
+				$expr[] = $search->compare('>=', $cmpfunc, '');
215 215
 
216
-				$sortfunc = $search->createFunction( 'sort:index.text.value', array( $listtype, $langid, 'name' ) );
217
-				$sortations[] = $search->sort( $direction, $sortfunc );
216
+				$sortfunc = $search->createFunction('sort:index.text.value', array($listtype, $langid, 'name'));
217
+				$sortations[] = $search->sort($direction, $sortfunc);
218 218
 				break;
219 219
 
220 220
 			case 'price':
221 221
 				$currencyid = $context->getLocale()->getCurrencyId();
222 222
 
223
-				$cmpfunc = $search->createFunction( 'index.price.value', array( $listtype, $currencyid, 'default' ) );
224
-				$expr[] = $search->compare( '>=', $cmpfunc, '0.00' );
223
+				$cmpfunc = $search->createFunction('index.price.value', array($listtype, $currencyid, 'default'));
224
+				$expr[] = $search->compare('>=', $cmpfunc, '0.00');
225 225
 
226
-				$sortfunc = $search->createFunction( 'sort:index.price.value', array( $listtype, $currencyid, 'default' ) );
227
-				$sortations[] = $search->sort( $direction, $sortfunc );
226
+				$sortfunc = $search->createFunction('sort:index.price.value', array($listtype, $currencyid, 'default'));
227
+				$sortations[] = $search->sort($direction, $sortfunc);
228 228
 				break;
229 229
 		}
230 230
 
231 231
 		$expr[] = $search->getConditions();
232 232
 
233
-		$search->setConditions( $search->combine( '&&', $expr ) );
234
-		$search->setSortations( $sortations );
235
-		$search->setSlice( $start, $size );
233
+		$search->setConditions($search->combine('&&', $expr));
234
+		$search->setSortations($sortations);
235
+		$search->setSlice($start, $size);
236 236
 
237 237
 		return $search;
238 238
 	}
@@ -246,9 +246,9 @@  discard block
 block discarded – undo
246 246
 	 * @return \Aimeos\MShop\Product\Item\Iface Product item including the referenced domains items
247 247
 	 * @since 2017.03
248 248
 	 */
249
-	public function getItem( $productId, array $domains = array( 'attribute', 'media', 'price', 'product', 'product/property', 'text' ) )
249
+	public function getItem($productId, array $domains = array('attribute', 'media', 'price', 'product', 'product/property', 'text'))
250 250
 	{
251
-		return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' )->getItem( $productId, $domains, true );
251
+		return \Aimeos\MShop\Factory::createManager($this->getContext(), 'product')->getItem($productId, $domains, true);
252 252
 	}
253 253
 
254 254
 
@@ -260,19 +260,19 @@  discard block
 block discarded – undo
260 260
 	 * @return \Aimeos\MShop\Product\Item\Iface[] Associative list of product IDs as keys and product items as values
261 261
 	 * @since 2017.03
262 262
 	 */
263
-	public function getItems( array $productIds, array $domains = array( 'media', 'price', 'text' ) )
263
+	public function getItems(array $productIds, array $domains = array('media', 'price', 'text'))
264 264
 	{
265
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' );
265
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product');
266 266
 
267
-		$search = $manager->createSearch( true );
267
+		$search = $manager->createSearch(true);
268 268
 		$expr = array(
269
-			$search->compare( '==', 'product.id', $productIds ),
269
+			$search->compare('==', 'product.id', $productIds),
270 270
 			$search->getConditions(),
271 271
 		);
272
-		$search->setConditions( $search->combine( '&&', $expr ) );
273
-		$search->setSlice( 0, count( $productIds ) );
272
+		$search->setConditions($search->combine('&&', $expr));
273
+		$search->setSlice(0, count($productIds));
274 274
 
275
-		return $manager->searchItems( $search, $domains );
275
+		return $manager->searchItems($search, $domains);
276 276
 	}
277 277
 
278 278
 
@@ -285,9 +285,9 @@  discard block
 block discarded – undo
285 285
 	 * @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface
286 286
 	 * @since 2017.03
287 287
 	 */
288
-	public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null )
288
+	public function searchItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = array('media', 'price', 'text'), &$total = null)
289 289
 	{
290
-		return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->searchItems( $filter, $domains, $total );
290
+		return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index')->searchItems($filter, $domains, $total);
291 291
 	}
292 292
 
293 293
 
@@ -297,12 +297,12 @@  discard block
 block discarded – undo
297 297
 	 * @param \Aimeos\MShop\Catalog\Item\Iface $item Catalog item with children
298 298
 	 * @return array List of catalog IDs
299 299
 	 */
300
-	protected function getCatalogIdsFromTree( \Aimeos\MShop\Catalog\Item\Iface $item )
300
+	protected function getCatalogIdsFromTree(\Aimeos\MShop\Catalog\Item\Iface $item)
301 301
 	{
302
-		$list = array( $item->getId() );
302
+		$list = array($item->getId());
303 303
 
304
-		foreach( $item->getChildren() as $child ) {
305
-			$list = array_merge( $list, $this->getCatalogIdsFromTree( $child ) );
304
+		foreach ($item->getChildren() as $child) {
305
+			$list = array_merge($list, $this->getCatalogIdsFromTree($child));
306 306
 		}
307 307
 
308 308
 		return $list;
@@ -315,13 +315,13 @@  discard block
 block discarded – undo
315 315
 	 * @param array $ids List of IDs to validate
316 316
 	 * @return array List of validated IDs
317 317
 	 */
318
-	protected function validateIds( array $ids )
318
+	protected function validateIds(array $ids)
319 319
 	{
320 320
 		$list = [];
321 321
 
322
-		foreach( $ids as $id )
322
+		foreach ($ids as $id)
323 323
 		{
324
-			if( $id != '' ) {
324
+			if ($id != '') {
325 325
 				$list[] = (int) $id;
326 326
 			}
327 327
 		}
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -192,8 +192,7 @@
 block discarded – undo
192 192
 		{
193 193
 			$search = $manager->createSearch();
194 194
 			$search->setConditions( $search->compare( '>', 'product.status', 0 ) );
195
-		}
196
-		else
195
+		} else
197 196
 		{
198 197
 			$search = $manager->createSearch( true );
199 198
 		}
Please login to merge, or discard this patch.