Completed
Push — master ( 2df236...6b2914 )
by Aimeos
02:25
created
controller/jobs/src/Controller/Jobs/Product/Export/Sitemap/Standard.php 1 patch
Spacing   +26 added lines, -26 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', sys_get_temp_dir() );
178
+		$location = $config->get('controller/jobs/product/export/sitemap/location', sys_get_temp_dir());
179 179
 
180 180
 		/** controller/jobs/product/export/sitemap/container/options
181 181
 		 * List of file container options for the site map files
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
 		 * @see controller/jobs/product/export/sitemap/max-query
196 196
 		 * @see controller/jobs/product/export/sitemap/changefreq
197 197
 		 */
198
-		$options = $config->get( 'controller/jobs/product/export/sitemap/container/options', array() );
198
+		$options = $config->get('controller/jobs/product/export/sitemap/container/options', array());
199 199
 
200
-		return \Aimeos\MW\Container\Factory::getContainer( $location, 'Directory', 'Gzip', $options );
200
+		return \Aimeos\MW\Container\Factory::getContainer($location, 'Directory', 'Gzip', $options);
201 201
 	}
202 202
 
203 203
 
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	 * @param integer $filenum New file number
209 209
 	 * @return \Aimeos\MW\Container\Content\Iface New content object
210 210
 	 */
211
-	protected function createContent( \Aimeos\MW\Container\Iface $container, $filenum )
211
+	protected function createContent(\Aimeos\MW\Container\Iface $container, $filenum)
212 212
 	{
213 213
 		/** controller/jobs/product/export/sitemap/standard/template-header
214 214
 		 * Relative path to the XML site map header template of the product site map job controller.
@@ -238,9 +238,9 @@  discard block
 block discarded – undo
238 238
 		$context = $this->getContext();
239 239
 		$view = $context->getView();
240 240
 
241
-		$content = $container->create( $this->getFilename( $filenum ) );
242
-		$content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) );
243
-		$container->add( $content );
241
+		$content = $container->create($this->getFilename($filenum));
242
+		$content->add($view->render($context->getConfig()->get($tplconf, $default)));
243
+		$container->add($content);
244 244
 
245 245
 		return $content;
246 246
 	}
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 	 *
252 252
 	 * @param \Aimeos\MW\Container\Content\Iface $content
253 253
 	 */
254
-	protected function closeContent( \Aimeos\MW\Container\Content\Iface $content )
254
+	protected function closeContent(\Aimeos\MW\Container\Content\Iface $content)
255 255
 	{
256 256
 		/** controller/jobs/product/export/sitemap/standard/template-footer
257 257
 		 * Relative path to the XML site map footer template of the product site map job controller.
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 		$context = $this->getContext();
282 282
 		$view = $context->getView();
283 283
 
284
-		$content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) );
284
+		$content->add($view->render($context->getConfig()->get($tplconf, $default)));
285 285
 	}
286 286
 
287 287
 
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 	 * @param \Aimeos\MW\Container\Iface $container File container object
292 292
 	 * @param array $files List of generated site map file names
293 293
 	 */
294
-	protected function createSitemapIndex( \Aimeos\MW\Container\Iface $container, array $files )
294
+	protected function createSitemapIndex(\Aimeos\MW\Container\Iface $container, array $files)
295 295
 	{
296 296
 		/** controller/jobs/product/export/sitemap/standard/template-index
297 297
 		 * Relative path to the XML site map index template of the product site map job controller.
@@ -323,9 +323,9 @@  discard block
 block discarded – undo
323 323
 
324 324
 		$view->siteFiles = $files;
325 325
 
326
-		$content = $container->create( 'aimeos-sitemap-index.xml' );
327
-		$content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) );
328
-		$container->add( $content );
326
+		$content = $container->create('aimeos-sitemap-index.xml');
327
+		$content->add($view->render($context->getConfig()->get($tplconf, $default)));
328
+		$container->add($content);
329 329
 	}
330 330
 
331 331
 
@@ -336,11 +336,11 @@  discard block
 block discarded – undo
336 336
 	 * @param mixed $default Default value if name is unknown
337 337
 	 * @return mixed Configuration value
338 338
 	 */
339
-	protected function getConfig( $name, $default = null )
339
+	protected function getConfig($name, $default = null)
340 340
 	{
341 341
 		$config = $this->getContext()->getConfig();
342 342
 
343
-		switch( $name )
343
+		switch ($name)
344 344
 		{
345 345
 			case 'domain':
346 346
 				return array();
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 				 * @see controller/jobs/product/export/sitemap/max-query
368 368
 				 * @see controller/jobs/product/export/sitemap/changefreq
369 369
 				 */
370
-				return $config->get( 'controller/jobs/product/export/sitemap/max-items', 50000 );
370
+				return $config->get('controller/jobs/product/export/sitemap/max-items', 50000);
371 371
 
372 372
 			case 'max-query':
373 373
 				/** controller/jobs/product/export/sitemap/max-query
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 				 * @see controller/jobs/product/export/sitemap/max-items
388 388
 				 * @see controller/jobs/product/export/sitemap/changefreq
389 389
 				 */
390
-				return $config->get( 'controller/jobs/product/export/sitemap/max-query', 1000 );
390
+				return $config->get('controller/jobs/product/export/sitemap/max-query', 1000);
391 391
 		}
392 392
 
393 393
 		return $default;
@@ -400,8 +400,8 @@  discard block
 block discarded – undo
400 400
 	 * @param integer $number Current file number
401 401
 	 * @return string New file name
402 402
 	 */
403
-	protected function getFilename( $number )
403
+	protected function getFilename($number)
404 404
 	{
405
-		return sprintf( 'aimeos-sitemap-%d.xml', $number );
405
+		return sprintf('aimeos-sitemap-%d.xml', $number);
406 406
 	}
407 407
 }
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Product/Export/Standard.php 1 patch
Spacing   +42 added lines, -42 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', array() );
177
+		$options = $config->get('controller/jobs/product/export/standard/container/options', array());
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 = array();
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
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 				 * @see controller/jobs/product/export/max-items
348 348
 				 * @see controller/jobs/product/export/max-query
349 349
 				 */
350
-				return $config->get( 'controller/jobs/product/export/domains', $default );
350
+				return $config->get('controller/jobs/product/export/domains', $default);
351 351
 
352 352
 			case 'max-items':
353 353
 				/** controller/jobs/product/export/max-items
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 				 * @see controller/jobs/product/export/max-query
370 370
 				 * @see controller/jobs/product/export/domains
371 371
 				 */
372
-				return $config->get( 'controller/jobs/product/export/max-items', $default );
372
+				return $config->get('controller/jobs/product/export/max-items', $default);
373 373
 
374 374
 			case 'max-query':
375 375
 				/** controller/jobs/product/export/max-query
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 				 * @see controller/jobs/product/export/max-items
392 392
 				 * @see controller/jobs/product/export/domains
393 393
 				 */
394
-				return $config->get( 'controller/jobs/product/export/max-query', $default );
394
+				return $config->get('controller/jobs/product/export/max-query', $default);
395 395
 		}
396 396
 
397 397
 		return $default;
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 404
 	 * @param integer $number Current file number
405 405
 	 * @return string New file name
406 406
 	 */
407
-	protected function getFilename( $number )
407
+	protected function getFilename($number)
408 408
 	{
409
-		return sprintf( 'aimeos-products-%d.xml', $number );
409
+		return sprintf('aimeos-products-%d.xml', $number);
410 410
 	}
411 411
 }
Please login to merge, or discard this patch.