Completed
Push — master ( cbc921...0b1729 )
by Aimeos
02:05
created
tests/Controller/Common/Catalog/Import/Csv/Processor/Text/StandardTest.php 1 patch
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -17,16 +17,16 @@  discard block
 block discarded – undo
17 17
 
18 18
 	protected function setUp()
19 19
 	{
20
-		\Aimeos\MShop::cache( true );
20
+		\Aimeos\MShop::cache(true);
21 21
 
22 22
 		$this->context = \TestHelperCntl::getContext();
23
-		$this->endpoint = new \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Done( $this->context, [] );
23
+		$this->endpoint = new \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Done($this->context, []);
24 24
 	}
25 25
 
26 26
 
27 27
 	protected function tearDown()
28 28
 	{
29
-		\Aimeos\MShop::cache( false );
29
+		\Aimeos\MShop::cache(false);
30 30
 		\Aimeos\MShop::clear();
31 31
 	}
32 32
 
@@ -49,31 +49,31 @@  discard block
 block discarded – undo
49 49
 			4 => 1,
50 50
 		);
51 51
 
52
-		$catalog = $this->create( 'job_csv_test' );
52
+		$catalog = $this->create('job_csv_test');
53 53
 
54
-		$object = new \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Text\Standard( $this->context, $mapping, $this->endpoint );
55
-		$object->process( $catalog, $data );
54
+		$object = new \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Text\Standard($this->context, $mapping, $this->endpoint);
55
+		$object->process($catalog, $data);
56 56
 
57 57
 
58 58
 		$listItems = $catalog->getListItems();
59
-		$listItem = reset( $listItems );
59
+		$listItem = reset($listItems);
60 60
 
61
-		$this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem );
62
-		$this->assertEquals( 1, count( $listItems ) );
61
+		$this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem);
62
+		$this->assertEquals(1, count($listItems));
63 63
 
64
-		$this->assertEquals( 1, $listItem->getStatus() );
65
-		$this->assertEquals( 0, $listItem->getPosition() );
66
-		$this->assertEquals( 'text', $listItem->getDomain() );
67
-		$this->assertEquals( 'default', $listItem->getType() );
64
+		$this->assertEquals(1, $listItem->getStatus());
65
+		$this->assertEquals(0, $listItem->getPosition());
66
+		$this->assertEquals('text', $listItem->getDomain());
67
+		$this->assertEquals('default', $listItem->getType());
68 68
 
69 69
 		$refItem = $listItem->getRefItem();
70 70
 
71
-		$this->assertEquals( 1, $refItem->getStatus() );
72
-		$this->assertEquals( 'name', $refItem->getType() );
73
-		$this->assertEquals( 'test text', $refItem->getLabel() );
74
-		$this->assertEquals( 'Job CSV test', $refItem->getContent() );
75
-		$this->assertEquals( 'de', $refItem->getLanguageId() );
76
-		$this->assertEquals( 1, $refItem->getStatus() );
71
+		$this->assertEquals(1, $refItem->getStatus());
72
+		$this->assertEquals('name', $refItem->getType());
73
+		$this->assertEquals('test text', $refItem->getLabel());
74
+		$this->assertEquals('Job CSV test', $refItem->getContent());
75
+		$this->assertEquals('de', $refItem->getLanguageId());
76
+		$this->assertEquals(1, $refItem->getStatus());
77 77
 	}
78 78
 
79 79
 
@@ -101,27 +101,27 @@  discard block
 block discarded – undo
101 101
 			7 => 'Long: Job CSV test 2',
102 102
 		);
103 103
 
104
-		$catalog = $this->create( 'job_csv_test' );
104
+		$catalog = $this->create('job_csv_test');
105 105
 
106
-		$object = new \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Text\Standard( $this->context, $mapping, $this->endpoint );
107
-		$object->process( $catalog, $data );
106
+		$object = new \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Text\Standard($this->context, $mapping, $this->endpoint);
107
+		$object->process($catalog, $data);
108 108
 
109 109
 
110 110
 		$pos = 0;
111 111
 		$listItems = $catalog->getListItems();
112 112
 		$expected = array(
113
-			0 => array( 'name', 'Job CSV test' ),
114
-			1 => array( 'short', 'Short: Job CSV test' ),
115
-			2 => array( 'long', 'Long: Job CSV test' ),
116
-			3 => array( 'long', 'Long: Job CSV test 2' ),
113
+			0 => array('name', 'Job CSV test'),
114
+			1 => array('short', 'Short: Job CSV test'),
115
+			2 => array('long', 'Long: Job CSV test'),
116
+			3 => array('long', 'Long: Job CSV test 2'),
117 117
 		);
118 118
 
119
-		$this->assertEquals( 4, count( $listItems ) );
119
+		$this->assertEquals(4, count($listItems));
120 120
 
121
-		foreach( $listItems as $listItem )
121
+		foreach ($listItems as $listItem)
122 122
 		{
123
-			$this->assertEquals( $expected[$pos][0], $listItem->getRefItem()->getType() );
124
-			$this->assertEquals( $expected[$pos][1], $listItem->getRefItem()->getContent() );
123
+			$this->assertEquals($expected[$pos][0], $listItem->getRefItem()->getType());
124
+			$this->assertEquals($expected[$pos][1], $listItem->getRefItem()->getContent());
125 125
 			$pos++;
126 126
 		}
127 127
 	}
@@ -144,21 +144,21 @@  discard block
 block discarded – undo
144 144
 			1 => 'Short: Job CSV test',
145 145
 		);
146 146
 
147
-		$catalog = $this->create( 'job_csv_test' );
147
+		$catalog = $this->create('job_csv_test');
148 148
 
149
-		$object = new \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Text\Standard( $this->context, $mapping, $this->endpoint );
150
-		$object->process( $catalog, $data );
151
-		$object->process( $catalog, $dataUpdate );
149
+		$object = new \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Text\Standard($this->context, $mapping, $this->endpoint);
150
+		$object->process($catalog, $data);
151
+		$object->process($catalog, $dataUpdate);
152 152
 
153 153
 
154 154
 		$listItems = $catalog->getListItems();
155
-		$listItem = reset( $listItems );
155
+		$listItem = reset($listItems);
156 156
 
157
-		$this->assertEquals( 1, count( $listItems ) );
158
-		$this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem );
157
+		$this->assertEquals(1, count($listItems));
158
+		$this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem);
159 159
 
160
-		$this->assertEquals( 'short', $listItem->getRefItem()->getType() );
161
-		$this->assertEquals( 'Short: Job CSV test', $listItem->getRefItem()->getContent() );
160
+		$this->assertEquals('short', $listItem->getRefItem()->getType());
161
+		$this->assertEquals('Short: Job CSV test', $listItem->getRefItem()->getContent());
162 162
 	}
163 163
 
164 164
 
@@ -174,18 +174,18 @@  discard block
 block discarded – undo
174 174
 			1 => 'Job CSV test',
175 175
 		);
176 176
 
177
-		$catalog = $this->create( 'job_csv_test' );
177
+		$catalog = $this->create('job_csv_test');
178 178
 
179
-		$object = new \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Text\Standard( $this->context, $mapping, $this->endpoint );
180
-		$object->process( $catalog, $data );
179
+		$object = new \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Text\Standard($this->context, $mapping, $this->endpoint);
180
+		$object->process($catalog, $data);
181 181
 
182
-		$object = new \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Text\Standard( $this->context, [], $this->endpoint );
183
-		$object->process( $catalog, [] );
182
+		$object = new \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Text\Standard($this->context, [], $this->endpoint);
183
+		$object->process($catalog, []);
184 184
 
185 185
 
186 186
 		$listItems = $catalog->getListItems();
187 187
 
188
-		$this->assertEquals( 0, count( $listItems ) );
188
+		$this->assertEquals(0, count($listItems));
189 189
 	}
190 190
 
191 191
 
@@ -205,15 +205,15 @@  discard block
 block discarded – undo
205 205
 			3 => '',
206 206
 		);
207 207
 
208
-		$catalog = $this->create( 'job_csv_test' );
208
+		$catalog = $this->create('job_csv_test');
209 209
 
210
-		$object = new \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Text\Standard( $this->context, $mapping, $this->endpoint );
211
-		$object->process( $catalog, $data );
210
+		$object = new \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Text\Standard($this->context, $mapping, $this->endpoint);
211
+		$object->process($catalog, $data);
212 212
 
213 213
 
214 214
 		$listItems = $catalog->getListItems();
215 215
 
216
-		$this->assertEquals( 1, count( $listItems ) );
216
+		$this->assertEquals(1, count($listItems));
217 217
 	}
218 218
 
219 219
 
@@ -237,26 +237,26 @@  discard block
 block discarded – undo
237 237
 			5 => 'default',
238 238
 		);
239 239
 
240
-		$this->context->getConfig()->set( 'controller/common/catalog/import/csv/processor/text/listtypes', array( 'default' ) );
240
+		$this->context->getConfig()->set('controller/common/catalog/import/csv/processor/text/listtypes', array('default'));
241 241
 
242
-		$catalog = $this->create( 'job_csv_test' );
242
+		$catalog = $this->create('job_csv_test');
243 243
 
244
-		$object = new \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Text\Standard( $this->context, $mapping, $this->endpoint );
244
+		$object = new \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Text\Standard($this->context, $mapping, $this->endpoint);
245 245
 
246
-		$this->setExpectedException( '\Aimeos\Controller\Common\Exception' );
247
-		$object->process( $catalog, $data );
246
+		$this->setExpectedException('\Aimeos\Controller\Common\Exception');
247
+		$object->process($catalog, $data);
248 248
 	}
249 249
 
250 250
 
251 251
 	/**
252 252
 	 * @param string $code
253 253
 	 */
254
-	protected function create( $code )
254
+	protected function create($code)
255 255
 	{
256
-		$manager = \Aimeos\MShop\Catalog\Manager\Factory::create( $this->context );
256
+		$manager = \Aimeos\MShop\Catalog\Manager\Factory::create($this->context);
257 257
 
258 258
 		$item = $manager->createItem();
259
-		$item->setCode( $code );
259
+		$item->setCode($code);
260 260
 
261 261
 		return $item;
262 262
 	}
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Product/Import/Csv/Standard.php 1 patch
Spacing   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -30,14 +30,14 @@  discard block
 block discarded – undo
30 30
 	 * @param \Aimeos\MShop\Context\Item\Iface $context MShop context object
31 31
 	 * @param \Aimeos\Bootstrap $aimeos \Aimeos\Bootstrap main object
32 32
 	 */
33
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos )
33
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos)
34 34
 	{
35
-		parent::__construct( $context, $aimeos );
35
+		parent::__construct($context, $aimeos);
36 36
 
37
-		$manager = \Aimeos\MShop::create( $context, 'product/type' );
38
-		$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
37
+		$manager = \Aimeos\MShop::create($context, 'product/type');
38
+		$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
39 39
 
40
-		foreach( $manager->searchItems( $search ) as $item ) {
40
+		foreach ($manager->searchItems($search) as $item) {
41 41
 			$this->types[$item->getCode()] = $item->getCode();
42 42
 		}
43 43
 	}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	public function getName()
52 52
 	{
53
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Product import CSV' );
53
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Product import CSV');
54 54
 	}
55 55
 
56 56
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	 */
62 62
 	public function getDescription()
63 63
 	{
64
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Imports new and updates existing products from CSV files' );
64
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Imports new and updates existing products from CSV files');
65 65
 	}
66 66
 
67 67
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 		$context = $this->getContext();
77 77
 		$config = $context->getConfig();
78 78
 		$logger = $context->getLogger();
79
-		$domains = array( 'attribute', 'media', 'price', 'product', 'product/property', 'text' );
79
+		$domains = array('attribute', 'media', 'price', 'product', 'product/property', 'text');
80 80
 		$mappings = $this->getDefaultMapping();
81 81
 
82 82
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 		 * @see controller/common/product/import/csv/converter
97 97
 		 * @see controller/common/product/import/csv/max-size
98 98
 		 */
99
-		$domains = $config->get( 'controller/common/product/import/csv/domains', $domains );
99
+		$domains = $config->get('controller/common/product/import/csv/domains', $domains);
100 100
 
101 101
 		/** controller/jobs/product/import/csv/domains
102 102
 		 * List of item domain names that should be retrieved along with the product items
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 		 * @see controller/jobs/product/import/csv/backup
117 117
 		 * @see controller/common/product/import/csv/max-size
118 118
 		 */
119
-		$domains = $config->get( 'controller/jobs/product/import/csv/domains', $domains );
119
+		$domains = $config->get('controller/jobs/product/import/csv/domains', $domains);
120 120
 
121 121
 
122 122
 		/** controller/common/product/import/csv/mapping
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 		 * @see controller/common/product/import/csv/converter
142 142
 		 * @see controller/common/product/import/csv/max-size
143 143
 		 */
144
-		$mappings = $config->get( 'controller/common/product/import/csv/mapping', $mappings );
144
+		$mappings = $config->get('controller/common/product/import/csv/mapping', $mappings);
145 145
 
146 146
 		/** controller/jobs/product/import/csv/mapping
147 147
 		 * List of mappings between the position in the CSV file and item keys
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 		 * @see controller/jobs/product/import/csv/backup
162 162
 		 * @see controller/common/product/import/csv/max-size
163 163
 		 */
164
-		$mappings = $config->get( 'controller/jobs/product/import/csv/mapping', $mappings );
164
+		$mappings = $config->get('controller/jobs/product/import/csv/mapping', $mappings);
165 165
 
166 166
 
167 167
 		/** controller/common/product/import/csv/converter
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 		 * @see controller/common/product/import/csv/mapping
204 204
 		 * @see controller/common/product/import/csv/max-size
205 205
 		 */
206
-		$converters = $config->get( 'controller/common/product/import/csv/converter', [] );
206
+		$converters = $config->get('controller/common/product/import/csv/converter', []);
207 207
 
208 208
 		/** controller/jobs/product/import/csv/converter
209 209
 		 * List of converter names for the values at the position in the CSV file
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 		 * @see controller/jobs/product/import/csv/backup
224 224
 		 * @see controller/common/product/import/csv/max-size
225 225
 		 */
226
-		$converters = $config->get( 'controller/jobs/product/import/csv/converter', $converters );
226
+		$converters = $config->get('controller/jobs/product/import/csv/converter', $converters);
227 227
 
228 228
 
229 229
 		/** controller/common/product/import/csv/max-size
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 		 * @see controller/common/product/import/csv/mapping
244 244
 		 * @see controller/common/product/import/csv/converter
245 245
 		 */
246
-		$maxcnt = (int) $config->get( 'controller/common/product/import/csv/max-size', 1000 );
246
+		$maxcnt = (int) $config->get('controller/common/product/import/csv/max-size', 1000);
247 247
 
248 248
 
249 249
 		/** controller/jobs/product/import/csv/skip-lines
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 		 * @see controller/jobs/product/import/csv/backup
266 266
 		 * @see controller/common/product/import/csv/max-size
267 267
 		 */
268
-		$skiplines = (int) $config->get( 'controller/jobs/product/import/csv/skip-lines', 0 );
268
+		$skiplines = (int) $config->get('controller/jobs/product/import/csv/skip-lines', 0);
269 269
 
270 270
 
271 271
 		/** controller/jobs/product/import/csv/strict
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 		 * @see controller/jobs/product/import/csv/backup
290 290
 		 * @see controller/common/product/import/csv/max-size
291 291
 		 */
292
-		$strict = (bool) $config->get( 'controller/jobs/product/import/csv/strict', true );
292
+		$strict = (bool) $config->get('controller/jobs/product/import/csv/strict', true);
293 293
 
294 294
 
295 295
 		/** controller/jobs/product/import/csv/backup
@@ -322,74 +322,74 @@  discard block
 block discarded – undo
322 322
 		 * @see controller/jobs/product/import/csv/strict
323 323
 		 * @see controller/common/product/import/csv/max-size
324 324
 		 */
325
-		$backup = $config->get( 'controller/jobs/product/import/csv/backup' );
325
+		$backup = $config->get('controller/jobs/product/import/csv/backup');
326 326
 
327 327
 
328
-		if( !isset( $mappings['item'] ) || !is_array( $mappings['item'] ) )
328
+		if (!isset($mappings['item']) || !is_array($mappings['item']))
329 329
 		{
330
-			$msg = sprintf( 'Required mapping key "%1$s" is missing or contains no array', 'item' );
331
-			throw new \Aimeos\Controller\Jobs\Exception( $msg );
330
+			$msg = sprintf('Required mapping key "%1$s" is missing or contains no array', 'item');
331
+			throw new \Aimeos\Controller\Jobs\Exception($msg);
332 332
 		}
333 333
 
334 334
 		try
335 335
 		{
336 336
 			$procMappings = $mappings;
337
-			unset( $procMappings['item'] );
337
+			unset($procMappings['item']);
338 338
 
339
-			$codePos = $this->getCodePosition( $mappings['item'] );
340
-			$convlist = $this->getConverterList( $converters );
341
-			$processor = $this->getProcessors( $procMappings );
339
+			$codePos = $this->getCodePosition($mappings['item']);
340
+			$convlist = $this->getConverterList($converters);
341
+			$processor = $this->getProcessors($procMappings);
342 342
 			$container = $this->getContainer();
343 343
 			$path = $container->getName();
344 344
 
345
-			$msg = sprintf( 'Started product import from "%1$s" (%2$s)', $path, __CLASS__ );
346
-			$logger->log( $msg, \Aimeos\MW\Logger\Base::NOTICE );
345
+			$msg = sprintf('Started product import from "%1$s" (%2$s)', $path, __CLASS__);
346
+			$logger->log($msg, \Aimeos\MW\Logger\Base::NOTICE);
347 347
 
348
-			foreach( $container as $content )
348
+			foreach ($container as $content)
349 349
 			{
350 350
 				$name = $content->getName();
351 351
 
352
-				for( $i = 0; $i < $skiplines; $i++ ) {
352
+				for ($i = 0; $i < $skiplines; $i++) {
353 353
 					$content->next();
354 354
 				}
355 355
 
356
-				while( ( $data = $this->getData( $content, $maxcnt, $codePos ) ) !== [] )
356
+				while (($data = $this->getData($content, $maxcnt, $codePos)) !== [])
357 357
 				{
358
-					$data = $this->convertData( $convlist, $data );
359
-					$products = $this->getProducts( array_keys( $data ), $domains );
360
-					$errcnt = $this->import( $products, $data, $mappings['item'], $processor, $strict );
361
-					$chunkcnt = count( $data );
358
+					$data = $this->convertData($convlist, $data);
359
+					$products = $this->getProducts(array_keys($data), $domains);
360
+					$errcnt = $this->import($products, $data, $mappings['item'], $processor, $strict);
361
+					$chunkcnt = count($data);
362 362
 
363 363
 					$msg = 'Imported product lines from "%1$s": %2$d/%3$d (%4$s)';
364
-					$logger->log( sprintf( $msg, $name, $chunkcnt - $errcnt, $chunkcnt, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE );
364
+					$logger->log(sprintf($msg, $name, $chunkcnt - $errcnt, $chunkcnt, __CLASS__), \Aimeos\MW\Logger\Base::NOTICE);
365 365
 
366 366
 					$errors += $errcnt;
367 367
 					$total += $chunkcnt;
368
-					unset( $products, $data );
368
+					unset($products, $data);
369 369
 				}
370 370
 			}
371 371
 
372 372
 			$container->close();
373 373
 		}
374
-		catch( \Exception $e )
374
+		catch (\Exception $e)
375 375
 		{
376
-			$logger->log( 'Product import error: ' . $e->getMessage() );
377
-			$logger->log( $e->getTraceAsString() );
376
+			$logger->log('Product import error: ' . $e->getMessage());
377
+			$logger->log($e->getTraceAsString());
378 378
 
379
-			throw new \Aimeos\Controller\Jobs\Exception( $e->getMessage() );
379
+			throw new \Aimeos\Controller\Jobs\Exception($e->getMessage());
380 380
 		}
381 381
 
382 382
 		$msg = 'Finished product import from "%1$s": %2$d successful, %3$s errors, %4$s total (%5$s)';
383
-		$logger->log( sprintf( $msg, $path, $total - $errors, $errors, $total, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE );
383
+		$logger->log(sprintf($msg, $path, $total - $errors, $errors, $total, __CLASS__), \Aimeos\MW\Logger\Base::NOTICE);
384 384
 
385
-		if( $errors > 0 )
385
+		if ($errors > 0)
386 386
 		{
387
-			$msg = sprintf( 'Invalid product lines in "%1$s": %2$d/%3$d', $path, $errors, $total );
388
-			throw new \Aimeos\Controller\Jobs\Exception( $msg );
387
+			$msg = sprintf('Invalid product lines in "%1$s": %2$d/%3$d', $path, $errors, $total);
388
+			throw new \Aimeos\Controller\Jobs\Exception($msg);
389 389
 		}
390 390
 
391
-		if( !empty( $backup ) && @rename( $path, strftime( $backup ) ) === false ) {
392
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Unable to move imported file' ) );
391
+		if (!empty($backup) && @rename($path, strftime($backup)) === false) {
392
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('Unable to move imported file'));
393 393
 		}
394 394
 	}
395 395
 
@@ -401,16 +401,16 @@  discard block
 block discarded – undo
401 401
 	 * @return integer Position of the "product.code" column
402 402
 	 * @throws \Aimeos\Controller\Jobs\Exception If no mapping for "product.code" is found
403 403
 	 */
404
-	protected function getCodePosition( array $mapping )
404
+	protected function getCodePosition(array $mapping)
405 405
 	{
406
-		foreach( $mapping as $pos => $key )
406
+		foreach ($mapping as $pos => $key)
407 407
 		{
408
-			if( $key === 'product.code' ) {
408
+			if ($key === 'product.code') {
409 409
 				return $pos;
410 410
 			}
411 411
 		}
412 412
 
413
-		throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'No "product.code" column in CSV mapping found' ) );
413
+		throw new \Aimeos\Controller\Jobs\Exception(sprintf('No "product.code" column in CSV mapping found'));
414 414
 	}
415 415
 
416 416
 
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 		 * @see controller/jobs/product/import/csv/container/content
446 446
 		 * @see controller/jobs/product/import/csv/container/options
447 447
 		 */
448
-		$location = $config->get( 'controller/jobs/product/import/csv/location' );
448
+		$location = $config->get('controller/jobs/product/import/csv/location');
449 449
 
450 450
 		/** controller/jobs/product/import/csv/container/type
451 451
 		 * Nave of the container type to read the data from
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 		 * @see controller/jobs/product/import/csv/container/content
469 469
 		 * @see controller/jobs/product/import/csv/container/options
470 470
 		 */
471
-		$container = $config->get( 'controller/jobs/product/import/csv/container/type', 'Directory' );
471
+		$container = $config->get('controller/jobs/product/import/csv/container/type', 'Directory');
472 472
 
473 473
 		/** controller/jobs/product/import/csv/container/content
474 474
 		 * Name of the content type inside the container to read the data from
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
 		 * @see controller/jobs/product/import/csv/container/type
490 490
 		 * @see controller/jobs/product/import/csv/container/options
491 491
 		 */
492
-		$content = $config->get( 'controller/jobs/product/import/csv/container/content', 'CSV' );
492
+		$content = $config->get('controller/jobs/product/import/csv/container/content', 'CSV');
493 493
 
494 494
 		/** controller/jobs/product/import/csv/container/options
495 495
 		 * List of file container options for the product import files
@@ -507,15 +507,15 @@  discard block
 block discarded – undo
507 507
 		 * @see controller/jobs/product/import/csv/container/content
508 508
 		 * @see controller/jobs/product/import/csv/container/type
509 509
 		 */
510
-		$options = $config->get( 'controller/jobs/product/import/csv/container/options', [] );
510
+		$options = $config->get('controller/jobs/product/import/csv/container/options', []);
511 511
 
512
-		if( $location === null )
512
+		if ($location === null)
513 513
 		{
514
-			$msg = sprintf( 'Required configuration for "%1$s" is missing', 'controller/jobs/product/import/csv/location' );
515
-			throw new \Aimeos\Controller\Jobs\Exception( $msg );
514
+			$msg = sprintf('Required configuration for "%1$s" is missing', 'controller/jobs/product/import/csv/location');
515
+			throw new \Aimeos\Controller\Jobs\Exception($msg);
516 516
 		}
517 517
 
518
-		return \Aimeos\MW\Container\Factory::getContainer( $location, $container, $content, $options );
518
+		return \Aimeos\MW\Container\Factory::getContainer($location, $container, $content, $options);
519 519
 	}
520 520
 
521 521
 
@@ -530,68 +530,68 @@  discard block
 block discarded – undo
530 530
 	 * @return integer Number of products that couldn't be imported
531 531
 	 * @throws \Aimeos\Controller\Jobs\Exception
532 532
 	 */
533
-	protected function import( array $products, array $data, array $mapping,
534
-		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor, $strict )
533
+	protected function import(array $products, array $data, array $mapping,
534
+		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor, $strict)
535 535
 	{
536 536
 		$items = [];
537 537
 		$errors = 0;
538 538
 		$context = $this->getContext();
539
-		$manager = \Aimeos\MShop::create( $context, 'product' );
540
-		$indexManager = \Aimeos\MShop::create( $context, 'index' );
539
+		$manager = \Aimeos\MShop::create($context, 'product');
540
+		$indexManager = \Aimeos\MShop::create($context, 'index');
541 541
 
542
-		foreach( $data as $code => $list )
542
+		foreach ($data as $code => $list)
543 543
 		{
544 544
 			$manager->begin();
545 545
 
546 546
 			try
547 547
 			{
548
-				$code = trim( $code );
548
+				$code = trim($code);
549 549
 
550
-				if( isset( $products[$code] ) ) {
550
+				if (isset($products[$code])) {
551 551
 					$product = $products[$code];
552 552
 				} else {
553 553
 					$product = $manager->createItem();
554 554
 				}
555 555
 
556
-				$map = $this->getMappedChunk( $list, $mapping );
556
+				$map = $this->getMappedChunk($list, $mapping);
557 557
 
558
-				if( isset( $map[0] ) )
558
+				if (isset($map[0]))
559 559
 				{
560 560
 					$map = $map[0]; // there can only be one chunk for the base product data
561
-					$map['product.type'] = $this->getValue( $map, 'product.type', 'default' );
561
+					$map['product.type'] = $this->getValue($map, 'product.type', 'default');
562 562
 
563
-					if( !in_array( $map['product.type'], $this->types ) )
563
+					if (!in_array($map['product.type'], $this->types))
564 564
 					{
565
-						$msg = sprintf( 'Invalid product type "%1$s"', $map['product.type'] );
566
-						throw new \Aimeos\Controller\Jobs\Exception( $msg );
565
+						$msg = sprintf('Invalid product type "%1$s"', $map['product.type']);
566
+						throw new \Aimeos\Controller\Jobs\Exception($msg);
567 567
 					}
568 568
 
569
-					$product = $manager->saveItem( $product->fromArray( $map ) );
569
+					$product = $manager->saveItem($product->fromArray($map));
570 570
 
571
-					$list = $processor->process( $product, $list );
571
+					$list = $processor->process($product, $list);
572 572
 
573
-					$product = $manager->saveItem( $product );
573
+					$product = $manager->saveItem($product);
574 574
 					$items[$product->getId()] = $product;
575 575
 				}
576 576
 
577 577
 				$manager->commit();
578 578
 			}
579
-			catch( \Exception $e )
579
+			catch (\Exception $e)
580 580
 			{
581 581
 				$manager->rollback();
582 582
 
583
-				$msg = sprintf( 'Unable to import product with code "%1$s": %2$s', $code, $e->getMessage() );
584
-				$context->getLogger()->log( $msg );
583
+				$msg = sprintf('Unable to import product with code "%1$s": %2$s', $code, $e->getMessage());
584
+				$context->getLogger()->log($msg);
585 585
 
586 586
 				$errors++;
587 587
 			}
588 588
 
589
-			if( $strict && !empty( $list ) ) {
590
-				$context->getLogger()->log( 'Not imported: ' . print_r( $list, true ) );
589
+			if ($strict && !empty($list)) {
590
+				$context->getLogger()->log('Not imported: ' . print_r($list, true));
591 591
 			}
592 592
 		}
593 593
 
594
-		$indexManager->rebuildIndex( $items );
594
+		$indexManager->rebuildIndex($items);
595 595
 
596 596
 		return $errors;
597 597
 	}
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Product/Export/Sitemap/Standard.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	public function getName()
30 30
 	{
31
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Product site map' );
31
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Product site map');
32 32
 	}
33 33
 
34 34
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	public function getDescription()
41 41
 	{
42
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Creates a product site map for search engines' );
42
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Creates a product site map for search engines');
43 43
 	}
44 44
 
45 45
 
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
 	{
53 53
 		$container = $this->createContainer();
54 54
 
55
-		$files = $this->export( $container );
56
-		$this->createSitemapIndex( $container, $files );
55
+		$files = $this->export($container);
56
+		$this->createSitemapIndex($container, $files);
57 57
 
58 58
 		$container->close();
59 59
 	}
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 * @param \Aimeos\MW\Container\Content\Iface $content File content object
66 66
 	 * @param \Aimeos\MShop\Product\Item\Iface[] $items List of product items
67 67
 	 */
68
-	protected function addItems( \Aimeos\MW\Container\Content\Iface $content, array $items )
68
+	protected function addItems(\Aimeos\MW\Container\Content\Iface $content, array $items)
69 69
 	{
70 70
 		$config = $this->getContext()->getConfig();
71 71
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 		 * @see controller/jobs/product/export/sitemap/max-items
97 97
 		 * @see controller/jobs/product/export/sitemap/max-query
98 98
 		 */
99
-		$changefreq = $config->get( 'controller/jobs/product/export/sitemap/changefreq', 'daily' );
99
+		$changefreq = $config->get('controller/jobs/product/export/sitemap/changefreq', 'daily');
100 100
 
101 101
 		/** controller/jobs/product/export/sitemap/standard/template-items
102 102
 		 * Relative path to the XML items template of the product site map job controller.
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 		$view->siteItems = $items;
130 130
 		$view->siteFreq = $changefreq;
131 131
 
132
-		$content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) );
132
+		$content->add($view->render($context->getConfig()->get($tplconf, $default)));
133 133
 	}
134 134
 
135 135
 
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 		 * @see controller/jobs/product/export/sitemap/max-query
176 176
 		 * @see controller/jobs/product/export/sitemap/changefreq
177 177
 		 */
178
-		$location = $config->get( 'controller/jobs/product/export/sitemap/location' );
178
+		$location = $config->get('controller/jobs/product/export/sitemap/location');
179 179
 
180 180
 		/** controller/jobs/product/export/sitemap/container/options
181 181
 		 * List of file container options for the site map files
@@ -196,16 +196,16 @@  discard block
 block discarded – undo
196 196
 		 * @see controller/jobs/product/export/sitemap/max-query
197 197
 		 * @see controller/jobs/product/export/sitemap/changefreq
198 198
 		 */
199
-		$default = array( 'gzip-mode' => 'wb' );
200
-		$options = $config->get( 'controller/jobs/product/export/sitemap/container/options', $default );
199
+		$default = array('gzip-mode' => 'wb');
200
+		$options = $config->get('controller/jobs/product/export/sitemap/container/options', $default);
201 201
 
202
-		if( $location === null )
202
+		if ($location === null)
203 203
 		{
204
-			$msg = sprintf( 'Required configuration for "%1$s" is missing', 'controller/jobs/product/export/sitemap/location' );
205
-			throw new \Aimeos\Controller\Jobs\Exception( $msg );
204
+			$msg = sprintf('Required configuration for "%1$s" is missing', 'controller/jobs/product/export/sitemap/location');
205
+			throw new \Aimeos\Controller\Jobs\Exception($msg);
206 206
 		}
207 207
 
208
-		return \Aimeos\MW\Container\Factory::getContainer( $location, 'Directory', 'Gzip', $options );
208
+		return \Aimeos\MW\Container\Factory::getContainer($location, 'Directory', 'Gzip', $options);
209 209
 	}
210 210
 
211 211
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	 * @param integer $filenum New file number
217 217
 	 * @return \Aimeos\MW\Container\Content\Iface New content object
218 218
 	 */
219
-	protected function createContent( \Aimeos\MW\Container\Iface $container, $filenum )
219
+	protected function createContent(\Aimeos\MW\Container\Iface $container, $filenum)
220 220
 	{
221 221
 		/** controller/jobs/product/export/sitemap/standard/template-header
222 222
 		 * Relative path to the XML site map header template of the product site map job controller.
@@ -246,9 +246,9 @@  discard block
 block discarded – undo
246 246
 		$context = $this->getContext();
247 247
 		$view = $context->getView();
248 248
 
249
-		$content = $container->create( $this->getFilename( $filenum ) );
250
-		$content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) );
251
-		$container->add( $content );
249
+		$content = $container->create($this->getFilename($filenum));
250
+		$content->add($view->render($context->getConfig()->get($tplconf, $default)));
251
+		$container->add($content);
252 252
 
253 253
 		return $content;
254 254
 	}
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 	 *
260 260
 	 * @param \Aimeos\MW\Container\Content\Iface $content
261 261
 	 */
262
-	protected function closeContent( \Aimeos\MW\Container\Content\Iface $content )
262
+	protected function closeContent(\Aimeos\MW\Container\Content\Iface $content)
263 263
 	{
264 264
 		/** controller/jobs/product/export/sitemap/standard/template-footer
265 265
 		 * Relative path to the XML site map footer template of the product site map job controller.
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 		$context = $this->getContext();
290 290
 		$view = $context->getView();
291 291
 
292
-		$content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) );
292
+		$content->add($view->render($context->getConfig()->get($tplconf, $default)));
293 293
 	}
294 294
 
295 295
 
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	 * @param \Aimeos\MW\Container\Iface $container File container object
300 300
 	 * @param array $files List of generated site map file names
301 301
 	 */
302
-	protected function createSitemapIndex( \Aimeos\MW\Container\Iface $container, array $files )
302
+	protected function createSitemapIndex(\Aimeos\MW\Container\Iface $container, array $files)
303 303
 	{
304 304
 		/** controller/jobs/product/export/sitemap/standard/template-index
305 305
 		 * Relative path to the XML site map index template of the product site map job controller.
@@ -331,9 +331,9 @@  discard block
 block discarded – undo
331 331
 
332 332
 		$view->siteFiles = $files;
333 333
 
334
-		$content = $container->create( 'aimeos-sitemap-index.xml' );
335
-		$content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) );
336
-		$container->add( $content );
334
+		$content = $container->create('aimeos-sitemap-index.xml');
335
+		$content->add($view->render($context->getConfig()->get($tplconf, $default)));
336
+		$container->add($content);
337 337
 	}
338 338
 
339 339
 
@@ -344,44 +344,44 @@  discard block
 block discarded – undo
344 344
 	 * @param boolean $default True to filter exported products by default criteria
345 345
 	 * @return array List of content (file) names
346 346
 	 */
347
-	protected function export( \Aimeos\MW\Container\Iface $container, $default = true )
347
+	protected function export(\Aimeos\MW\Container\Iface $container, $default = true)
348 348
 	{
349
-		$domains = $this->getConfig( 'domains', [] );
350
-		$maxItems = $this->getConfig( 'max-items', 10000 );
351
-		$maxQuery = $this->getConfig( 'max-query', 1000 );
349
+		$domains = $this->getConfig('domains', []);
350
+		$maxItems = $this->getConfig('max-items', 10000);
351
+		$maxQuery = $this->getConfig('max-query', 1000);
352 352
 
353 353
 		$start = 0; $filenum = 1;
354 354
 		$names = [];
355 355
 
356
-		$manager = \Aimeos\MShop::create( $this->getContext(), 'index' );
356
+		$manager = \Aimeos\MShop::create($this->getContext(), 'index');
357 357
 
358
-		$search = $manager->createSearch( $default );
359
-		$search->setConditions( $search->compare( '!=', 'index.catalog.id', null ) );
360
-		$search->setSortations( array( $search->sort( '+', 'product.id' ) ) );
361
-		$search->setSlice( 0, $maxQuery );
358
+		$search = $manager->createSearch($default);
359
+		$search->setConditions($search->compare('!=', 'index.catalog.id', null));
360
+		$search->setSortations(array($search->sort('+', 'product.id')));
361
+		$search->setSlice(0, $maxQuery);
362 362
 
363
-		$content = $this->createContent( $container, $filenum );
363
+		$content = $this->createContent($container, $filenum);
364 364
 		$names[] = $content->getResource();
365 365
 
366 366
 		do
367 367
 		{
368
-			$items = $manager->searchItems( $search, $domains );
369
-			$this->addItems( $content, $items );
368
+			$items = $manager->searchItems($search, $domains);
369
+			$this->addItems($content, $items);
370 370
 
371
-			$count = count( $items );
371
+			$count = count($items);
372 372
 			$start += $count;
373
-			$search->setSlice( $start, $maxQuery );
373
+			$search->setSlice($start, $maxQuery);
374 374
 
375
-			if( $start + $maxQuery > $maxItems * $filenum )
375
+			if ($start + $maxQuery > $maxItems * $filenum)
376 376
 			{
377
-				$this->closeContent( $content );
378
-				$content = $this->createContent( $container, ++$filenum );
377
+				$this->closeContent($content);
378
+				$content = $this->createContent($container, ++$filenum);
379 379
 				$names[] = $content->getResource();
380 380
 			}
381 381
 		}
382
-		while( $count >= $search->getSliceSize() );
382
+		while ($count >= $search->getSliceSize());
383 383
 
384
-		$this->closeContent( $content );
384
+		$this->closeContent($content);
385 385
 
386 386
 		return $names;
387 387
 	}
@@ -394,11 +394,11 @@  discard block
 block discarded – undo
394 394
 	 * @param mixed $default Default value if name is unknown
395 395
 	 * @return mixed Configuration value
396 396
 	 */
397
-	protected function getConfig( $name, $default = null )
397
+	protected function getConfig($name, $default = null)
398 398
 	{
399 399
 		$config = $this->getContext()->getConfig();
400 400
 
401
-		switch( $name )
401
+		switch ($name)
402 402
 		{
403 403
 			case 'domains':
404 404
 				/** controller/jobs/product/export/sitemap/domains
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 				 * @see controller/jobs/product/export/sitemap/max-query
420 420
 				 * @see controller/jobs/product/export/sitemap/changefreq
421 421
 				 */
422
-				return $config->get( 'controller/jobs/product/export/sitemap/domains', $default );
422
+				return $config->get('controller/jobs/product/export/sitemap/domains', $default);
423 423
 
424 424
 			case 'max-items':
425 425
 				/** controller/jobs/product/export/sitemap/max-items
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 				 * @see controller/jobs/product/export/sitemap/changefreq
445 445
 				 * @see controller/jobs/product/export/sitemap/domains
446 446
 				 */
447
-				return $config->get( 'controller/jobs/product/export/sitemap/max-items', 50000 );
447
+				return $config->get('controller/jobs/product/export/sitemap/max-items', 50000);
448 448
 
449 449
 			case 'max-query':
450 450
 				/** controller/jobs/product/export/sitemap/max-query
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
 				 * @see controller/jobs/product/export/sitemap/changefreq
466 466
 				 * @see controller/jobs/product/export/sitemap/domains
467 467
 				 */
468
-				return $config->get( 'controller/jobs/product/export/sitemap/max-query', 1000 );
468
+				return $config->get('controller/jobs/product/export/sitemap/max-query', 1000);
469 469
 		}
470 470
 
471 471
 		return $default;
@@ -478,8 +478,8 @@  discard block
 block discarded – undo
478 478
 	 * @param integer $number Current file number
479 479
 	 * @return string New file name
480 480
 	 */
481
-	protected function getFilename( $number )
481
+	protected function getFilename($number)
482 482
 	{
483
-		return sprintf( 'aimeos-sitemap-%d.xml', $number );
483
+		return sprintf('aimeos-sitemap-%d.xml', $number);
484 484
 	}
485 485
 }
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Product/Export/Standard.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	public function getName()
30 30
 	{
31
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Product export' );
31
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Product export');
32 32
 	}
33 33
 
34 34
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	public function getDescription()
41 41
 	{
42
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Exports all available products' );
42
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Exports all available products');
43 43
 	}
44 44
 
45 45
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	public function run()
52 52
 	{
53 53
 		$container = $this->createContainer();
54
-		$this->export( $container, false );
54
+		$this->export($container, false);
55 55
 		$container->close();
56 56
 	}
57 57
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 * @param \Aimeos\MW\Container\Content\Iface $content File content object
63 63
 	 * @param \Aimeos\MShop\Product\Item\Iface[] $items List of product items
64 64
 	 */
65
-	protected function addItems( \Aimeos\MW\Container\Content\Iface $content, array $items )
65
+	protected function addItems(\Aimeos\MW\Container\Content\Iface $content, array $items)
66 66
 	{
67 67
 		/** controller/jobs/product/export/standard/template-items
68 68
 		 * Relative path to the XML items template of the product site map job controller.
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 
95 95
 		$view->exportItems = $items;
96 96
 
97
-		$content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) );
97
+		$content->add($view->render($context->getConfig()->get($tplconf, $default)));
98 98
 	}
99 99
 
100 100
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 		 * @see controller/jobs/product/export/max-items
124 124
 		 * @see controller/jobs/product/export/max-query
125 125
 		 */
126
-		$location = $config->get( 'controller/jobs/product/export/location' );
126
+		$location = $config->get('controller/jobs/product/export/location');
127 127
 
128 128
 		/** controller/jobs/product/export/standard/container/type
129 129
 		 * List of file container options for the export files
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 		 * @see controller/jobs/product/export/max-items
141 141
 		 * @see controller/jobs/product/export/max-query
142 142
 		 */
143
-		$container = $config->get( 'controller/jobs/product/export/standard/container/type', 'Directory' );
143
+		$container = $config->get('controller/jobs/product/export/standard/container/type', 'Directory');
144 144
 
145 145
 		/** controller/jobs/product/export/standard/container/content
146 146
 		 * List of file container options for the export files
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 		 * @see controller/jobs/product/export/max-items
158 158
 		 * @see controller/jobs/product/export/max-query
159 159
 		 */
160
-		$content = $config->get( 'controller/jobs/product/export/standard/container/content', 'Binary' );
160
+		$content = $config->get('controller/jobs/product/export/standard/container/content', 'Binary');
161 161
 
162 162
 		/** controller/jobs/product/export/standard/container/options
163 163
 		 * List of file container options for the export files
@@ -174,15 +174,15 @@  discard block
 block discarded – undo
174 174
 		 * @see controller/jobs/product/export/max-items
175 175
 		 * @see controller/jobs/product/export/max-query
176 176
 		 */
177
-		$options = $config->get( 'controller/jobs/product/export/standard/container/options', [] );
177
+		$options = $config->get('controller/jobs/product/export/standard/container/options', []);
178 178
 
179
-		if( $location === null )
179
+		if ($location === null)
180 180
 		{
181
-			$msg = sprintf( 'Required configuration for "%1$s" is missing', 'controller/jobs/product/export/location' );
182
-			throw new \Aimeos\Controller\Jobs\Exception( $msg );
181
+			$msg = sprintf('Required configuration for "%1$s" is missing', 'controller/jobs/product/export/location');
182
+			throw new \Aimeos\Controller\Jobs\Exception($msg);
183 183
 		}
184 184
 
185
-		return \Aimeos\MW\Container\Factory::getContainer( $location, $container, $content, $options );
185
+		return \Aimeos\MW\Container\Factory::getContainer($location, $container, $content, $options);
186 186
 	}
187 187
 
188 188
 
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	 * @param integer $filenum New file number
194 194
 	 * @return \Aimeos\MW\Container\Content\Iface New content object
195 195
 	 */
196
-	protected function createContent( \Aimeos\MW\Container\Iface $container, $filenum )
196
+	protected function createContent(\Aimeos\MW\Container\Iface $container, $filenum)
197 197
 	{
198 198
 		/** controller/jobs/product/export/standard/template-header
199 199
 		 * Relative path to the XML site map header template of the product site map job controller.
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
 		$context = $this->getContext();
224 224
 		$view = $context->getView();
225 225
 
226
-		$content = $container->create( $this->getFilename( $filenum ) );
227
-		$content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) );
228
-		$container->add( $content );
226
+		$content = $container->create($this->getFilename($filenum));
227
+		$content->add($view->render($context->getConfig()->get($tplconf, $default)));
228
+		$container->add($content);
229 229
 
230 230
 		return $content;
231 231
 	}
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 	 *
237 237
 	 * @param \Aimeos\MW\Container\Content\Iface $content
238 238
 	 */
239
-	protected function closeContent( \Aimeos\MW\Container\Content\Iface $content )
239
+	protected function closeContent(\Aimeos\MW\Container\Content\Iface $content)
240 240
 	{
241 241
 		/** controller/jobs/product/export/standard/template-footer
242 242
 		 * Relative path to the XML site map footer template of the product site map job controller.
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 		$context = $this->getContext();
267 267
 		$view = $context->getView();
268 268
 
269
-		$content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) );
269
+		$content->add($view->render($context->getConfig()->get($tplconf, $default)));
270 270
 	}
271 271
 
272 272
 
@@ -277,45 +277,45 @@  discard block
 block discarded – undo
277 277
 	 * @param boolean $default True to filter exported products by default criteria
278 278
 	 * @return array List of content (file) names
279 279
 	 */
280
-	protected function export( \Aimeos\MW\Container\Iface $container, $default = true )
280
+	protected function export(\Aimeos\MW\Container\Iface $container, $default = true)
281 281
 	{
282
-		$domains = array( 'attribute', 'media', 'price', 'product', 'text' );
282
+		$domains = array('attribute', 'media', 'price', 'product', 'text');
283 283
 
284
-		$domains = $this->getConfig( 'domains', $domains );
285
-		$maxItems = $this->getConfig( 'max-items', 10000 );
286
-		$maxQuery = $this->getConfig( 'max-query', 1000 );
284
+		$domains = $this->getConfig('domains', $domains);
285
+		$maxItems = $this->getConfig('max-items', 10000);
286
+		$maxQuery = $this->getConfig('max-query', 1000);
287 287
 
288 288
 		$start = 0; $filenum = 1;
289 289
 		$names = [];
290 290
 
291
-		$productManager = \Aimeos\MShop::create( $this->getContext(), 'product' );
291
+		$productManager = \Aimeos\MShop::create($this->getContext(), 'product');
292 292
 
293
-		$search = $productManager->createSearch( $default );
294
-		$search->setSortations( array( $search->sort( '+', 'product.id' ) ) );
295
-		$search->setSlice( 0, $maxQuery );
293
+		$search = $productManager->createSearch($default);
294
+		$search->setSortations(array($search->sort('+', 'product.id')));
295
+		$search->setSlice(0, $maxQuery);
296 296
 
297
-		$content = $this->createContent( $container, $filenum );
297
+		$content = $this->createContent($container, $filenum);
298 298
 		$names[] = $content->getResource();
299 299
 
300 300
 		do
301 301
 		{
302
-			$items = $productManager->searchItems( $search, $domains );
303
-			$this->addItems( $content, $items );
302
+			$items = $productManager->searchItems($search, $domains);
303
+			$this->addItems($content, $items);
304 304
 
305
-			$count = count( $items );
305
+			$count = count($items);
306 306
 			$start += $count;
307
-			$search->setSlice( $start, $maxQuery );
307
+			$search->setSlice($start, $maxQuery);
308 308
 
309
-			if( $start + $maxQuery > $maxItems * $filenum )
309
+			if ($start + $maxQuery > $maxItems * $filenum)
310 310
 			{
311
-				$this->closeContent( $content );
312
-				$content = $this->createContent( $container, ++$filenum );
311
+				$this->closeContent($content);
312
+				$content = $this->createContent($container, ++$filenum);
313 313
 				$names[] = $content->getResource();
314 314
 			}
315 315
 		}
316
-		while( $count >= $search->getSliceSize() );
316
+		while ($count >= $search->getSliceSize());
317 317
 
318
-		$this->closeContent( $content );
318
+		$this->closeContent($content);
319 319
 
320 320
 		return $names;
321 321
 	}
@@ -328,11 +328,11 @@  discard block
 block discarded – undo
328 328
 	 * @param mixed $default Default value if name is unknown
329 329
 	 * @return mixed Configuration value
330 330
 	 */
331
-	protected function getConfig( $name, $default = null )
331
+	protected function getConfig($name, $default = null)
332 332
 	{
333 333
 		$config = $this->getContext()->getConfig();
334 334
 
335
-		switch( $name )
335
+		switch ($name)
336 336
 		{
337 337
 			case 'domain':
338 338
 				/** controller/jobs/product/export/domains
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 				 * @see controller/jobs/product/export/max-items
356 356
 				 * @see controller/jobs/product/export/max-query
357 357
 				 */
358
-				return $config->get( 'controller/jobs/product/export/domains', $default );
358
+				return $config->get('controller/jobs/product/export/domains', $default);
359 359
 
360 360
 			case 'max-items':
361 361
 				/** controller/jobs/product/export/max-items
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 				 * @see controller/jobs/product/export/max-query
379 379
 				 * @see controller/jobs/product/export/domains
380 380
 				 */
381
-				return $config->get( 'controller/jobs/product/export/max-items', $default );
381
+				return $config->get('controller/jobs/product/export/max-items', $default);
382 382
 
383 383
 			case 'max-query':
384 384
 				/** controller/jobs/product/export/max-query
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 				 * @see controller/jobs/product/export/max-items
402 402
 				 * @see controller/jobs/product/export/domains
403 403
 				 */
404
-				return $config->get( 'controller/jobs/product/export/max-query', $default );
404
+				return $config->get('controller/jobs/product/export/max-query', $default);
405 405
 
406 406
 			case 'filename':
407 407
 				/** controller/jobs/product/export/filename
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 				 * @see controller/jobs/product/export/max-query
423 423
 				 * @see controller/jobs/product/export/domains
424 424
 				 */
425
-				return $config->get( 'controller/jobs/product/export/filename', $default );
425
+				return $config->get('controller/jobs/product/export/filename', $default);
426 426
 		}
427 427
 
428 428
 		return $default;
@@ -435,8 +435,8 @@  discard block
 block discarded – undo
435 435
 	 * @param integer $number Current file number
436 436
 	 * @return string New file name
437 437
 	 */
438
-	protected function getFilename( $number )
438
+	protected function getFilename($number)
439 439
 	{
440
-		return sprintf( $this->getConfig( 'filename', 'aimeos-products-%1$d_%2$s.xml' ), $number, date( 'Y-m-d_H:i:s' ) );
440
+		return sprintf($this->getConfig('filename', 'aimeos-products-%1$d_%2$s.xml'), $number, date('Y-m-d_H:i:s'));
441 441
 	}
442 442
 }
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Product/Bought/Standard.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	public function getName()
31 31
 	{
32
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Products bought together' );
32
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Products bought together');
33 33
 	}
34 34
 
35 35
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	public function getDescription()
42 42
 	{
43
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Creates bought together product suggestions' );
43
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Creates bought together product suggestions');
44 44
 	}
45 45
 
46 46
 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 		 * @see controller/jobs/product/bought/min-confidence
73 73
 		 * @see controller/jobs/product/bought/limit-days
74 74
 		 */
75
-		$maxItems = $config->get( 'controller/jobs/product/bought/max-items', 5 );
75
+		$maxItems = $config->get('controller/jobs/product/bought/max-items', 5);
76 76
 
77 77
 		/** controller/jobs/product/bought/min-support
78 78
 		 * Minimum support value to sort out all irrelevant combinations
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 		 * @see controller/jobs/product/bought/min-confidence
102 102
 		 * @see controller/jobs/product/bought/limit-days
103 103
 		 */
104
-		$minSupport = $config->get( 'controller/jobs/product/bought/min-support', 0.02 );
104
+		$minSupport = $config->get('controller/jobs/product/bought/min-support', 0.02);
105 105
 
106 106
 		/** controller/jobs/product/bought/min-confidence
107 107
 		 * Minimum confidence value for high quality suggestions
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 		 * @see controller/jobs/product/bought/min-support
127 127
 		 * @see controller/jobs/product/bought/limit-days
128 128
 		 */
129
-		$minConfidence = $config->get( 'controller/jobs/product/bought/min-confidence', 0.66 );
129
+		$minConfidence = $config->get('controller/jobs/product/bought/min-confidence', 0.66);
130 130
 
131 131
 		/** controller/jobs/product/bought/limit-days
132 132
 		 * Only use orders placed in the past within the configured number of days for calculating bought together products
@@ -150,43 +150,43 @@  discard block
 block discarded – undo
150 150
 		 * @see controller/jobs/product/bought/min-support
151 151
 		 * @see controller/jobs/product/bought/min-confidence
152 152
 		 */
153
-		$days = $config->get( 'controller/jobs/product/bought/limit-days', 180 );
154
-		$date = date( 'Y-m-d H:i:s', time() - $days * 86400 );
153
+		$days = $config->get('controller/jobs/product/bought/limit-days', 180);
154
+		$date = date('Y-m-d H:i:s', time() - $days * 86400);
155 155
 
156 156
 
157
-		$baseManager = \Aimeos\MShop::create( $context, 'order/base' );
157
+		$baseManager = \Aimeos\MShop::create($context, 'order/base');
158 158
 		$search = $baseManager->createSearch();
159
-		$search->setConditions( $search->compare( '>', 'order.base.ctime', $date ) );
160
-		$search->setSlice( 0, 0 );
159
+		$search->setConditions($search->compare('>', 'order.base.ctime', $date));
160
+		$search->setSlice(0, 0);
161 161
 		$totalOrders = 0;
162
-		$baseManager->searchItems( $search, [], $totalOrders );
162
+		$baseManager->searchItems($search, [], $totalOrders);
163 163
 
164
-		$baseProductManager = \Aimeos\MShop::create( $context, 'order/base/product' );
164
+		$baseProductManager = \Aimeos\MShop::create($context, 'order/base/product');
165 165
 		$search = $baseProductManager->createSearch();
166
-		$search->setConditions( $search->compare( '>', 'order.base.product.ctime', $date ) );
166
+		$search->setConditions($search->compare('>', 'order.base.product.ctime', $date));
167 167
 		$start = 0;
168 168
 
169 169
 		do
170 170
 		{
171
-			$totalCounts = $baseProductManager->aggregate( $search, 'order.base.product.productid' );
172
-			$prodIds = array_keys( $totalCounts );
171
+			$totalCounts = $baseProductManager->aggregate($search, 'order.base.product.productid');
172
+			$prodIds = array_keys($totalCounts);
173 173
 
174
-			foreach( $totalCounts as $id => $count )
174
+			foreach ($totalCounts as $id => $count)
175 175
 			{
176
-				$this->removeListItems( $id );
176
+				$this->removeListItems($id);
177 177
 
178
-				if( $count / $totalOrders > $minSupport )
178
+				if ($count / $totalOrders > $minSupport)
179 179
 				{
180
-					$productIds = $this->getSuggestions( $id, $prodIds, $count, $totalOrders, $maxItems, $minSupport, $minConfidence, $date );
181
-					$this->addListItems( $id, $productIds );
180
+					$productIds = $this->getSuggestions($id, $prodIds, $count, $totalOrders, $maxItems, $minSupport, $minConfidence, $date);
181
+					$this->addListItems($id, $productIds);
182 182
 				}
183 183
 			}
184 184
 
185
-			$count = count( $totalCounts );
185
+			$count = count($totalCounts);
186 186
 			$start += $count;
187
-			$search->setSlice( $start );
187
+			$search->setSlice($start);
188 188
 		}
189
-		while( $count >= $search->getSliceSize() );
189
+		while ($count >= $search->getSliceSize());
190 190
 	}
191 191
 
192 192
 
@@ -203,59 +203,59 @@  discard block
 block discarded – undo
203 203
 	 * @param string $date Date in YYYY-MM-DD HH:mm:ss format after which orders should be used for calculations
204 204
 	 * @return array List of suggested product IDs as key and their confidence as value
205 205
 	 */
206
-	protected function getSuggestions( $id, $prodIds, $count, $total, $maxItems, $minSupport, $minConfidence, $date )
206
+	protected function getSuggestions($id, $prodIds, $count, $total, $maxItems, $minSupport, $minConfidence, $date)
207 207
 	{
208 208
 		$refIds = [];
209 209
 		$context = $this->getContext();
210 210
 
211
-		$catalogListManager = \Aimeos\MShop::create( $context, 'catalog/lists' );
212
-		$baseProductManager = \Aimeos\MShop::create( $context, 'order/base/product' );
211
+		$catalogListManager = \Aimeos\MShop::create($context, 'catalog/lists');
212
+		$baseProductManager = \Aimeos\MShop::create($context, 'order/base/product');
213 213
 
214 214
 
215 215
 		$search = $baseProductManager->createSearch();
216
-		$func = $search->createFunction( 'order.base.product.count', array( (string) $id ) );
216
+		$func = $search->createFunction('order.base.product.count', array((string) $id));
217 217
 		$expr = array(
218
-			$search->compare( '==', 'order.base.product.productid', $prodIds ),
219
-			$search->compare( '>', 'order.base.product.ctime', $date ),
220
-			$search->compare( '==', $func, 1 ),
218
+			$search->compare('==', 'order.base.product.productid', $prodIds),
219
+			$search->compare('>', 'order.base.product.ctime', $date),
220
+			$search->compare('==', $func, 1),
221 221
 		);
222
-		$search->setConditions( $search->combine( '&&', $expr ) );
222
+		$search->setConditions($search->combine('&&', $expr));
223 223
 
224
-		$relativeCounts = $baseProductManager->aggregate( $search, 'order.base.product.productid' );
224
+		$relativeCounts = $baseProductManager->aggregate($search, 'order.base.product.productid');
225 225
 
226 226
 
227 227
 		$search = $catalogListManager->createSearch();
228 228
 		$expr = array(
229
-			$search->compare( '==', 'catalog.lists.refid', array_keys( $relativeCounts ) ),
230
-			$search->compare( '==', 'catalog.lists.domain', 'product' ),
229
+			$search->compare('==', 'catalog.lists.refid', array_keys($relativeCounts)),
230
+			$search->compare('==', 'catalog.lists.domain', 'product'),
231 231
 		);
232
-		$search->setConditions( $search->combine( '&&', $expr ) );
232
+		$search->setConditions($search->combine('&&', $expr));
233 233
 
234
-		foreach( $catalogListManager->searchItems( $search ) as $listItem ) {
234
+		foreach ($catalogListManager->searchItems($search) as $listItem) {
235 235
 			$refIds[$listItem->getRefId()] = true;
236 236
 		}
237 237
 
238 238
 
239
-		unset( $relativeCounts[$id] );
239
+		unset($relativeCounts[$id]);
240 240
 		$supportA = $count / $total;
241 241
 		$products = [];
242 242
 
243
-		foreach( $relativeCounts as $prodId => $relCnt )
243
+		foreach ($relativeCounts as $prodId => $relCnt)
244 244
 		{
245
-			if( !isset( $refIds[$prodId] ) ) {
245
+			if (!isset($refIds[$prodId])) {
246 246
 				continue;
247 247
 			}
248 248
 
249 249
 			$supportAB = $relCnt / $total;
250 250
 
251
-			if( $supportAB > $minSupport && ( $conf = ( $supportAB / $supportA ) ) > $minConfidence ) {
251
+			if ($supportAB > $minSupport && ($conf = ($supportAB / $supportA)) > $minConfidence) {
252 252
 				$products[$prodId] = $conf;
253 253
 			}
254 254
 		}
255 255
 
256
-		arsort( $products );
256
+		arsort($products);
257 257
 
258
-		return array_keys( array_slice( $products, 0, $maxItems, true ) );
258
+		return array_keys(array_slice($products, 0, $maxItems, true));
259 259
 	}
260 260
 
261 261
 
@@ -265,26 +265,26 @@  discard block
 block discarded – undo
265 265
 	 * @param string $productId Unique ID of the product the given products should be referenced to
266 266
 	 * @param array $productIds List of position as key and product ID as value
267 267
 	 */
268
-	protected function addListItems( $productId, array $productIds )
268
+	protected function addListItems($productId, array $productIds)
269 269
 	{
270
-		if( empty( $productIds ) ) {
270
+		if (empty($productIds)) {
271 271
 			return;
272 272
 		}
273 273
 
274
-		$manager = \Aimeos\MShop::create( $this->getContext(), 'product/lists' );
274
+		$manager = \Aimeos\MShop::create($this->getContext(), 'product/lists');
275 275
 		$item = $manager->createItem();
276 276
 
277
-		foreach( $productIds as $pos => $refid )
277
+		foreach ($productIds as $pos => $refid)
278 278
 		{
279
-			$item->setId( null );
280
-			$item->setParentId( $productId );
281
-			$item->setDomain( 'product' );
282
-			$item->setType( 'bought-together' );
283
-			$item->setPosition( $pos );
284
-			$item->setRefId( $refid );
285
-			$item->setStatus( 1 );
286
-
287
-			$manager->saveItem( $item, false );
279
+			$item->setId(null);
280
+			$item->setParentId($productId);
281
+			$item->setDomain('product');
282
+			$item->setType('bought-together');
283
+			$item->setPosition($pos);
284
+			$item->setRefId($refid);
285
+			$item->setStatus(1);
286
+
287
+			$manager->saveItem($item, false);
288 288
 		}
289 289
 	}
290 290
 
@@ -294,20 +294,20 @@  discard block
 block discarded – undo
294 294
 	 *
295 295
 	 * @param string $productId Unique ID of the product the references should be removed from
296 296
 	 */
297
-	protected function removeListItems( $productId )
297
+	protected function removeListItems($productId)
298 298
 	{
299
-		$manager = \Aimeos\MShop::create( $this->getContext(), 'product/lists' );
299
+		$manager = \Aimeos\MShop::create($this->getContext(), 'product/lists');
300 300
 
301 301
 		$search = $manager->createSearch();
302 302
 		$expr = array(
303
-			$search->compare( '==', 'product.lists.parentid', $productId ),
304
-			$search->compare( '==', 'product.lists.domain', 'product' ),
305
-			$search->compare( '==', 'product.lists.type', 'bought-together' ),
303
+			$search->compare('==', 'product.lists.parentid', $productId),
304
+			$search->compare('==', 'product.lists.domain', 'product'),
305
+			$search->compare('==', 'product.lists.type', 'bought-together'),
306 306
 		);
307
-		$search->setConditions( $search->combine( '&&', $expr ) );
307
+		$search->setConditions($search->combine('&&', $expr));
308 308
 
309
-		$listItems = $manager->searchItems( $search );
309
+		$listItems = $manager->searchItems($search);
310 310
 
311
-		$manager->deleteItems( array_keys( $listItems ) );
311
+		$manager->deleteItems(array_keys($listItems));
312 312
 	}
313 313
 }
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Subscription/Export/Csv/Standard.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	public function getName()
30 30
 	{
31
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Subscription export CSV' );
31
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Subscription export CSV');
32 32
 	}
33 33
 
34 34
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	public function getDescription()
41 41
 	{
42
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Exports subscriptions to CSV file' );
42
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Exports subscriptions to CSV file');
43 43
 	}
44 44
 
45 45
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 		 * @category Developer
74 74
 		 * @see controller/common/subscription/export/csv/max-size
75 75
 		 */
76
-		$mappings = $config->get( 'controller/common/subscription/export/csv/mapping', $mappings );
76
+		$mappings = $config->get('controller/common/subscription/export/csv/mapping', $mappings);
77 77
 
78 78
 		/** controller/jobs/subscription/export/csv/mapping
79 79
 		 * List of mappings between the position in the CSV file and item keys
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 		 * @category Developer
89 89
 		 * @see controller/common/subscription/export/csv/max-size
90 90
 		 */
91
-		$mappings = $config->get( 'controller/jobs/subscription/export/csv/mapping', $mappings );
91
+		$mappings = $config->get('controller/jobs/subscription/export/csv/mapping', $mappings);
92 92
 
93 93
 
94 94
 		/** controller/common/subscription/export/csv/max-size
@@ -106,29 +106,29 @@  discard block
 block discarded – undo
106 106
 		 * @category Developer
107 107
 		 * @see controller/common/subscription/export/csv/mapping
108 108
 		 */
109
-		$maxcnt = (int) $config->get( 'controller/common/subscription/export/csv/max-size', 1000 );
109
+		$maxcnt = (int) $config->get('controller/common/subscription/export/csv/max-size', 1000);
110 110
 
111 111
 
112
-		$processors = $this->getProcessors( $mappings );
113
-		$mq = $context->getMessageQueueManager()->get( 'mq-admin' )->getQueue( 'subscription-export' );
112
+		$processors = $this->getProcessors($mappings);
113
+		$mq = $context->getMessageQueueManager()->get('mq-admin')->getQueue('subscription-export');
114 114
 
115
-		while( ( $msg = $mq->get() ) !== null )
115
+		while (($msg = $mq->get()) !== null)
116 116
 		{
117 117
 			try
118 118
 			{
119
-				if( ( $data = json_decode( $msg->getBody(), true ) ) === null ) {
120
-					throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid message: %1$s', $msg->getBody() ) );
119
+				if (($data = json_decode($msg->getBody(), true)) === null) {
120
+					throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid message: %1$s', $msg->getBody()));
121 121
 				}
122 122
 
123
-				$this->export( $processors, $data, $maxcnt );
123
+				$this->export($processors, $data, $maxcnt);
124 124
 			}
125
-			catch( \Exception $e )
125
+			catch (\Exception $e)
126 126
 			{
127
-				$logger->log( 'Subscription export error: ' . $e->getMessage() );
128
-				$logger->log( $e->getTraceAsString() );
127
+				$logger->log('Subscription export error: ' . $e->getMessage());
128
+				$logger->log($e->getTraceAsString());
129 129
 			}
130 130
 
131
-			$mq->del( $msg );
131
+			$mq->del($msg);
132 132
 		}
133 133
 	}
134 134
 
@@ -139,15 +139,15 @@  discard block
 block discarded – undo
139 139
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context item
140 140
 	 * @param string $path Absolute path to the exported file
141 141
 	 */
142
-	protected function addJob( $context, $path )
142
+	protected function addJob($context, $path)
143 143
 	{
144
-		$manager = \Aimeos\MAdmin::create( $context, 'job' );
144
+		$manager = \Aimeos\MAdmin::create($context, 'job');
145 145
 
146 146
 		$item = $manager->createItem();
147
-		$item->setResult( ['file' => $path] );
148
-		$item->setLabel( $path );
147
+		$item->setResult(['file' => $path]);
148
+		$item->setLabel($path);
149 149
 
150
-		$manager->saveItem( $item, false );
150
+		$manager->saveItem($item, false);
151 151
 	}
152 152
 
153 153
 
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 		 * @see controller/jobs/subscription/export/csv/container/content
178 178
 		 * @see controller/jobs/subscription/export/csv/container/options
179 179
 		 */
180
-		$location = $config->get( 'controller/jobs/subscription/export/csv/location', sys_get_temp_dir() );
180
+		$location = $config->get('controller/jobs/subscription/export/csv/location', sys_get_temp_dir());
181 181
 
182 182
 		/** controller/jobs/subscription/export/csv/container/type
183 183
 		 * Nave of the container type to read the data from
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 		 * @see controller/jobs/subscription/export/csv/container/content
201 201
 		 * @see controller/jobs/subscription/export/csv/container/options
202 202
 		 */
203
-		$container = $config->get( 'controller/jobs/subscription/export/csv/container/type', 'Directory' );
203
+		$container = $config->get('controller/jobs/subscription/export/csv/container/type', 'Directory');
204 204
 
205 205
 		/** controller/jobs/subscription/export/csv/container/content
206 206
 		 * Name of the content type inside the container to read the data from
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 		 * @see controller/jobs/subscription/export/csv/container/type
222 222
 		 * @see controller/jobs/subscription/export/csv/container/options
223 223
 		 */
224
-		$content = $config->get( 'controller/jobs/subscription/export/csv/container/content', 'CSV' );
224
+		$content = $config->get('controller/jobs/subscription/export/csv/container/content', 'CSV');
225 225
 
226 226
 		/** controller/jobs/subscription/export/csv/container/options
227 227
 		 * List of file container options for the subscription export files
@@ -239,9 +239,9 @@  discard block
 block discarded – undo
239 239
 		 * @see controller/jobs/subscription/export/csv/container/content
240 240
 		 * @see controller/jobs/subscription/export/csv/container/type
241 241
 		 */
242
-		$options = $config->get( 'controller/jobs/subscription/export/csv/container/options', [] );
242
+		$options = $config->get('controller/jobs/subscription/export/csv/container/options', []);
243 243
 
244
-		return \Aimeos\MW\Container\Factory::getContainer( $location, $container, $content, $options );
244
+		return \Aimeos\MW\Container\Factory::getContainer($location, $container, $content, $options);
245 245
 	}
246 246
 
247 247
 
@@ -253,56 +253,56 @@  discard block
 block discarded – undo
253 253
 	 * @param integer $maxcnt Maximum number of retrieved subscriptions at once
254 254
 	 * @return string Path of the file containing the exported data
255 255
 	 */
256
-	protected function export( array $processors, $msg, $maxcnt )
256
+	protected function export(array $processors, $msg, $maxcnt)
257 257
 	{
258
-		$lcontext = $this->getLocaleContext( $msg );
258
+		$lcontext = $this->getLocaleContext($msg);
259 259
 		$baseRef = ['order/base/address', 'order/base/product'];
260 260
 
261
-		$manager = \Aimeos\MShop::create( $lcontext, 'subscription' );
262
-		$baseManager = \Aimeos\MShop::create( $lcontext, 'order/base' );
261
+		$manager = \Aimeos\MShop::create($lcontext, 'subscription');
262
+		$baseManager = \Aimeos\MShop::create($lcontext, 'order/base');
263 263
 
264 264
 		$container = $this->getContainer();
265
-		$content = $container->create( 'subscription-export_' . date( 'Y-m-d_H-i-s' ) );
266
-		$search = $this->initCriteria( $manager->createSearch()->setSlice( 0, 0x7fffffff ), $msg );
265
+		$content = $container->create('subscription-export_' . date('Y-m-d_H-i-s'));
266
+		$search = $this->initCriteria($manager->createSearch()->setSlice(0, 0x7fffffff), $msg);
267 267
 		$start = 0;
268 268
 
269 269
 		do
270 270
 		{
271 271
 			$baseIds = [];
272
-			$search->setSlice( $start, $maxcnt );
273
-			$items = $manager->searchItems( $search );
272
+			$search->setSlice($start, $maxcnt);
273
+			$items = $manager->searchItems($search);
274 274
 
275
-			foreach( $items as $item ) {
275
+			foreach ($items as $item) {
276 276
 				$baseIds[] = $item->getOrderBaseId();
277 277
 			}
278 278
 
279 279
 			$baseSearch = $baseManager->createSearch();
280
-			$baseSearch->setConditions( $baseSearch->compare( '==', 'order.base.id', $baseIds ) );
281
-			$baseSearch->setSlice( 0, count( $baseIds ) );
280
+			$baseSearch->setConditions($baseSearch->compare('==', 'order.base.id', $baseIds));
281
+			$baseSearch->setSlice(0, count($baseIds));
282 282
 
283
-			$baseItems = $baseManager->searchItems( $baseSearch, $baseRef );
283
+			$baseItems = $baseManager->searchItems($baseSearch, $baseRef);
284 284
 
285
-			foreach( $items as $id => $item )
285
+			foreach ($items as $id => $item)
286 286
 			{
287
-				foreach( $processors as $type => $processor )
287
+				foreach ($processors as $type => $processor)
288 288
 				{
289
-					foreach( $processor->process( $item, $baseItems[$item->getOrderBaseId()] ) as $line ) {
290
-						$content->add( [0 => $type, 1 => $id] + $line );
289
+					foreach ($processor->process($item, $baseItems[$item->getOrderBaseId()]) as $line) {
290
+						$content->add([0 => $type, 1 => $id] + $line);
291 291
 					}
292 292
 				}
293 293
 			}
294 294
 
295
-			$count = count( $items );
295
+			$count = count($items);
296 296
 			$start += $count;
297 297
 		}
298
-		while( $count === $search->getSliceSize() );
298
+		while ($count === $search->getSliceSize());
299 299
 
300 300
 		$path = $content->getResource();
301
-		$container->add( $content );
301
+		$container->add($content);
302 302
 		$container->close();
303 303
 
304
-		$path = $this->moveFile( $lcontext, $path );
305
-		$this->addJob( $lcontext, $path );
304
+		$path = $this->moveFile($lcontext, $path);
305
+		$this->addJob($lcontext, $path);
306 306
 	}
307 307
 
308 308
 
@@ -312,15 +312,15 @@  discard block
 block discarded – undo
312 312
 	 * @param array $msg Message data including a "sitecode" value
313 313
 	 * @return \Aimeos\MShop\Context\Item\Iface New context item with updated locale
314 314
 	 */
315
-	protected function getLocaleContext( array $msg )
315
+	protected function getLocaleContext(array $msg)
316 316
 	{
317 317
 		$lcontext = clone $this->getContext();
318
-		$manager = \Aimeos\MShop::create( $lcontext, 'locale' );
318
+		$manager = \Aimeos\MShop::create($lcontext, 'locale');
319 319
 
320
-		$sitecode = ( isset( $msg['sitecode'] ) ? $msg['sitecode'] : 'default' );
321
-		$localeItem = $manager->bootstrap( $sitecode, '', '', false, \Aimeos\MShop\Locale\Manager\Base::SITE_ONE );
320
+		$sitecode = (isset($msg['sitecode']) ? $msg['sitecode'] : 'default');
321
+		$localeItem = $manager->bootstrap($sitecode, '', '', false, \Aimeos\MShop\Locale\Manager\Base::SITE_ONE);
322 322
 
323
-		return $lcontext->setLocale( $localeItem );
323
+		return $lcontext->setLocale($localeItem);
324 324
 	}
325 325
 
326 326
 
@@ -331,14 +331,14 @@  discard block
 block discarded – undo
331 331
 	 * @param array $msg Message data
332 332
 	 * @return \Aimeos\MW\Criteria\Iface Initialized criteria object
333 333
 	 */
334
-	protected function initCriteria( \Aimeos\MW\Criteria\Iface $criteria, array $msg )
334
+	protected function initCriteria(\Aimeos\MW\Criteria\Iface $criteria, array $msg)
335 335
 	{
336
-		if( isset( $msg['filter'] ) ) {
337
-			$criteria->setConditions( $criteria->toConditions( $msg['filter'] ) );
336
+		if (isset($msg['filter'])) {
337
+			$criteria->setConditions($criteria->toConditions($msg['filter']));
338 338
 		}
339 339
 
340
-		if( isset( $msg['sort'] ) ) {
341
-			$criteria->setSortations( $criteria->toSortations( $msg['sort'] ) );
340
+		if (isset($msg['sort'])) {
341
+			$criteria->setSortations($criteria->toSortations($msg['sort']));
342 342
 		}
343 343
 
344 344
 		return $criteria;
@@ -352,12 +352,12 @@  discard block
 block discarded – undo
352 352
 	 * @param string $path Absolute path to the exported file
353 353
 	 * @return string Relative path of the file in the storage
354 354
 	 */
355
-	protected function moveFile( $context, $path )
355
+	protected function moveFile($context, $path)
356 356
 	{
357
-		$filename = basename( $path );
358
-		$context->getFileSystemManager()->get( 'fs-admin' )->writef( $filename, $path );
357
+		$filename = basename($path);
358
+		$context->getFileSystemManager()->get('fs-admin')->writef($filename, $path);
359 359
 
360
-		unlink( $path );
360
+		unlink($path);
361 361
 		return $filename;
362 362
 	}
363 363
 }
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Subscription/Process/End/Standard.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	public function getName()
30 30
 	{
31
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Subscription process end' );
31
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Subscription process end');
32 32
 	}
33 33
 
34 34
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	public function getDescription()
41 41
 	{
42
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Terminates expired subscriptions' );
42
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Terminates expired subscriptions');
43 43
 	}
44 44
 
45 45
 
@@ -65,51 +65,51 @@  discard block
 block discarded – undo
65 65
 		 * @since 2018.04
66 66
 		 * @category Developer
67 67
 		 */
68
-		$names = (array) $config->get( 'controller/common/subscription/process/processors', [] );
68
+		$names = (array) $config->get('controller/common/subscription/process/processors', []);
69 69
 
70
-		$processors = $this->getProcessors( $names );
71
-		$manager = \Aimeos\MShop::create( $context, 'subscription' );
70
+		$processors = $this->getProcessors($names);
71
+		$manager = \Aimeos\MShop::create($context, 'subscription');
72 72
 
73
-		$search = $manager->createSearch( true );
73
+		$search = $manager->createSearch(true);
74 74
 		$expr = [
75
-			$search->compare( '<', 'subscription.dateend', date( 'Y-m-d' ) ),
75
+			$search->compare('<', 'subscription.dateend', date('Y-m-d')),
76 76
 			$search->getConditions(),
77 77
 		];
78
-		$search->setConditions( $search->combine( '&&', $expr ) );
79
-		$search->setSortations( [$search->sort( '+', 'subscription.id' )] );
78
+		$search->setConditions($search->combine('&&', $expr));
79
+		$search->setSortations([$search->sort('+', 'subscription.id')]);
80 80
 
81 81
 		$start = 0;
82 82
 
83 83
 		do
84 84
 		{
85
-			$search->setSlice( $start, 100 );
86
-			$items = $manager->searchItems( $search );
85
+			$search->setSlice($start, 100);
86
+			$items = $manager->searchItems($search);
87 87
 
88
-			foreach( $items as $item )
88
+			foreach ($items as $item)
89 89
 			{
90 90
 				try
91 91
 				{
92
-					foreach( $processors as $processor ) {
93
-						$processor->end( $item );
92
+					foreach ($processors as $processor) {
93
+						$processor->end($item);
94 94
 					}
95 95
 
96
-					if( ( $reason = $item->getReason() ) === null ) {
96
+					if (($reason = $item->getReason()) === null) {
97 97
 						$reason = \Aimeos\MShop\Subscription\Item\Iface::REASON_END;
98 98
 					}
99 99
 
100
-					$manager->saveItem( $item->setReason( $reason )->setStatus( 0 ) );
100
+					$manager->saveItem($item->setReason($reason)->setStatus(0));
101 101
 				}
102
-				catch( \Exception $e )
102
+				catch (\Exception $e)
103 103
 				{
104 104
 					$msg = 'Unable to process subscription with ID "%1$S": %2$s';
105
-					$logger->log( sprintf( $msg, $item->getId(), $e->getMessage() ) );
106
-					$logger->log( $e->getTraceAsString() );
105
+					$logger->log(sprintf($msg, $item->getId(), $e->getMessage()));
106
+					$logger->log($e->getTraceAsString());
107 107
 				}
108 108
 			}
109 109
 
110
-			$count = count( $items );
110
+			$count = count($items);
111 111
 			$start += $count;
112 112
 		}
113
-		while( $count === $search->getSliceSize() );
113
+		while ($count === $search->getSliceSize());
114 114
 	}
115 115
 }
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Subscription/Process/Renew/Standard.php 1 patch
Spacing   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	public function getName()
30 30
 	{
31
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Subscription process renew' );
31
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Subscription process renew');
32 32
 	}
33 33
 
34 34
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	public function getDescription()
41 41
 	{
42
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Renews subscriptions at next date' );
42
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Renews subscriptions at next date');
43 43
 	}
44 44
 
45 45
 
@@ -54,73 +54,73 @@  discard block
 block discarded – undo
54 54
 		$config = $context->getConfig();
55 55
 		$logger = $context->getLogger();
56 56
 
57
-		$names = (array) $config->get( 'controller/common/subscription/process/processors', [] );
57
+		$names = (array) $config->get('controller/common/subscription/process/processors', []);
58 58
 
59
-		$date = date( 'Y-m-d' );
60
-		$processors = $this->getProcessors( $names );
61
-		$manager = \Aimeos\MShop::create( $context, 'subscription' );
59
+		$date = date('Y-m-d');
60
+		$processors = $this->getProcessors($names);
61
+		$manager = \Aimeos\MShop::create($context, 'subscription');
62 62
 
63
-		$search = $manager->createSearch( true );
63
+		$search = $manager->createSearch(true);
64 64
 		$expr = [
65
-			$search->compare( '<=', 'subscription.datenext', $date ),
66
-			$search->combine( '||', [
67
-				$search->compare( '==', 'subscription.dateend', null ),
68
-				$search->compare( '>', 'subscription.dateend', $date ),
69
-			] ),
65
+			$search->compare('<=', 'subscription.datenext', $date),
66
+			$search->combine('||', [
67
+				$search->compare('==', 'subscription.dateend', null),
68
+				$search->compare('>', 'subscription.dateend', $date),
69
+			]),
70 70
 			$search->getConditions(),
71 71
 		];
72
-		$search->setConditions( $search->combine( '&&', $expr ) );
73
-		$search->setSortations( [$search->sort( '+', 'subscription.id' )] );
72
+		$search->setConditions($search->combine('&&', $expr));
73
+		$search->setSortations([$search->sort('+', 'subscription.id')]);
74 74
 
75 75
 		$start = 0;
76 76
 
77 77
 		do
78 78
 		{
79
-			$search->setSlice( $start, 100 );
80
-			$items = $manager->searchItems( $search );
79
+			$search->setSlice($start, 100);
80
+			$items = $manager->searchItems($search);
81 81
 
82
-			foreach( $items as $item )
82
+			foreach ($items as $item)
83 83
 			{
84 84
 				try
85 85
 				{
86
-					$context = $this->createContext( $item->getOrderBaseId() );
87
-					$newOrder = $this->createOrderBase( $context, $item );
88
-					$newInvoice = $this->createOrderInvoice( $context, $newOrder );
86
+					$context = $this->createContext($item->getOrderBaseId());
87
+					$newOrder = $this->createOrderBase($context, $item);
88
+					$newInvoice = $this->createOrderInvoice($context, $newOrder);
89 89
 
90 90
 					try
91 91
 					{
92
-						$this->createPayment( $context, $newOrder, $newInvoice );
92
+						$this->createPayment($context, $newOrder, $newInvoice);
93 93
 
94
-						$interval = new \DateInterval( $item->getInterval() );
95
-						$item->setDateNext( date_create()->add( $interval )->format( 'Y-m-d' ) );
94
+						$interval = new \DateInterval($item->getInterval());
95
+						$item->setDateNext(date_create()->add($interval)->format('Y-m-d'));
96 96
 					}
97
-					catch( \Exception $e )
97
+					catch (\Exception $e)
98 98
 					{
99
-						$item->setReason( \Aimeos\MShop\Subscription\Item\Iface::REASON_PAYMENT );
100
-						$item->setDateEnd( date_create()->format( 'Y-m-d' ) );
101
-						$manager->saveItem( $item );
99
+						$item->setReason(\Aimeos\MShop\Subscription\Item\Iface::REASON_PAYMENT);
100
+						$item->setDateEnd(date_create()->format('Y-m-d'));
101
+						$manager->saveItem($item);
102 102
 
103 103
 						throw $e;
104 104
 					}
105 105
 
106
-					$manager->saveItem( $item );
106
+					$manager->saveItem($item);
107 107
 
108
-					foreach( $processors as $processor ) {
109
-						$processor->renew( $item, $newInvoice );
108
+					foreach ($processors as $processor) {
109
+						$processor->renew($item, $newInvoice);
110 110
 					}
111 111
 				}
112
-				catch( \Exception $e )
112
+				catch (\Exception $e)
113 113
 				{
114 114
 					$msg = 'Unable to process subscription with ID "%1$s": %2$s';
115
-					$logger->log( sprintf( $msg, $item->getId(), $e->getMessage() ) );
116
-					$logger->log( $e->getTraceAsString() );
115
+					$logger->log(sprintf($msg, $item->getId(), $e->getMessage()));
116
+					$logger->log($e->getTraceAsString());
117 117
 				}
118 118
 			}
119 119
 
120
-			$count = count( $items );
120
+			$count = count($items);
121 121
 			$start += $count;
122 122
 		}
123
-		while( $count === $search->getSliceSize() );
123
+		while ($count === $search->getSliceSize());
124 124
 	}
125 125
 
126 126
 
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
 	 * @param array $addresses Associative list of type as key and address object implementing \Aimeos\MShop\Order\Item\Base\Address\Iface as value
133 133
 	 * @return \Aimeos\MShop\Order\Item\Base\Iface Order with addresses added
134 134
 	 */
135
-	protected function addBasketAddresses( \Aimeos\MShop\Context\Item\Iface $context,
136
-		\Aimeos\MShop\Order\Item\Base\Iface $newBasket, array $addresses )
135
+	protected function addBasketAddresses(\Aimeos\MShop\Context\Item\Iface $context,
136
+		\Aimeos\MShop\Order\Item\Base\Iface $newBasket, array $addresses)
137 137
 	{
138
-		foreach( $addresses as $type => $orderAddress ) {
139
-			$newBasket->setAddress( $orderAddress, $type );
138
+		foreach ($addresses as $type => $orderAddress) {
139
+			$newBasket->setAddress($orderAddress, $type);
140 140
 		}
141 141
 
142 142
 		return $newBasket;
@@ -151,8 +151,8 @@  discard block
 block discarded – undo
151 151
 	 * @param array $codes List of coupon codes that should be added to the given basket
152 152
 	 * @return \Aimeos\MShop\Order\Item\Base\Iface Basket, maybe with coupons added
153 153
 	 */
154
-	protected function addBasketCoupons( \Aimeos\MShop\Context\Item\Iface $context,
155
-		\Aimeos\MShop\Order\Item\Base\Iface $basket, array $codes )
154
+	protected function addBasketCoupons(\Aimeos\MShop\Context\Item\Iface $context,
155
+		\Aimeos\MShop\Order\Item\Base\Iface $basket, array $codes)
156 156
 	{
157 157
 		/** controller/jobs/subcription/process/renew/standard/use-coupons
158 158
 		 *
@@ -166,34 +166,34 @@  discard block
 block discarded – undo
166 166
 		 * @category User
167 167
 		 * @since 2018.10
168 168
 		 */
169
-		if( $context->getConfig()->get( 'controller/jobs/subcription/process/renew/standard/use-coupons', false ) )
169
+		if ($context->getConfig()->get('controller/jobs/subcription/process/renew/standard/use-coupons', false))
170 170
 		{
171
-			$manager = \Aimeos\MShop::create( $context, 'coupon' );
172
-			$codeManager = \Aimeos\MShop::create( $context, 'coupon/code' );
171
+			$manager = \Aimeos\MShop::create($context, 'coupon');
172
+			$codeManager = \Aimeos\MShop::create($context, 'coupon/code');
173 173
 
174
-			foreach( $codes as $code )
174
+			foreach ($codes as $code)
175 175
 			{
176
-				$search = $manager->createSearch( true )->setSlice( 0, 1 );
176
+				$search = $manager->createSearch(true)->setSlice(0, 1);
177 177
 				$expr = [
178
-					$search->compare( '==', 'coupon.code.code', $code ),
179
-					$codeManager->createSearch( true )->getConditions(),
178
+					$search->compare('==', 'coupon.code.code', $code),
179
+					$codeManager->createSearch(true)->getConditions(),
180 180
 					$search->getConditions(),
181 181
 				];
182
-				$search->setConditions( $search->combine( '&&', $expr ) );
182
+				$search->setConditions($search->combine('&&', $expr));
183 183
 
184
-				$result = $manager->searchItems( $search );
184
+				$result = $manager->searchItems($search);
185 185
 
186
-				if( ( $item = reset( $result ) ) === false ) {
186
+				if (($item = reset($result)) === false) {
187 187
 					continue;
188 188
 				}
189 189
 
190
-				$provider = $manager->getProvider( $item, strtolower( $code ) );
190
+				$provider = $manager->getProvider($item, strtolower($code));
191 191
 
192
-				if( $provider->isAvailable( $basket ) !== true ) {
192
+				if ($provider->isAvailable($basket) !== true) {
193 193
 					continue;
194 194
 				}
195 195
 
196
-				$provider->addCoupon( $basket );
196
+				$provider->addCoupon($basket);
197 197
 			}
198 198
 		}
199 199
 
@@ -210,17 +210,17 @@  discard block
 block discarded – undo
210 210
 	 * @param string $orderProductId Unique ID of the ordered subscription product
211 211
 	 * @return \Aimeos\MShop\Order\Item\Base\Iface Order with products added
212 212
 	 */
213
-	protected function addBasketProducts( \Aimeos\MShop\Context\Item\Iface $context,
214
-		\Aimeos\MShop\Order\Item\Base\Iface $newBasket, array $orderProducts, $orderProductId )
213
+	protected function addBasketProducts(\Aimeos\MShop\Context\Item\Iface $context,
214
+		\Aimeos\MShop\Order\Item\Base\Iface $newBasket, array $orderProducts, $orderProductId)
215 215
 	{
216
-		foreach( $orderProducts as $orderProduct )
216
+		foreach ($orderProducts as $orderProduct)
217 217
 		{
218
-			if( $orderProduct->getId() == $orderProductId )
218
+			if ($orderProduct->getId() == $orderProductId)
219 219
 			{
220
-				foreach( $orderProduct->getAttributeItems() as $attrItem ) {
221
-					$attrItem->setId( null );
220
+				foreach ($orderProduct->getAttributeItems() as $attrItem) {
221
+					$attrItem->setId(null);
222 222
 				}
223
-				$newBasket->addProduct( $orderProduct->setId( null ) );
223
+				$newBasket->addProduct($orderProduct->setId(null));
224 224
 			}
225 225
 		}
226 226
 
@@ -236,35 +236,35 @@  discard block
 block discarded – undo
236 236
 	 * @param array $services Associative list of type as key and list of service objects implementing \Aimeos\MShop\Order\Item\Base\Service\Iface as values
237 237
 	 * @return \Aimeos\MShop\Order\Item\Base\Iface Order with delivery and payment service added
238 238
 	 */
239
-	protected function addBasketServices( \Aimeos\MShop\Context\Item\Iface $context,
240
-		\Aimeos\MShop\Order\Item\Base\Iface $newBasket, array $services )
239
+	protected function addBasketServices(\Aimeos\MShop\Context\Item\Iface $context,
240
+		\Aimeos\MShop\Order\Item\Base\Iface $newBasket, array $services)
241 241
 	{
242 242
 		$type = \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT;
243 243
 
244
-		if( isset( $services[$type] ) )
244
+		if (isset($services[$type]))
245 245
 		{
246
-			foreach( $services[$type] as $orderService ) {
247
-				$newBasket->addService( $orderService, $type );
246
+			foreach ($services[$type] as $orderService) {
247
+				$newBasket->addService($orderService, $type);
248 248
 			}
249 249
 		}
250 250
 
251 251
 		$type = \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY;
252 252
 
253
-		$serviceManager = \Aimeos\MShop::create( $context, 'service' );
254
-		$orderServiceManager = \Aimeos\MShop::create( $context, 'order/base/service' );
253
+		$serviceManager = \Aimeos\MShop::create($context, 'service');
254
+		$orderServiceManager = \Aimeos\MShop::create($context, 'order/base/service');
255 255
 
256
-		$search = $serviceManager->createSearch( true );
257
-		$search->setSortations( [$search->sort( '+', 'service.position' )] );
258
-		$search->setConditions( $search->compare( '==', 'service.type', $type ) );
256
+		$search = $serviceManager->createSearch(true);
257
+		$search->setSortations([$search->sort('+', 'service.position')]);
258
+		$search->setConditions($search->compare('==', 'service.type', $type));
259 259
 
260
-		foreach( $serviceManager->searchItems( $search, ['media', 'price', 'text'] ) as $item )
260
+		foreach ($serviceManager->searchItems($search, ['media', 'price', 'text']) as $item)
261 261
 		{
262
-			$provider = $serviceManager->getProvider( $item, $item->getType() );
262
+			$provider = $serviceManager->getProvider($item, $item->getType());
263 263
 
264
-			if( $provider->isAvailable( $newBasket ) === true )
264
+			if ($provider->isAvailable($newBasket) === true)
265 265
 			{
266
-				$orderServiceItem = $orderServiceManager->createItem()->copyFrom( $item );
267
-				return $newBasket->addService( $orderServiceItem, $type );
266
+				$orderServiceItem = $orderServiceManager->createItem()->copyFrom($item);
267
+				return $newBasket->addService($orderServiceItem, $type);
268 268
 			}
269 269
 		}
270 270
 
@@ -278,30 +278,30 @@  discard block
 block discarded – undo
278 278
 	 * @param string $baseId Unique order base ID
279 279
 	 * @return \Aimeos\MShop\Context\Item\Iface New context object
280 280
 	 */
281
-	protected function createContext( $baseId )
281
+	protected function createContext($baseId)
282 282
 	{
283 283
 		$context = clone $this->getContext();
284 284
 
285
-		$manager = \Aimeos\MShop::create( $context, 'order/base' );
286
-		$baseItem = $manager->getItem( $baseId );
285
+		$manager = \Aimeos\MShop::create($context, 'order/base');
286
+		$baseItem = $manager->getItem($baseId);
287 287
 
288 288
 		$locale = $baseItem->getLocale();
289 289
 		$level = \Aimeos\MShop\Locale\Manager\Base::SITE_ALL;
290 290
 
291
-		$manager = \Aimeos\MShop::create( $context, 'locale' );
292
-		$locale = $manager->bootstrap( $baseItem->getSiteCode(), $locale->getLanguageId(), $locale->getCurrencyId(), false, $level );
291
+		$manager = \Aimeos\MShop::create($context, 'locale');
292
+		$locale = $manager->bootstrap($baseItem->getSiteCode(), $locale->getLanguageId(), $locale->getCurrencyId(), false, $level);
293 293
 
294
-		$context->setLocale( $locale );
294
+		$context->setLocale($locale);
295 295
 
296 296
 		try
297 297
 		{
298
-			$manager = \Aimeos\MShop::create( $context, 'customer' );
299
-			$customerItem = $manager->getItem( $baseItem->getCustomerId(), ['customer/group'] );
298
+			$manager = \Aimeos\MShop::create($context, 'customer');
299
+			$customerItem = $manager->getItem($baseItem->getCustomerId(), ['customer/group']);
300 300
 
301
-			$context->setUserId( $baseItem->getCustomerId() );
302
-			$context->setGroupIds( $customerItem->getGroups() );
301
+			$context->setUserId($baseItem->getCustomerId());
302
+			$context->setGroupIds($customerItem->getGroups());
303 303
 		}
304
-		catch( \Exception $e ) {} // Subscription without account
304
+		catch (\Exception $e) {} // Subscription without account
305 305
 
306 306
 		return $context;
307 307
 	}
@@ -314,19 +314,19 @@  discard block
 block discarded – undo
314 314
 	 * @param \Aimeos\MShop\Subscription\Item\Iface $subscription Subscription item with order base ID and order product ID
315 315
 	 * @return \Aimeos\MShop\Order\Item\Base\Iface Complete order with product, addresses and services saved to the storage
316 316
 	 */
317
-	protected function createOrderBase( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Subscription\Item\Iface $subscription )
317
+	protected function createOrderBase(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Subscription\Item\Iface $subscription)
318 318
 	{
319
-		$manager = \Aimeos\MShop::create( $context, 'order/base' );
319
+		$manager = \Aimeos\MShop::create($context, 'order/base');
320 320
 
321
-		$basket = $manager->load( $subscription->getOrderBaseId() );
322
-		$newBasket = $manager->createItem()->setCustomerId( $basket->getCustomerId() );
321
+		$basket = $manager->load($subscription->getOrderBaseId());
322
+		$newBasket = $manager->createItem()->setCustomerId($basket->getCustomerId());
323 323
 
324
-		$newBasket = $this->addBasketProducts( $context, $newBasket, $basket->getProducts(), $subscription->getOrderProductId() );
325
-		$newBasket = $this->addBasketAddresses( $context, $newBasket, $basket->getAddresses() );
326
-		$newBasket = $this->addBasketServices( $context, $newBasket, $basket->getServices() );
327
-		$newBasket = $this->addBasketCoupons( $context, $newBasket, array_keys( $basket->getCoupons() ) );
324
+		$newBasket = $this->addBasketProducts($context, $newBasket, $basket->getProducts(), $subscription->getOrderProductId());
325
+		$newBasket = $this->addBasketAddresses($context, $newBasket, $basket->getAddresses());
326
+		$newBasket = $this->addBasketServices($context, $newBasket, $basket->getServices());
327
+		$newBasket = $this->addBasketCoupons($context, $newBasket, array_keys($basket->getCoupons()));
328 328
 
329
-		return $manager->store( $newBasket );
329
+		return $manager->store($newBasket);
330 330
 	}
331 331
 
332 332
 
@@ -337,15 +337,15 @@  discard block
 block discarded – undo
337 337
 	 * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Complete order with product, addresses and services saved to the storage
338 338
 	 * @return \Aimeos\MShop\Order\Item\Iface New invoice item associated to the order saved to the storage
339 339
 	 */
340
-	protected function createOrderInvoice( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket )
340
+	protected function createOrderInvoice(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket)
341 341
 	{
342
-		$manager = \Aimeos\MShop::create( $context, 'order' );
342
+		$manager = \Aimeos\MShop::create($context, 'order');
343 343
 
344 344
 		$item = $manager->createItem();
345
-		$item->setBaseId( $basket->getId() );
346
-		$item->setType( 'subscription' );
345
+		$item->setBaseId($basket->getId());
346
+		$item->setType('subscription');
347 347
 
348
-		return $manager->saveItem( $item );
348
+		return $manager->saveItem($item);
349 349
 	}
350 350
 
351 351
 
@@ -356,17 +356,17 @@  discard block
 block discarded – undo
356 356
 	 * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Complete order with product, addresses and services
357 357
 	 * @param \Aimeos\MShop\Order\Item\Iface New invoice item associated to the order
358 358
 	 */
359
-	protected function createPayment( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket,
360
-		\Aimeos\MShop\Order\Item\Iface $invoice )
359
+	protected function createPayment(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket,
360
+		\Aimeos\MShop\Order\Item\Iface $invoice)
361 361
 	{
362
-		$manager = \Aimeos\MShop::create( $context, 'service' );
362
+		$manager = \Aimeos\MShop::create($context, 'service');
363 363
 
364
-		foreach( $basket->getService( \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT ) as $service )
364
+		foreach ($basket->getService(\Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT) as $service)
365 365
 		{
366
-			$item = $manager->getItem( $service->getServiceId() );
367
-			$provider = $manager->getProvider( $item, 'payment' );
366
+			$item = $manager->getItem($service->getServiceId());
367
+			$provider = $manager->getProvider($item, 'payment');
368 368
 
369
-			$provider->repay( $invoice );
369
+			$provider->repay($invoice);
370 370
 		}
371 371
 	}
372 372
 }
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Subscription/Process/Begin/Standard.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	public function getName()
30 30
 	{
31
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Subscription process start' );
31
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Subscription process start');
32 32
 	}
33 33
 
34 34
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	public function getDescription()
41 41
 	{
42
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Process subscriptions initially' );
42
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Process subscriptions initially');
43 43
 	}
44 44
 
45 45
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 		 * @see controller/common/subscription/process/payment-status
68 68
 		 * @see controller/common/subscription/process/payment-days
69 69
 		 */
70
-		$names = (array) $config->get( 'controller/common/subscription/process/processors', [] );
70
+		$names = (array) $config->get('controller/common/subscription/process/processors', []);
71 71
 
72 72
 		/** controller/common/subscription/process/payment-status
73 73
 		 * Minimum payment status that will activate the subscription
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 		 * @see controller/common/subscription/process/payment-days
87 87
 		 */
88 88
 		$status = \Aimeos\MShop\Order\Item\Base::PAY_AUTHORIZED;
89
-		$status = $config->get( 'controller/common/subscription/process/payment-status', $status );
89
+		$status = $config->get('controller/common/subscription/process/payment-status', $status);
90 90
 
91 91
 		/** controller/common/subscription/process/payment-days
92 92
 		 * Number of days to wait for the payment until subscription is removed
@@ -104,74 +104,74 @@  discard block
 block discarded – undo
104 104
 		 * @see controller/common/subscription/process/processors
105 105
 		 * @see controller/common/subscription/process/payment-status
106 106
 		 */
107
-		$days = (float) $config->get( 'controller/common/subscription/process/payment-days', 3 );
107
+		$days = (float) $config->get('controller/common/subscription/process/payment-days', 3);
108 108
 
109 109
 
110
-		$processors = $this->getProcessors( $names );
111
-		$orderManager = \Aimeos\MShop::create( $context, 'order' );
112
-		$manager = \Aimeos\MShop::create( $context, 'subscription' );
110
+		$processors = $this->getProcessors($names);
111
+		$orderManager = \Aimeos\MShop::create($context, 'order');
112
+		$manager = \Aimeos\MShop::create($context, 'subscription');
113 113
 
114
-		$search = $manager->createSearch( true );
114
+		$search = $manager->createSearch(true);
115 115
 		$expr = [
116
-			$search->compare( '==', 'subscription.datenext', null ),
116
+			$search->compare('==', 'subscription.datenext', null),
117 117
 			$search->getConditions(),
118 118
 		];
119
-		$search->setConditions( $search->combine( '&&', $expr ) );
120
-		$search->setSortations( [$search->sort( '+', 'subscription.id' )] );
119
+		$search->setConditions($search->combine('&&', $expr));
120
+		$search->setSortations([$search->sort('+', 'subscription.id')]);
121 121
 
122
-		$date = date( 'Y-m-d H:i:s', time() - 86400 * $days );
122
+		$date = date('Y-m-d H:i:s', time() - 86400 * $days);
123 123
 		$start = 0;
124 124
 
125 125
 		do
126 126
 		{
127 127
 			$ordBaseIds = $payStatus = [];
128 128
 
129
-			$search->setSlice( $start, 100 );
130
-			$items = $manager->searchItems( $search );
129
+			$search->setSlice($start, 100);
130
+			$items = $manager->searchItems($search);
131 131
 
132
-			foreach( $items as $item ) {
132
+			foreach ($items as $item) {
133 133
 				$ordBaseIds[] = $item->getOrderBaseId();
134 134
 			}
135 135
 
136
-			$orderSearch = $orderManager->createSearch()->setSlice( 0, $search->getSliceSize() );
137
-			$orderSearch->setConditions( $orderSearch->compare( '==', 'order.base.id', $ordBaseIds ) );
138
-			$orderSearch->setSortations( [$orderSearch->sort( '+', 'order.id' )] );
136
+			$orderSearch = $orderManager->createSearch()->setSlice(0, $search->getSliceSize());
137
+			$orderSearch->setConditions($orderSearch->compare('==', 'order.base.id', $ordBaseIds));
138
+			$orderSearch->setSortations([$orderSearch->sort('+', 'order.id')]);
139 139
 
140
-			foreach( $orderManager->searchItems( $orderSearch ) as $orderItem ) {
140
+			foreach ($orderManager->searchItems($orderSearch) as $orderItem) {
141 141
 				$payStatus[$orderItem->getBaseId()] = $orderItem->getPaymentStatus();
142 142
 			}
143 143
 
144
-			foreach( $items as $item )
144
+			foreach ($items as $item)
145 145
 			{
146 146
 				try
147 147
 				{
148
-					if( isset( $payStatus[$item->getOrderBaseId()] ) && $payStatus[$item->getOrderBaseId()] >= $status )
148
+					if (isset($payStatus[$item->getOrderBaseId()]) && $payStatus[$item->getOrderBaseId()] >= $status)
149 149
 					{
150
-						foreach( $processors as $processor ) {
151
-							$processor->begin( $item );
150
+						foreach ($processors as $processor) {
151
+							$processor->begin($item);
152 152
 						}
153 153
 
154
-						$interval = new \DateInterval( $item->getInterval() );
155
-						$item->setDateNext( date_create( $item->getTimeCreated() )->add( $interval )->format( 'Y-m-d' ) );
154
+						$interval = new \DateInterval($item->getInterval());
155
+						$item->setDateNext(date_create($item->getTimeCreated())->add($interval)->format('Y-m-d'));
156 156
 					}
157
-					elseif( $item->getTimeCreated() < $date )
157
+					elseif ($item->getTimeCreated() < $date)
158 158
 					{
159
-						$item->setStatus( 0 );
159
+						$item->setStatus(0);
160 160
 					}
161 161
 
162
-					$manager->saveItem( $item );
162
+					$manager->saveItem($item);
163 163
 				}
164
-				catch( \Exception $e )
164
+				catch (\Exception $e)
165 165
 				{
166 166
 					$msg = 'Unable to process subscription with ID "%1$S": %2$s';
167
-					$logger->log( sprintf( $msg, $item->getId(), $e->getMessage() ) );
168
-					$logger->log( $e->getTraceAsString() );
167
+					$logger->log(sprintf($msg, $item->getId(), $e->getMessage()));
168
+					$logger->log($e->getTraceAsString());
169 169
 				}
170 170
 			}
171 171
 
172
-			$count = count( $items );
172
+			$count = count($items);
173 173
 			$start += $count;
174 174
 		}
175
-		while( $count === $search->getSliceSize() );
175
+		while ($count === $search->getSliceSize());
176 176
 	}
177 177
 }
Please login to merge, or discard this patch.