Completed
Pull Request — master (#5)
by
unknown
03:31
created
controller/jobs/src/Controller/Jobs/Product/Export/Standard.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -290,14 +290,14 @@
 block discarded – undo
290 290
 
291 291
 		$indexManager = \Aimeos\MShop\Index\Manager\Factory::createManager($this->getContext());
292 292
 
293
-       		$search = $indexManager->createSearch($default);
294
-        	$search->setSlice(0, $maxQuery);
295
-        	$search->setConditions(
296
-            		$search->compare('!=', 'index.catalog.id', null)
297
-        	);
298
-        	$search->setSortations(
299
-            		[$search->sort('+', 'product.id')]
300
-        	);
293
+	   		$search = $indexManager->createSearch($default);
294
+			$search->setSlice(0, $maxQuery);
295
+			$search->setConditions(
296
+					$search->compare('!=', 'index.catalog.id', null)
297
+			);
298
+			$search->setSortations(
299
+					[$search->sort('+', 'product.id')]
300
+			);
301 301
 
302 302
 		do
303 303
 		{
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 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,13 +277,13 @@  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 = [];
@@ -301,23 +301,23 @@  discard block
 block discarded – undo
301 301
 
302 302
 		do
303 303
 		{
304
-			$items = $indexManager->searchItems( $search, $domains );
305
-			$this->addItems( $content, $items );
304
+			$items = $indexManager->searchItems($search, $domains);
305
+			$this->addItems($content, $items);
306 306
 
307
-			$count = count( $items );
307
+			$count = count($items);
308 308
 			$start += $count;
309
-			$search->setSlice( $start, $maxQuery );
309
+			$search->setSlice($start, $maxQuery);
310 310
 
311
-			if( $start + $maxQuery > $maxItems * $filenum )
311
+			if ($start + $maxQuery > $maxItems * $filenum)
312 312
 			{
313
-				$this->closeContent( $content );
314
-				$content = $this->createContent( $container, ++$filenum );
313
+				$this->closeContent($content);
314
+				$content = $this->createContent($container, ++$filenum);
315 315
 				$names[] = $content->getResource();
316 316
 			}
317 317
 		}
318
-		while( $count >= $search->getSliceSize() );
318
+		while ($count >= $search->getSliceSize());
319 319
 
320
-		$this->closeContent( $content );
320
+		$this->closeContent($content);
321 321
 
322 322
 		return $names;
323 323
 	}
@@ -330,11 +330,11 @@  discard block
 block discarded – undo
330 330
 	 * @param mixed $default Default value if name is unknown
331 331
 	 * @return mixed Configuration value
332 332
 	 */
333
-	protected function getConfig( $name, $default = null )
333
+	protected function getConfig($name, $default = null)
334 334
 	{
335 335
 		$config = $this->getContext()->getConfig();
336 336
 
337
-		switch( $name )
337
+		switch ($name)
338 338
 		{
339 339
 			case 'domain':
340 340
 				/** controller/jobs/product/export/domains
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 				 * @see controller/jobs/product/export/max-items
358 358
 				 * @see controller/jobs/product/export/max-query
359 359
 				 */
360
-				return $config->get( 'controller/jobs/product/export/domains', $default );
360
+				return $config->get('controller/jobs/product/export/domains', $default);
361 361
 
362 362
 			case 'max-items':
363 363
 				/** controller/jobs/product/export/max-items
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 				 * @see controller/jobs/product/export/max-query
381 381
 				 * @see controller/jobs/product/export/domains
382 382
 				 */
383
-				return $config->get( 'controller/jobs/product/export/max-items', $default );
383
+				return $config->get('controller/jobs/product/export/max-items', $default);
384 384
 
385 385
 			case 'max-query':
386 386
 				/** controller/jobs/product/export/max-query
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 				 * @see controller/jobs/product/export/max-items
404 404
 				 * @see controller/jobs/product/export/domains
405 405
 				 */
406
-				return $config->get( 'controller/jobs/product/export/max-query', $default );
406
+				return $config->get('controller/jobs/product/export/max-query', $default);
407 407
 
408 408
 			case 'filename':
409 409
 				/** controller/jobs/product/export/filename
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 				 * @see controller/jobs/product/export/max-query
425 425
 				 * @see controller/jobs/product/export/domains
426 426
 				 */
427
-				return $config->get( 'controller/jobs/product/export/filename', $default );
427
+				return $config->get('controller/jobs/product/export/filename', $default);
428 428
 		}
429 429
 
430 430
 		return $default;
@@ -437,8 +437,8 @@  discard block
 block discarded – undo
437 437
 	 * @param integer $number Current file number
438 438
 	 * @return string New file name
439 439
 	 */
440
-	protected function getFilename( $number )
440
+	protected function getFilename($number)
441 441
 	{
442
-		return sprintf( $this->getConfig( 'filename', 'aimeos-products-%1$d_%2$s.xml' ), $number, date( 'Y-m-d_H:i:s' ) );
442
+		return sprintf($this->getConfig('filename', 'aimeos-products-%1$d_%2$s.xml'), $number, date('Y-m-d_H:i:s'));
443 443
 	}
444 444
 }
Please login to merge, or discard this patch.