@@ -40,17 +40,17 @@ |
||
| 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 | |
| 47 | - foreach( $order->getCoupons() as $code => $products ) |
|
| 47 | + foreach ($order->getCoupons() as $code => $products) |
|
| 48 | 48 | { |
| 49 | 49 | $data = []; |
| 50 | 50 | |
| 51 | - foreach( $this->getMapping() as $pos => $key ) |
|
| 51 | + foreach ($this->getMapping() as $pos => $key) |
|
| 52 | 52 | { |
| 53 | - if( $key === 'order.base.coupon.code' ) { |
|
| 53 | + if ($key === 'order.base.coupon.code') { |
|
| 54 | 54 | $data[$pos] = $code; |
| 55 | 55 | } else { |
| 56 | 56 | $data[$pos] = ''; |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object |
| 30 | 30 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value |
| 31 | 31 | */ |
| 32 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping ) |
|
| 32 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping) |
|
| 33 | 33 | { |
| 34 | 34 | $this->context = $context; |
| 35 | 35 | $this->mapping = $mapping; |
@@ -40,28 +40,28 @@ |
||
| 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 | $addresses = $order->getAddresses(); |
| 47 | 47 | |
| 48 | - krsort( $addresses ); |
|
| 48 | + krsort($addresses); |
|
| 49 | 49 | |
| 50 | - foreach( $addresses as $item ) |
|
| 50 | + foreach ($addresses as $item) |
|
| 51 | 51 | { |
| 52 | 52 | $data = []; |
| 53 | 53 | $list = $item->toArray(); |
| 54 | 54 | |
| 55 | - foreach( $this->getMapping() as $pos => $key ) |
|
| 55 | + foreach ($this->getMapping() as $pos => $key) |
|
| 56 | 56 | { |
| 57 | - if( array_key_exists( $key, $list ) ) { |
|
| 57 | + if (array_key_exists($key, $list)) { |
|
| 58 | 58 | $data[$pos] = $list[$key]; |
| 59 | 59 | } else { |
| 60 | 60 | $data[$pos] = ''; |
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - ksort( $data ); |
|
| 64 | + ksort($data); |
|
| 65 | 65 | $result[] = $data; |
| 66 | 66 | } |
| 67 | 67 | |
@@ -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 |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | * Initializes the object |
| 30 | 30 | * |
| 31 | 31 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object |
| 32 | - * @param array $mapping Associative list of field position in CSV as key and domain item key as value |
|
| 32 | + * @param string[] $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 | 35 | public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
@@ -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; |
@@ -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 | } |
@@ -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 | } |