Completed
Pull Request — master (#6)
by
unknown
02:53
created
controller/jobs/src/Controller/Jobs/Product/Export/Standard.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -275,7 +275,7 @@
 block discarded – undo
275 275
 	 *
276 276
 	 * @param \Aimeos\MW\Container\Iface $container Container object
277 277
 	 * @param boolean $default True to filter exported products by default criteria
278
-	 * @return array List of content (file) names
278
+	 * @return string[] List of content (file) names
279 279
 	 */
280 280
 	protected function export( \Aimeos\MW\Container\Iface $container, $default = true )
281 281
 	{
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -291,14 +291,14 @@
 block discarded – undo
291 291
 		$indexManager = \Aimeos\MShop\Index\Manager\Factory::createManager($this->getContext());
292 292
 
293 293
 		$search = $indexManager->createSearch($default);
294
-        	$search->setSlice(0, $maxQuery);
294
+			$search->setSlice(0, $maxQuery);
295 295
 		
296
-        	$search->setConditions(
297
-          		$search->compare('!=', 'index.catalog.id', null)
298
-        	);
299
-        	$search->setSortations(
300
-         		[$search->sort('+', 'product.id')]
301
-        	);
296
+			$search->setConditions(
297
+		  		$search->compare('!=', 'index.catalog.id', null)
298
+			);
299
+			$search->setSortations(
300
+		 		[$search->sort('+', 'product.id')]
301
+			);
302 302
 		
303 303
 		$content = $this->createContent( $container, $filenum );
304 304
 		$names[] = basename($content->getResource());
Please login to merge, or discard this 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, 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 = [ 'attribute', 'media', 'price', 'product', 'text' ];
282
+		$domains = ['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 = [];
@@ -300,28 +300,28 @@  discard block
 block discarded – undo
300 300
          		[$search->sort('+', 'product.id')]
301 301
         	);
302 302
 		
303
-		$content = $this->createContent( $container, $filenum );
303
+		$content = $this->createContent($container, $filenum);
304 304
 		$names[] = basename($content->getResource());
305 305
 
306 306
 		do
307 307
 		{
308
-			$items = $indexManager->searchItems( $search, $domains );
309
-			$this->addItems( $content, $items );
308
+			$items = $indexManager->searchItems($search, $domains);
309
+			$this->addItems($content, $items);
310 310
 
311
-			$count = count( $items );
311
+			$count = count($items);
312 312
 			$start += $count;
313
-			$search->setSlice( $start, $maxQuery );
313
+			$search->setSlice($start, $maxQuery);
314 314
 
315
-			if( $start + $maxQuery > $maxItems * $filenum )
315
+			if ($start + $maxQuery > $maxItems * $filenum)
316 316
 			{
317
-				$this->closeContent( $content );
318
-				$content = $this->createContent( $container, ++$filenum );
317
+				$this->closeContent($content);
318
+				$content = $this->createContent($container, ++$filenum);
319 319
 				$names[] = basename($content->getResource());
320 320
 			}
321 321
 		}
322
-		while( $count >= $search->getSliceSize() );
322
+		while ($count >= $search->getSliceSize());
323 323
 
324
-		$this->closeContent( $content );
324
+		$this->closeContent($content);
325 325
 
326 326
 		return $names;
327 327
 	}
@@ -334,11 +334,11 @@  discard block
 block discarded – undo
334 334
 	 * @param mixed $default Default value if name is unknown
335 335
 	 * @return mixed Configuration value
336 336
 	 */
337
-	protected function getConfig( $name, $default = null )
337
+	protected function getConfig($name, $default = null)
338 338
 	{
339 339
 		$config = $this->getContext()->getConfig();
340 340
 
341
-		switch( $name )
341
+		switch ($name)
342 342
 		{
343 343
 			case 'domain':
344 344
 				/** controller/jobs/product/export/domains
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 				 * @see controller/jobs/product/export/max-items
362 362
 				 * @see controller/jobs/product/export/max-query
363 363
 				 */
364
-				return $config->get( 'controller/jobs/product/export/domains', $default );
364
+				return $config->get('controller/jobs/product/export/domains', $default);
365 365
 
366 366
 			case 'max-items':
367 367
 				/** controller/jobs/product/export/max-items
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 				 * @see controller/jobs/product/export/max-query
385 385
 				 * @see controller/jobs/product/export/domains
386 386
 				 */
387
-				return $config->get( 'controller/jobs/product/export/max-items', $default );
387
+				return $config->get('controller/jobs/product/export/max-items', $default);
388 388
 
389 389
 			case 'max-query':
390 390
 				/** controller/jobs/product/export/max-query
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 				 * @see controller/jobs/product/export/max-items
408 408
 				 * @see controller/jobs/product/export/domains
409 409
 				 */
410
-				return $config->get( 'controller/jobs/product/export/max-query', $default );
410
+				return $config->get('controller/jobs/product/export/max-query', $default);
411 411
 
412 412
 			case 'filename':
413 413
 				/** controller/jobs/product/export/filename
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 				 * @see controller/jobs/product/export/max-query
429 429
 				 * @see controller/jobs/product/export/domains
430 430
 				 */
431
-				return $config->get( 'controller/jobs/product/export/filename', $default );
431
+				return $config->get('controller/jobs/product/export/filename', $default);
432 432
 		}
433 433
 
434 434
 		return $default;
@@ -441,8 +441,8 @@  discard block
 block discarded – undo
441 441
 	 * @param integer $number Current file number
442 442
 	 * @return string New file name
443 443
 	 */
444
-	protected function getFilename( $number )
444
+	protected function getFilename($number)
445 445
 	{
446
-		return sprintf( $this->getConfig( 'filename', 'aimeos-products-%1$d_%2$s.xml' ), $number, date( 'Y-m-d_H:i:s' ) );
446
+		return sprintf($this->getConfig('filename', 'aimeos-products-%1$d_%2$s.xml'), $number, date('Y-m-d_H:i:s'));
447 447
 	}
448 448
 }
Please login to merge, or discard this patch.