Completed
Push — master ( e18811...62e25d )
by Aimeos
06:01
created
controller/jobs/src/Controller/Jobs/Product/Export/Standard.php 1 patch
Spacing   +43 added lines, -43 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 );
54
+		$this->export($container);
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', sys_get_temp_dir() );
126
+		$location = $config->get('controller/jobs/product/export/location', sys_get_temp_dir());
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,9 +174,9 @@  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
-		return \Aimeos\MW\Container\Factory::getContainer( $location, $container, $content, $options );
179
+		return \Aimeos\MW\Container\Factory::getContainer($location, $container, $content, $options);
180 180
 	}
181 181
 
182 182
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 	 * @param integer $filenum New file number
188 188
 	 * @return \Aimeos\MW\Container\Content\Iface New content object
189 189
 	 */
190
-	protected function createContent( \Aimeos\MW\Container\Iface $container, $filenum )
190
+	protected function createContent(\Aimeos\MW\Container\Iface $container, $filenum)
191 191
 	{
192 192
 		/** controller/jobs/product/export/standard/template-header
193 193
 		 * Relative path to the XML site map header template of the product site map job controller.
@@ -217,9 +217,9 @@  discard block
 block discarded – undo
217 217
 		$context = $this->getContext();
218 218
 		$view = $context->getView();
219 219
 
220
-		$content = $container->create( $this->getFilename( $filenum ) );
221
-		$content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) );
222
-		$container->add( $content );
220
+		$content = $container->create($this->getFilename($filenum));
221
+		$content->add($view->render($context->getConfig()->get($tplconf, $default)));
222
+		$container->add($content);
223 223
 
224 224
 		return $content;
225 225
 	}
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 	 *
231 231
 	 * @param \Aimeos\MW\Container\Content\Iface $content
232 232
 	 */
233
-	protected function closeContent( \Aimeos\MW\Container\Content\Iface $content )
233
+	protected function closeContent(\Aimeos\MW\Container\Content\Iface $content)
234 234
 	{
235 235
 		/** controller/jobs/product/export/standard/template-footer
236 236
 		 * Relative path to the XML site map footer template of the product site map job controller.
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 		$context = $this->getContext();
261 261
 		$view = $context->getView();
262 262
 
263
-		$content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) );
263
+		$content->add($view->render($context->getConfig()->get($tplconf, $default)));
264 264
 	}
265 265
 
266 266
 
@@ -270,45 +270,45 @@  discard block
 block discarded – undo
270 270
 	 * @param \Aimeos\MW\Container\Iface $container Container object
271 271
 	 * @return array List of content (file) names
272 272
 	 */
273
-	protected function export( \Aimeos\MW\Container\Iface $container )
273
+	protected function export(\Aimeos\MW\Container\Iface $container)
274 274
 	{
275
-		$default = array( 'attribute', 'media', 'price', 'product', 'text' );
275
+		$default = array('attribute', 'media', 'price', 'product', 'text');
276 276
 
277
-		$domains = $this->getConfig( 'domains', $default );
278
-		$maxItems = $this->getConfig( 'max-items', 10000 );
279
-		$maxQuery = $this->getConfig( 'max-query', 1000 );
277
+		$domains = $this->getConfig('domains', $default);
278
+		$maxItems = $this->getConfig('max-items', 10000);
279
+		$maxQuery = $this->getConfig('max-query', 1000);
280 280
 
281 281
 		$start = 0; $filenum = 1;
282 282
 		$names = [];
283 283
 
284
-		$productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' );
284
+		$productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product');
285 285
 
286
-		$search = $productManager->createSearch( true );
287
-		$search->setSortations( array( $search->sort( '+', 'product.id' ) ) );
288
-		$search->setSlice( 0, $maxQuery );
286
+		$search = $productManager->createSearch(true);
287
+		$search->setSortations(array($search->sort('+', 'product.id')));
288
+		$search->setSlice(0, $maxQuery);
289 289
 
290
-		$content = $this->createContent( $container, $filenum );
290
+		$content = $this->createContent($container, $filenum);
291 291
 		$names[] = $content->getResource();
292 292
 
293 293
 		do
294 294
 		{
295
-			$items = $productManager->searchItems( $search, $domains );
296
-			$this->addItems( $content, $items );
295
+			$items = $productManager->searchItems($search, $domains);
296
+			$this->addItems($content, $items);
297 297
 
298
-			$count = count( $items );
298
+			$count = count($items);
299 299
 			$start += $count;
300
-			$search->setSlice( $start, $maxQuery );
300
+			$search->setSlice($start, $maxQuery);
301 301
 
302
-			if( $start + $maxQuery > $maxItems * $filenum )
302
+			if ($start + $maxQuery > $maxItems * $filenum)
303 303
 			{
304
-				$this->closeContent( $content );
305
-				$content = $this->createContent( $container, ++$filenum );
304
+				$this->closeContent($content);
305
+				$content = $this->createContent($container, ++$filenum);
306 306
 				$names[] = $content->getResource();
307 307
 			}
308 308
 		}
309
-		while( $count >= $search->getSliceSize() );
309
+		while ($count >= $search->getSliceSize());
310 310
 
311
-		$this->closeContent( $content );
311
+		$this->closeContent($content);
312 312
 
313 313
 		return $names;
314 314
 	}
@@ -321,11 +321,11 @@  discard block
 block discarded – undo
321 321
 	 * @param mixed $default Default value if name is unknown
322 322
 	 * @return mixed Configuration value
323 323
 	 */
324
-	protected function getConfig( $name, $default = null )
324
+	protected function getConfig($name, $default = null)
325 325
 	{
326 326
 		$config = $this->getContext()->getConfig();
327 327
 
328
-		switch( $name )
328
+		switch ($name)
329 329
 		{
330 330
 			case 'domain':
331 331
 				/** controller/jobs/product/export/domains
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 				 * @see controller/jobs/product/export/max-items
349 349
 				 * @see controller/jobs/product/export/max-query
350 350
 				 */
351
-				return $config->get( 'controller/jobs/product/export/domains', $default );
351
+				return $config->get('controller/jobs/product/export/domains', $default);
352 352
 
353 353
 			case 'max-items':
354 354
 				/** controller/jobs/product/export/max-items
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 				 * @see controller/jobs/product/export/max-query
372 372
 				 * @see controller/jobs/product/export/domains
373 373
 				 */
374
-				return $config->get( 'controller/jobs/product/export/max-items', $default );
374
+				return $config->get('controller/jobs/product/export/max-items', $default);
375 375
 
376 376
 			case 'max-query':
377 377
 				/** controller/jobs/product/export/max-query
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
 				 * @see controller/jobs/product/export/max-items
395 395
 				 * @see controller/jobs/product/export/domains
396 396
 				 */
397
-				return $config->get( 'controller/jobs/product/export/max-query', $default );
397
+				return $config->get('controller/jobs/product/export/max-query', $default);
398 398
 
399 399
 			case 'filename':
400 400
 				/** controller/jobs/product/export/filename
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 				 * @see controller/jobs/product/export/max-query
416 416
 				 * @see controller/jobs/product/export/domains
417 417
 				 */
418
-				return $config->get( 'controller/jobs/product/export/filename', $default );
418
+				return $config->get('controller/jobs/product/export/filename', $default);
419 419
 		}
420 420
 
421 421
 		return $default;
@@ -428,8 +428,8 @@  discard block
 block discarded – undo
428 428
 	 * @param integer $number Current file number
429 429
 	 * @return string New file name
430 430
 	 */
431
-	protected function getFilename( $number )
431
+	protected function getFilename($number)
432 432
 	{
433
-		return sprintf( $this->getConfig( 'filename', 'aimeos-products-%1$d_%2$s.xml' ), $number, date( 'Y-m-d_H:i:s' ) );
433
+		return sprintf($this->getConfig('filename', 'aimeos-products-%1$d_%2$s.xml'), $number, date('Y-m-d_H:i:s'));
434 434
 	}
435 435
 }
Please login to merge, or discard this patch.