| @@ -28,7 +28,7 @@ discard block | ||
| 28 | 28 | */ | 
| 29 | 29 | public function getName() | 
| 30 | 30 |  	{ | 
| 31 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Order export CSV' ); | |
| 31 | +		return $this->getContext()->getI18n()->dt('controller/jobs', 'Order export CSV'); | |
| 32 | 32 | } | 
| 33 | 33 | |
| 34 | 34 | |
| @@ -39,7 +39,7 @@ discard block | ||
| 39 | 39 | */ | 
| 40 | 40 | public function getDescription() | 
| 41 | 41 |  	{ | 
| 42 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Exports orders to CSV file' ); | |
| 42 | +		return $this->getContext()->getI18n()->dt('controller/jobs', 'Exports orders to CSV file'); | |
| 43 | 43 | } | 
| 44 | 44 | |
| 45 | 45 | |
| @@ -73,7 +73,7 @@ discard block | ||
| 73 | 73 | * @category Developer | 
| 74 | 74 | * @see controller/common/order/export/csv/max-size | 
| 75 | 75 | */ | 
| 76 | - $mappings = $config->get( 'controller/common/order/export/csv/mapping', $mappings ); | |
| 76 | +		$mappings = $config->get('controller/common/order/export/csv/mapping', $mappings); | |
| 77 | 77 | |
| 78 | 78 | /** controller/jobs/order/export/csv/mapping | 
| 79 | 79 | * List of mappings between the position in the CSV file and item keys | 
| @@ -88,7 +88,7 @@ discard block | ||
| 88 | 88 | * @category Developer | 
| 89 | 89 | * @see controller/common/order/export/csv/max-size | 
| 90 | 90 | */ | 
| 91 | - $mappings = $config->get( 'controller/jobs/order/export/csv/mapping', $mappings ); | |
| 91 | +		$mappings = $config->get('controller/jobs/order/export/csv/mapping', $mappings); | |
| 92 | 92 | |
| 93 | 93 | |
| 94 | 94 | /** controller/common/order/export/csv/max-size | 
| @@ -106,29 +106,29 @@ discard block | ||
| 106 | 106 | * @category Developer | 
| 107 | 107 | * @see controller/common/order/export/csv/mapping | 
| 108 | 108 | */ | 
| 109 | - $maxcnt = (int) $config->get( 'controller/common/order/export/csv/max-size', 1000 ); | |
| 109 | +		$maxcnt = (int) $config->get('controller/common/order/export/csv/max-size', 1000); | |
| 110 | 110 | |
| 111 | 111 | |
| 112 | - $processors = $this->getProcessors( $mappings ); | |
| 113 | - $mq = $context->getMessageQueueManager()->get( 'mq-admin' )->getQueue( 'order-export' ); | |
| 112 | + $processors = $this->getProcessors($mappings); | |
| 113 | +		$mq = $context->getMessageQueueManager()->get('mq-admin')->getQueue('order-export'); | |
| 114 | 114 | |
| 115 | - while( ( $msg = $mq->get() ) !== null ) | |
| 115 | + while (($msg = $mq->get()) !== null) | |
| 116 | 116 |  		{ | 
| 117 | 117 | try | 
| 118 | 118 |  			{ | 
| 119 | -				if( ( $data = json_decode( $msg->getBody(), true ) ) === null ) { | |
| 120 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid message: %2$s', $msg->getBody() ) ); | |
| 119 | +				if (($data = json_decode($msg->getBody(), true)) === null) { | |
| 120 | +					throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid message: %2$s', $msg->getBody())); | |
| 121 | 121 | } | 
| 122 | 122 | |
| 123 | - $this->export( $processors, $data, $maxcnt ); | |
| 123 | + $this->export($processors, $data, $maxcnt); | |
| 124 | 124 | } | 
| 125 | - catch( \Exception $e ) | |
| 125 | + catch (\Exception $e) | |
| 126 | 126 |  			{ | 
| 127 | - $logger->log( 'Order export error: ' . $e->getMessage() ); | |
| 128 | - $logger->log( $e->getTraceAsString() ); | |
| 127 | +				$logger->log('Order export error: ' . $e->getMessage()); | |
| 128 | + $logger->log($e->getTraceAsString()); | |
| 129 | 129 | } | 
| 130 | 130 | |
| 131 | - $mq->del( $msg ); | |
| 131 | + $mq->del($msg); | |
| 132 | 132 | } | 
| 133 | 133 | } | 
| 134 | 134 | |
| @@ -139,15 +139,15 @@ discard block | ||
| 139 | 139 | * @param \Aimeos\MShop\Context\Item\Iface $context Context item | 
| 140 | 140 | * @param string $path Absolute path to the exported file | 
| 141 | 141 | */ | 
| 142 | - protected function addJob( $context, $path ) | |
| 142 | + protected function addJob($context, $path) | |
| 143 | 143 |  	{ | 
| 144 | - $manager = \Aimeos\MAdmin\Factory::createManager( $context, 'job' ); | |
| 144 | + $manager = \Aimeos\MAdmin\Factory::createManager($context, 'job'); | |
| 145 | 145 | |
| 146 | 146 | $item = $manager->createItem(); | 
| 147 | - $item->setResult( ['file' => $path] ); | |
| 148 | - $item->setLabel( $path ); | |
| 147 | + $item->setResult(['file' => $path]); | |
| 148 | + $item->setLabel($path); | |
| 149 | 149 | |
| 150 | - $manager->saveItem( $item, false ); | |
| 150 | + $manager->saveItem($item, false); | |
| 151 | 151 | } | 
| 152 | 152 | |
| 153 | 153 | |
| @@ -177,7 +177,7 @@ discard block | ||
| 177 | 177 | * @see controller/jobs/order/export/csv/container/content | 
| 178 | 178 | * @see controller/jobs/order/export/csv/container/options | 
| 179 | 179 | */ | 
| 180 | - $location = $config->get( 'controller/jobs/order/export/csv/location', sys_get_temp_dir() ); | |
| 180 | +		$location = $config->get('controller/jobs/order/export/csv/location', sys_get_temp_dir()); | |
| 181 | 181 | |
| 182 | 182 | /** controller/jobs/order/export/csv/container/type | 
| 183 | 183 | * Nave of the container type to read the data from | 
| @@ -200,7 +200,7 @@ discard block | ||
| 200 | 200 | * @see controller/jobs/order/export/csv/container/content | 
| 201 | 201 | * @see controller/jobs/order/export/csv/container/options | 
| 202 | 202 | */ | 
| 203 | - $container = $config->get( 'controller/jobs/order/export/csv/container/type', 'Directory' ); | |
| 203 | +		$container = $config->get('controller/jobs/order/export/csv/container/type', 'Directory'); | |
| 204 | 204 | |
| 205 | 205 | /** controller/jobs/order/export/csv/container/content | 
| 206 | 206 | * Name of the content type inside the container to read the data from | 
| @@ -221,7 +221,7 @@ discard block | ||
| 221 | 221 | * @see controller/jobs/order/export/csv/container/type | 
| 222 | 222 | * @see controller/jobs/order/export/csv/container/options | 
| 223 | 223 | */ | 
| 224 | - $content = $config->get( 'controller/jobs/order/export/csv/container/content', 'CSV' ); | |
| 224 | +		$content = $config->get('controller/jobs/order/export/csv/container/content', 'CSV'); | |
| 225 | 225 | |
| 226 | 226 | /** controller/jobs/order/export/csv/container/options | 
| 227 | 227 | * List of file container options for the order export files | 
| @@ -239,9 +239,9 @@ discard block | ||
| 239 | 239 | * @see controller/jobs/order/export/csv/container/content | 
| 240 | 240 | * @see controller/jobs/order/export/csv/container/type | 
| 241 | 241 | */ | 
| 242 | - $options = $config->get( 'controller/jobs/order/export/csv/container/options', [] ); | |
| 242 | +		$options = $config->get('controller/jobs/order/export/csv/container/options', []); | |
| 243 | 243 | |
| 244 | - return \Aimeos\MW\Container\Factory::getContainer( $location, $container, $content, $options ); | |
| 244 | + return \Aimeos\MW\Container\Factory::getContainer($location, $container, $content, $options); | |
| 245 | 245 | } | 
| 246 | 246 | |
| 247 | 247 | |
| @@ -253,56 +253,56 @@ discard block | ||
| 253 | 253 | * @param integer $maxcnt Maximum number of retrieved orders at once | 
| 254 | 254 | * @return string Path of the file containing the exported data | 
| 255 | 255 | */ | 
| 256 | - protected function export( array $processors, $msg, $maxcnt ) | |
| 256 | + protected function export(array $processors, $msg, $maxcnt) | |
| 257 | 257 |  	{ | 
| 258 | - $lcontext = $this->getLocaleContext( $msg ); | |
| 258 | + $lcontext = $this->getLocaleContext($msg); | |
| 259 | 259 | $baseRef = ['order/base/address', 'order.base.coupon', 'order/base/product', 'order/base/service']; | 
| 260 | 260 | |
| 261 | - $manager = \Aimeos\MShop\Factory::createManager( $lcontext, 'order' ); | |
| 262 | - $baseManager = \Aimeos\MShop\Factory::createManager( $lcontext, 'order/base' ); | |
| 261 | + $manager = \Aimeos\MShop\Factory::createManager($lcontext, 'order'); | |
| 262 | + $baseManager = \Aimeos\MShop\Factory::createManager($lcontext, 'order/base'); | |
| 263 | 263 | |
| 264 | 264 | $container = $this->getContainer(); | 
| 265 | - $content = $container->create( 'order-export_' . date( 'Y-m-d_H-i-s' ) ); | |
| 266 | - $search = $this->initCriteria( $manager->createSearch(), $msg ); | |
| 265 | +		$content = $container->create('order-export_' . date('Y-m-d_H-i-s')); | |
| 266 | + $search = $this->initCriteria($manager->createSearch(), $msg); | |
| 267 | 267 | $start = 0; | 
| 268 | 268 | |
| 269 | 269 | do | 
| 270 | 270 |  		{ | 
| 271 | 271 | $baseIds = []; | 
| 272 | - $search->setSlice( $start, $maxcnt ); | |
| 273 | - $items = $manager->searchItems( $search ); | |
| 272 | + $search->setSlice($start, $maxcnt); | |
| 273 | + $items = $manager->searchItems($search); | |
| 274 | 274 | |
| 275 | -			foreach( $items as $item ) { | |
| 275 | +			foreach ($items as $item) { | |
| 276 | 276 | $baseIds[] = $item->getBaseId(); | 
| 277 | 277 | } | 
| 278 | 278 | |
| 279 | 279 | $baseSearch = $baseManager->createSearch(); | 
| 280 | - $baseSearch->setConditions( $baseSearch->compare( '==', 'order.base.id', $baseIds ) ); | |
| 281 | - $baseSearch->setSlice( 0, count( $baseIds ) ); | |
| 280 | +			$baseSearch->setConditions($baseSearch->compare('==', 'order.base.id', $baseIds)); | |
| 281 | + $baseSearch->setSlice(0, count($baseIds)); | |
| 282 | 282 | |
| 283 | - $baseItems = $baseManager->searchItems( $baseSearch, $baseRef ); | |
| 283 | + $baseItems = $baseManager->searchItems($baseSearch, $baseRef); | |
| 284 | 284 | |
| 285 | - foreach( $items as $id => $item ) | |
| 285 | + foreach ($items as $id => $item) | |
| 286 | 286 |  			{ | 
| 287 | - foreach( $processors as $type => $processor ) | |
| 287 | + foreach ($processors as $type => $processor) | |
| 288 | 288 |  				{ | 
| 289 | -					foreach( $processor->process( $item, $baseItems[$item->getBaseId()] ) as $line ) { | |
| 290 | - $content->add( [0 => $type, 1 => $id] + $line ); | |
| 289 | +					foreach ($processor->process($item, $baseItems[$item->getBaseId()]) as $line) { | |
| 290 | + $content->add([0 => $type, 1 => $id] + $line); | |
| 291 | 291 | } | 
| 292 | 292 | } | 
| 293 | 293 | } | 
| 294 | 294 | |
| 295 | - $count = count( $items ); | |
| 295 | + $count = count($items); | |
| 296 | 296 | $start += $count; | 
| 297 | 297 | } | 
| 298 | - while( $count === $search->getSliceSize() ); | |
| 298 | + while ($count === $search->getSliceSize()); | |
| 299 | 299 | |
| 300 | 300 | $path = $content->getResource(); | 
| 301 | - $container->add( $content ); | |
| 301 | + $container->add($content); | |
| 302 | 302 | $container->close(); | 
| 303 | 303 | |
| 304 | - $path = $this->moveFile( $lcontext, $path ); | |
| 305 | - $this->addJob( $lcontext, $path ); | |
| 304 | + $path = $this->moveFile($lcontext, $path); | |
| 305 | + $this->addJob($lcontext, $path); | |
| 306 | 306 | } | 
| 307 | 307 | |
| 308 | 308 | |
| @@ -312,15 +312,15 @@ discard block | ||
| 312 | 312 | * @param array $msg Message data including a "sitecode" value | 
| 313 | 313 | * @return \Aimeos\MShop\Context\Item\Iface New context item with updated locale | 
| 314 | 314 | */ | 
| 315 | - protected function getLocaleContext( array $msg ) | |
| 315 | + protected function getLocaleContext(array $msg) | |
| 316 | 316 |  	{ | 
| 317 | 317 | $lcontext = clone $this->getContext(); | 
| 318 | - $manager = \Aimeos\MShop\Factory::createManager( $lcontext, 'locale' ); | |
| 318 | + $manager = \Aimeos\MShop\Factory::createManager($lcontext, 'locale'); | |
| 319 | 319 | |
| 320 | - $sitecode = ( isset( $msg['sitecode'] ) ? $msg['sitecode'] : 'default' ); | |
| 321 | - $localeItem = $manager->bootstrap( $sitecode, '', '', false, \Aimeos\MShop\Locale\Manager\Base::SITE_ONE ); | |
| 320 | + $sitecode = (isset($msg['sitecode']) ? $msg['sitecode'] : 'default'); | |
| 321 | + $localeItem = $manager->bootstrap($sitecode, '', '', false, \Aimeos\MShop\Locale\Manager\Base::SITE_ONE); | |
| 322 | 322 | |
| 323 | - return $lcontext->setLocale( $localeItem ); | |
| 323 | + return $lcontext->setLocale($localeItem); | |
| 324 | 324 | } | 
| 325 | 325 | |
| 326 | 326 | |
| @@ -331,14 +331,14 @@ discard block | ||
| 331 | 331 | * @param array $msg Message data | 
| 332 | 332 | * @return \Aimeos\MW\Criteria\Iface Initialized criteria object | 
| 333 | 333 | */ | 
| 334 | - protected function initCriteria( \Aimeos\MW\Criteria\Iface $criteria, array $msg ) | |
| 334 | + protected function initCriteria(\Aimeos\MW\Criteria\Iface $criteria, array $msg) | |
| 335 | 335 |  	{ | 
| 336 | -		if( isset( $msg['filter'] ) ) { | |
| 337 | - $criteria->setConditions( $criteria->toConditions( $msg['filter'] ) ); | |
| 336 | +		if (isset($msg['filter'])) { | |
| 337 | + $criteria->setConditions($criteria->toConditions($msg['filter'])); | |
| 338 | 338 | } | 
| 339 | 339 | |
| 340 | -		if( isset( $msg['sort'] ) ) { | |
| 341 | - $criteria->setSortations( $criteria->toSortations( $msg['sort'] ) ); | |
| 340 | +		if (isset($msg['sort'])) { | |
| 341 | + $criteria->setSortations($criteria->toSortations($msg['sort'])); | |
| 342 | 342 | } | 
| 343 | 343 | |
| 344 | 344 | return $criteria; | 
| @@ -352,12 +352,12 @@ discard block | ||
| 352 | 352 | * @param string $path Absolute path to the exported file | 
| 353 | 353 | * @return string Relative path of the file in the storage | 
| 354 | 354 | */ | 
| 355 | - protected function moveFile( $context, $path ) | |
| 355 | + protected function moveFile($context, $path) | |
| 356 | 356 |  	{ | 
| 357 | - $filename = basename( $path ); | |
| 358 | - $context->getFileSystemManager()->get( 'fs-admin' )->writef( $filename, $path ); | |
| 357 | + $filename = basename($path); | |
| 358 | +		$context->getFileSystemManager()->get('fs-admin')->writef($filename, $path); | |
| 359 | 359 | |
| 360 | - unlink( $path ); | |
| 360 | + unlink($path); | |
| 361 | 361 | return $filename; | 
| 362 | 362 | } | 
| 363 | 363 | } |