Completed
Push — master ( 6dd458...ee0799 )
by Aimeos
10s
created
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\Factory::createManager( $this->getContext(), 'index' );
356
+		$manager = \Aimeos\MShop\Factory::createManager($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.