@@ -40,21 +40,21 @@ |
||
| 40 | 40 | * @param \Aimeos\MShop\Order\Item\Base\Iface $order Full order with associated items |
| 41 | 41 | * @return array Two dimensional associative list of order data representing the lines in CSV |
| 42 | 42 | */ |
| 43 | - public function process( \Aimeos\MShop\Order\Item\Iface $invoice, \Aimeos\MShop\Order\Item\Base\Iface $order ) |
|
| 43 | + public function process(\Aimeos\MShop\Order\Item\Iface $invoice, \Aimeos\MShop\Order\Item\Base\Iface $order) |
|
| 44 | 44 | { |
| 45 | 45 | $result = []; |
| 46 | 46 | $list = $invoice->toArray() + $order->toArray(); |
| 47 | 47 | |
| 48 | - foreach( $this->getMapping() as $pos => $key ) |
|
| 48 | + foreach ($this->getMapping() as $pos => $key) |
|
| 49 | 49 | { |
| 50 | - if( array_key_exists( $key, $list ) ) { |
|
| 50 | + if (array_key_exists($key, $list)) { |
|
| 51 | 51 | $result[$pos] = $list[$key]; |
| 52 | 52 | } else { |
| 53 | 53 | $result[$pos] = ''; |
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - ksort( $result ); |
|
| 57 | + ksort($result); |
|
| 58 | 58 | |
| 59 | 59 | return [$result]; |
| 60 | 60 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object |
| 26 | 26 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value |
| 27 | 27 | */ |
| 28 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping ); |
|
| 28 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping); |
|
| 29 | 29 | |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -35,5 +35,5 @@ discard block |
||
| 35 | 35 | * @param \Aimeos\MShop\Order\Item\Base\Iface $order Full order with associated items |
| 36 | 36 | * @return array Two dimensional associative list of order data representing the lines in CSV |
| 37 | 37 | */ |
| 38 | - public function process( \Aimeos\MShop\Order\Item\Iface $invoice, \Aimeos\MShop\Order\Item\Base\Iface $order ); |
|
| 38 | + public function process(\Aimeos\MShop\Order\Item\Iface $invoice, \Aimeos\MShop\Order\Item\Base\Iface $order); |
|
| 39 | 39 | } |
| 40 | 40 | \ No newline at end of file |
@@ -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 | } |
@@ -26,17 +26,17 @@ discard block |
||
| 26 | 26 | * @param array $codes List of coupon codes |
| 27 | 27 | * @return array Associative list of coupon codes as key and coupon code items as value |
| 28 | 28 | */ |
| 29 | - protected function getCouponCodeItems( array $codes ) |
|
| 29 | + protected function getCouponCodeItems(array $codes) |
|
| 30 | 30 | { |
| 31 | 31 | $result = []; |
| 32 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon/code' ); |
|
| 32 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon/code'); |
|
| 33 | 33 | |
| 34 | 34 | $search = $manager->createSearch(); |
| 35 | - $search->setConditions( $search->compare( '==', 'coupon.code.code', $codes ) ); |
|
| 36 | - $search->setSlice( 0, count( $codes ) ); |
|
| 35 | + $search->setConditions($search->compare('==', 'coupon.code.code', $codes)); |
|
| 36 | + $search->setSlice(0, count($codes)); |
|
| 37 | 37 | |
| 38 | - foreach( $manager->searchItems( $search ) as $item ) { |
|
| 39 | - $result[ $item->getCode() ] = $item; |
|
| 38 | + foreach ($manager->searchItems($search) as $item) { |
|
| 39 | + $result[$item->getCode()] = $item; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | return $result; |
@@ -51,15 +51,15 @@ discard block |
||
| 51 | 51 | * @param integer $codePos Column position which contains the unique coupon code (starting from 0) |
| 52 | 52 | * @return array List of arrays with coupon codes as keys and list of values from the CSV file |
| 53 | 53 | */ |
| 54 | - protected function getData( \Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos ) |
|
| 54 | + protected function getData(\Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos) |
|
| 55 | 55 | { |
| 56 | 56 | $count = 0; |
| 57 | 57 | $data = []; |
| 58 | 58 | |
| 59 | - while( $content->valid() && $count++ < $maxcnt ) |
|
| 59 | + while ($content->valid() && $count++ < $maxcnt) |
|
| 60 | 60 | { |
| 61 | 61 | $row = $content->current(); |
| 62 | - $data[ $row[$codePos] ] = $row; |
|
| 62 | + $data[$row[$codePos]] = $row; |
|
| 63 | 63 | $content->next(); |
| 64 | 64 | } |
| 65 | 65 | |
@@ -98,21 +98,21 @@ discard block |
||
| 98 | 98 | * @param array $mapping List of domain item keys with the CSV field position as key |
| 99 | 99 | * @return array List of associative arrays containing the chunked properties |
| 100 | 100 | */ |
| 101 | - protected function getMappedChunk( array &$data, array $mapping ) |
|
| 101 | + protected function getMappedChunk(array &$data, array $mapping) |
|
| 102 | 102 | { |
| 103 | 103 | $idx = 0; |
| 104 | 104 | $map = []; |
| 105 | 105 | |
| 106 | - foreach( $mapping as $pos => $key ) |
|
| 106 | + foreach ($mapping as $pos => $key) |
|
| 107 | 107 | { |
| 108 | - if( isset( $map[$idx][$key] ) ) { |
|
| 108 | + if (isset($map[$idx][$key])) { |
|
| 109 | 109 | $idx++; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - if( isset( $data[$pos] ) ) |
|
| 112 | + if (isset($data[$pos])) |
|
| 113 | 113 | { |
| 114 | 114 | $map[$idx][$key] = $data[$pos]; |
| 115 | - unset( $data[$pos] ); |
|
| 115 | + unset($data[$pos]); |
|
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | |
@@ -126,39 +126,39 @@ discard block |
||
| 126 | 126 | * @param array $mappings Associative list of processor types as keys and index/data mappings as values |
| 127 | 127 | * @return \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface Processor object |
| 128 | 128 | */ |
| 129 | - protected function getProcessors( array $mappings ) |
|
| 129 | + protected function getProcessors(array $mappings) |
|
| 130 | 130 | { |
| 131 | 131 | $context = $this->getContext(); |
| 132 | 132 | $config = $context->getConfig(); |
| 133 | 133 | $iface = '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\Iface'; |
| 134 | - $object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Done( $context, [] ); |
|
| 134 | + $object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Done($context, []); |
|
| 135 | 135 | |
| 136 | - foreach( $mappings as $type => $mapping ) |
|
| 136 | + foreach ($mappings as $type => $mapping) |
|
| 137 | 137 | { |
| 138 | - if( ctype_alnum( $type ) === false ) |
|
| 138 | + if (ctype_alnum($type) === false) |
|
| 139 | 139 | { |
| 140 | 140 | $classname = is_string($type) ? '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\' . $type : '<not a string>'; |
| 141 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
| 141 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - $name = $config->get( 'controller/common/coupon/import/csv/processor/' . $type . '/name', 'Standard' ); |
|
| 144 | + $name = $config->get('controller/common/coupon/import/csv/processor/' . $type . '/name', 'Standard'); |
|
| 145 | 145 | |
| 146 | - if( ctype_alnum( $name ) === false ) |
|
| 146 | + if (ctype_alnum($name) === false) |
|
| 147 | 147 | { |
| 148 | 148 | $classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\' . $type . '\\' . $name : '<not a string>'; |
| 149 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
| 149 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - $classname = '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\' . ucfirst( $type ) . '\\' . $name; |
|
| 152 | + $classname = '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\' . ucfirst($type) . '\\' . $name; |
|
| 153 | 153 | |
| 154 | - if( class_exists( $classname ) === false ) { |
|
| 155 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) ); |
|
| 154 | + if (class_exists($classname) === false) { |
|
| 155 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname)); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - $object = new $classname( $context, $mapping, $object ); |
|
| 158 | + $object = new $classname($context, $mapping, $object); |
|
| 159 | 159 | |
| 160 | - if( !( $object instanceof $iface ) ) { |
|
| 161 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" does not implement interface "%2$s"', $classname, $iface ) ); |
|
| 160 | + if (!($object instanceof $iface)) { |
|
| 161 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" does not implement interface "%2$s"', $classname, $iface)); |
|
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | |
@@ -40,21 +40,21 @@ |
||
| 40 | 40 | * @param array $data List of CSV fields with position as key and data as value |
| 41 | 41 | * @return array List of data which hasn't been imported |
| 42 | 42 | */ |
| 43 | - public function process( \Aimeos\MShop\Coupon\Item\Code\Iface $item, array $data ) |
|
| 43 | + public function process(\Aimeos\MShop\Coupon\Item\Code\Iface $item, array $data) |
|
| 44 | 44 | { |
| 45 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon/code' ); |
|
| 46 | - $map = $this->getMappedChunk( $data, $this->getMapping() ); |
|
| 45 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon/code'); |
|
| 46 | + $map = $this->getMappedChunk($data, $this->getMapping()); |
|
| 47 | 47 | |
| 48 | - foreach( $map as $list ) |
|
| 48 | + foreach ($map as $list) |
|
| 49 | 49 | { |
| 50 | - if( $list['coupon.code.code'] == '' ) { |
|
| 50 | + if ($list['coupon.code.code'] == '') { |
|
| 51 | 51 | continue; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - $item->fromArray( $list ); |
|
| 55 | - $manager->saveItem( $item ); |
|
| 54 | + $item->fromArray($list); |
|
| 55 | + $manager->saveItem($item); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - return $this->getObject()->process( $item, $data ); |
|
| 58 | + return $this->getObject()->process($item, $data); |
|
| 59 | 59 | } |
| 60 | 60 | } |
@@ -32,8 +32,8 @@ discard block |
||
| 32 | 32 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value |
| 33 | 33 | * @param \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface $object Decorated processor |
| 34 | 34 | */ |
| 35 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
| 36 | - \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface $object = null ) |
|
| 35 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
| 36 | + \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface $object = null) |
|
| 37 | 37 | { |
| 38 | 38 | $this->context = $context; |
| 39 | 39 | $this->mapping = $mapping; |
@@ -71,8 +71,8 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | protected function getObject() |
| 73 | 73 | { |
| 74 | - if( $this->object === null ) { |
|
| 75 | - throw new \Aimeos\Controller\Jobs\Exception( 'No processor object available' ); |
|
| 74 | + if ($this->object === null) { |
|
| 75 | + throw new \Aimeos\Controller\Jobs\Exception('No processor object available'); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | return $this->object; |
@@ -27,8 +27,8 @@ discard block |
||
| 27 | 27 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value |
| 28 | 28 | * @param \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface $object Decorated processor |
| 29 | 29 | */ |
| 30 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
| 31 | - \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface $object = null ) |
|
| 30 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
| 31 | + \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface $object = null) |
|
| 32 | 32 | { |
| 33 | 33 | } |
| 34 | 34 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * @param array $data List of CSV fields with position as key and data as value |
| 41 | 41 | * @return array List of data which hasn't been imported |
| 42 | 42 | */ |
| 43 | - public function process( \Aimeos\MShop\Coupon\Item\Code\Iface $item, array $data ) |
|
| 43 | + public function process(\Aimeos\MShop\Coupon\Item\Code\Iface $item, array $data) |
|
| 44 | 44 | { |
| 45 | 45 | return $data; |
| 46 | 46 | } |
@@ -26,8 +26,8 @@ discard block |
||
| 26 | 26 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value |
| 27 | 27 | * @param \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface $object Decorated processor |
| 28 | 28 | */ |
| 29 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
| 30 | - \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface $object = null ); |
|
| 29 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
| 30 | + \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface $object = null); |
|
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -37,5 +37,5 @@ discard block |
||
| 37 | 37 | * @param array $data List of CSV fields with position as key and data as value |
| 38 | 38 | * @return array List of data which hasn't been imported |
| 39 | 39 | */ |
| 40 | - public function process( \Aimeos\MShop\Coupon\Item\Code\Iface $item, array $data ); |
|
| 40 | + public function process(\Aimeos\MShop\Coupon\Item\Code\Iface $item, array $data); |
|
| 41 | 41 | } |
| 42 | 42 | \ No newline at end of file |
@@ -17,16 +17,16 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | protected function setUp() |
| 19 | 19 | { |
| 20 | - \Aimeos\MShop\Factory::setCache( true ); |
|
| 20 | + \Aimeos\MShop\Factory::setCache(true); |
|
| 21 | 21 | |
| 22 | 22 | $this->context = \TestHelperCntl::getContext(); |
| 23 | - $this->endpoint = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Done( $this->context, [] ); |
|
| 23 | + $this->endpoint = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Done($this->context, []); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | |
| 27 | 27 | protected function tearDown() |
| 28 | 28 | { |
| 29 | - \Aimeos\MShop\Factory::setCache( false ); |
|
| 29 | + \Aimeos\MShop\Factory::setCache(false); |
|
| 30 | 30 | \Aimeos\MShop\Factory::clear(); |
| 31 | 31 | } |
| 32 | 32 | |
@@ -47,24 +47,24 @@ discard block |
||
| 47 | 47 | 3 => '', |
| 48 | 48 | ); |
| 49 | 49 | |
| 50 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'coupon' ); |
|
| 51 | - $codeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'coupon/code' ); |
|
| 50 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'coupon'); |
|
| 51 | + $codeManager = \Aimeos\MShop\Factory::createManager($this->context, 'coupon/code'); |
|
| 52 | 52 | |
| 53 | - $coupon = $manager->saveItem( $manager->createItem()->setProvider( 'test' ) ); |
|
| 53 | + $coupon = $manager->saveItem($manager->createItem()->setProvider('test')); |
|
| 54 | 54 | $couponCode = $codeManager->createItem(); |
| 55 | - $couponCode->setParentId( $coupon->getId() ); |
|
| 55 | + $couponCode->setParentId($coupon->getId()); |
|
| 56 | 56 | |
| 57 | - $object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Code\Standard( $this->context, $mapping, $this->endpoint ); |
|
| 58 | - $object->process( $couponCode, $data ); |
|
| 57 | + $object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Code\Standard($this->context, $mapping, $this->endpoint); |
|
| 58 | + $object->process($couponCode, $data); |
|
| 59 | 59 | |
| 60 | - $codeManager->deleteItem( $couponCode->getId() ); |
|
| 61 | - $manager->deleteItem( $coupon->getId() ); |
|
| 60 | + $codeManager->deleteItem($couponCode->getId()); |
|
| 61 | + $manager->deleteItem($coupon->getId()); |
|
| 62 | 62 | |
| 63 | 63 | |
| 64 | - $this->assertEquals( 10, $couponCode->getCount() ); |
|
| 65 | - $this->assertEquals( 'jobimporttest', $couponCode->getCode() ); |
|
| 66 | - $this->assertEquals( '2000-01-01 00:00:00', $couponCode->getDateStart() ); |
|
| 67 | - $this->assertEquals( null, $couponCode->getDateEnd() ); |
|
| 64 | + $this->assertEquals(10, $couponCode->getCount()); |
|
| 65 | + $this->assertEquals('jobimporttest', $couponCode->getCode()); |
|
| 66 | + $this->assertEquals('2000-01-01 00:00:00', $couponCode->getDateStart()); |
|
| 67 | + $this->assertEquals(null, $couponCode->getDateEnd()); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | |
@@ -86,23 +86,23 @@ discard block |
||
| 86 | 86 | ); |
| 87 | 87 | |
| 88 | 88 | |
| 89 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'coupon' ); |
|
| 90 | - $codeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'coupon/code' ); |
|
| 89 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'coupon'); |
|
| 90 | + $codeManager = \Aimeos\MShop\Factory::createManager($this->context, 'coupon/code'); |
|
| 91 | 91 | |
| 92 | - $coupon = $manager->saveItem( $manager->createItem()->setProvider( 'test' ) ); |
|
| 92 | + $coupon = $manager->saveItem($manager->createItem()->setProvider('test')); |
|
| 93 | 93 | $couponCode = $codeManager->createItem(); |
| 94 | - $couponCode->setParentId( $coupon->getId() ); |
|
| 94 | + $couponCode->setParentId($coupon->getId()); |
|
| 95 | 95 | |
| 96 | - $object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Code\Standard( $this->context, $mapping, $this->endpoint ); |
|
| 97 | - $object->process( $couponCode, $data ); |
|
| 98 | - $object->process( $couponCode, $dataUpdate ); |
|
| 96 | + $object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Code\Standard($this->context, $mapping, $this->endpoint); |
|
| 97 | + $object->process($couponCode, $data); |
|
| 98 | + $object->process($couponCode, $dataUpdate); |
|
| 99 | 99 | |
| 100 | - $codeManager->deleteItem( $couponCode->getId() ); |
|
| 101 | - $manager->deleteItem( $coupon->getId() ); |
|
| 100 | + $codeManager->deleteItem($couponCode->getId()); |
|
| 101 | + $manager->deleteItem($coupon->getId()); |
|
| 102 | 102 | |
| 103 | 103 | |
| 104 | - $this->assertEquals( 5, $couponCode->getCount() ); |
|
| 105 | - $this->assertEquals( 'jobimporttest', $couponCode->getCode() ); |
|
| 104 | + $this->assertEquals(5, $couponCode->getCount()); |
|
| 105 | + $this->assertEquals('jobimporttest', $couponCode->getCode()); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | |
@@ -119,20 +119,20 @@ discard block |
||
| 119 | 119 | ); |
| 120 | 120 | |
| 121 | 121 | |
| 122 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'coupon' ); |
|
| 123 | - $codeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'coupon/code' ); |
|
| 122 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'coupon'); |
|
| 123 | + $codeManager = \Aimeos\MShop\Factory::createManager($this->context, 'coupon/code'); |
|
| 124 | 124 | |
| 125 | - $coupon = $manager->saveItem( $manager->createItem()->setProvider( 'test' ) ); |
|
| 125 | + $coupon = $manager->saveItem($manager->createItem()->setProvider('test')); |
|
| 126 | 126 | $couponCode = $codeManager->createItem(); |
| 127 | - $couponCode->setParentId( $coupon->getId() ); |
|
| 127 | + $couponCode->setParentId($coupon->getId()); |
|
| 128 | 128 | |
| 129 | - $object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Code\Standard( $this->context, $mapping, $this->endpoint ); |
|
| 130 | - $object->process( $couponCode, $data ); |
|
| 129 | + $object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Code\Standard($this->context, $mapping, $this->endpoint); |
|
| 130 | + $object->process($couponCode, $data); |
|
| 131 | 131 | |
| 132 | - $codeManager->deleteItem( $couponCode->getId() ); |
|
| 133 | - $manager->deleteItem( $coupon->getId() ); |
|
| 132 | + $codeManager->deleteItem($couponCode->getId()); |
|
| 133 | + $manager->deleteItem($coupon->getId()); |
|
| 134 | 134 | |
| 135 | 135 | |
| 136 | - $this->assertEquals( 0, $couponCode->getCount() ); |
|
| 136 | + $this->assertEquals(0, $couponCode->getCount()); |
|
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | \ No newline at end of file |