@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value |
43 | 43 | * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor |
44 | 44 | */ |
45 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
46 | - \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null ) |
|
45 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
46 | + \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null) |
|
47 | 47 | { |
48 | - parent::__construct( $context, $mapping, $object ); |
|
48 | + parent::__construct($context, $mapping, $object); |
|
49 | 49 | |
50 | 50 | /** controller/common/product/import/csv/processor/text/listtypes |
51 | 51 | * Names of the product list types for texts that are updated or removed |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @see controller/common/product/import/csv/processor/price/listtypes |
67 | 67 | * @see controller/common/product/import/csv/processor/product/listtypes |
68 | 68 | */ |
69 | - $this->listTypes = $context->getConfig()->get( 'controller/common/product/import/csv/processor/text/listtypes' ); |
|
69 | + $this->listTypes = $context->getConfig()->get('controller/common/product/import/csv/processor/text/listtypes'); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | |
@@ -77,40 +77,40 @@ discard block |
||
77 | 77 | * @param array $data List of CSV fields with position as key and data as value |
78 | 78 | * @return array List of data which hasn't been imported |
79 | 79 | */ |
80 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
80 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
81 | 81 | { |
82 | - $listManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists' ); |
|
83 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'text' ); |
|
82 | + $listManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists'); |
|
83 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'text'); |
|
84 | 84 | $manager->begin(); |
85 | 85 | |
86 | 86 | try |
87 | 87 | { |
88 | 88 | $delete = $listMap = []; |
89 | - $map = $this->getMappedChunk( $data, $this->getMapping() ); |
|
90 | - $listItems = $product->getListItems( 'text', $this->listTypes ); |
|
89 | + $map = $this->getMappedChunk($data, $this->getMapping()); |
|
90 | + $listItems = $product->getListItems('text', $this->listTypes); |
|
91 | 91 | |
92 | - foreach( $listItems as $listItem ) |
|
92 | + foreach ($listItems as $listItem) |
|
93 | 93 | { |
94 | - if( ( $refItem = $listItem->getRefItem() ) !== null ) { |
|
95 | - $listMap[ $refItem->getContent() ][ $refItem->getType() ][ $listItem->getType() ] = $listItem; |
|
94 | + if (($refItem = $listItem->getRefItem()) !== null) { |
|
95 | + $listMap[$refItem->getContent()][$refItem->getType()][$listItem->getType()] = $listItem; |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
99 | - foreach( $map as $pos => $list ) |
|
99 | + foreach ($map as $pos => $list) |
|
100 | 100 | { |
101 | - if( $this->checkEntry( $list ) === false ) { |
|
101 | + if ($this->checkEntry($list) === false) { |
|
102 | 102 | continue; |
103 | 103 | } |
104 | 104 | |
105 | - $content = trim( $list['text.content'] ); |
|
106 | - $type = trim( isset( $list['text.type'] ) ? $list['text.type'] : 'name' ); |
|
107 | - $typecode = trim( isset( $list['product.lists.type'] ) ? $list['product.lists.type'] : 'default' ); |
|
105 | + $content = trim($list['text.content']); |
|
106 | + $type = trim(isset($list['text.type']) ? $list['text.type'] : 'name'); |
|
107 | + $typecode = trim(isset($list['product.lists.type']) ? $list['product.lists.type'] : 'default'); |
|
108 | 108 | |
109 | - if( isset( $listMap[$content][$type][$typecode] ) ) |
|
109 | + if (isset($listMap[$content][$type][$typecode])) |
|
110 | 110 | { |
111 | 111 | $listItem = $listMap[$content][$type][$typecode]; |
112 | 112 | $refItem = $listItem->getRefItem(); |
113 | - unset( $listItems[ $listItem->getId() ] ); |
|
113 | + unset($listItems[$listItem->getId()]); |
|
114 | 114 | } |
115 | 115 | else |
116 | 116 | { |
@@ -118,33 +118,33 @@ discard block |
||
118 | 118 | $refItem = $manager->createItem(); |
119 | 119 | } |
120 | 120 | |
121 | - $list['text.typeid'] = $this->getTypeId( 'text/type', 'product', $type ); |
|
121 | + $list['text.typeid'] = $this->getTypeId('text/type', 'product', $type); |
|
122 | 122 | $list['text.domain'] = 'product'; |
123 | 123 | |
124 | - $refItem->fromArray( $this->addItemDefaults( $list ) ); |
|
125 | - $refItem = $manager->saveItem( $refItem ); |
|
124 | + $refItem->fromArray($this->addItemDefaults($list)); |
|
125 | + $refItem = $manager->saveItem($refItem); |
|
126 | 126 | |
127 | - $list['product.lists.typeid'] = $this->getTypeId( 'product/lists/type', 'text', $typecode ); |
|
127 | + $list['product.lists.typeid'] = $this->getTypeId('product/lists/type', 'text', $typecode); |
|
128 | 128 | $list['product.lists.parentid'] = $product->getId(); |
129 | 129 | $list['product.lists.refid'] = $refItem->getId(); |
130 | 130 | $list['product.lists.domain'] = 'text'; |
131 | 131 | |
132 | - $listItem->fromArray( $this->addListItemDefaults( $list, $pos ) ); |
|
133 | - $listManager->saveItem( $listItem, false ); |
|
132 | + $listItem->fromArray($this->addListItemDefaults($list, $pos)); |
|
133 | + $listManager->saveItem($listItem, false); |
|
134 | 134 | } |
135 | 135 | |
136 | - foreach( $listItems as $listItem ) { |
|
136 | + foreach ($listItems as $listItem) { |
|
137 | 137 | $delete[] = $listItem->getRefId(); |
138 | 138 | } |
139 | 139 | |
140 | - $manager->deleteItems( $delete ); |
|
141 | - $listManager->deleteItems( array_keys( $listItems ) ); |
|
140 | + $manager->deleteItems($delete); |
|
141 | + $listManager->deleteItems(array_keys($listItems)); |
|
142 | 142 | |
143 | - $data = $this->getObject()->process( $product, $data ); |
|
143 | + $data = $this->getObject()->process($product, $data); |
|
144 | 144 | |
145 | 145 | $manager->commit(); |
146 | 146 | } |
147 | - catch( \Exception $e ) |
|
147 | + catch (\Exception $e) |
|
148 | 148 | { |
149 | 149 | $manager->rollback(); |
150 | 150 | throw $e; |
@@ -160,13 +160,13 @@ discard block |
||
160 | 160 | * @param array $list Associative list of domain item keys and their values, e.g. "text.status" => 1 |
161 | 161 | * @return array Given associative list enriched by default values if they were not already set |
162 | 162 | */ |
163 | - protected function addItemDefaults( array $list ) |
|
163 | + protected function addItemDefaults(array $list) |
|
164 | 164 | { |
165 | - if( !isset( $list['text.label'] ) ) { |
|
166 | - $list['text.label'] = mb_strcut( trim( $list['text.content'] ), 0, 255 ); |
|
165 | + if (!isset($list['text.label'])) { |
|
166 | + $list['text.label'] = mb_strcut(trim($list['text.content']), 0, 255); |
|
167 | 167 | } |
168 | 168 | |
169 | - if( !isset( $list['text.status'] ) ) { |
|
169 | + if (!isset($list['text.status'])) { |
|
170 | 170 | $list['text.status'] = 1; |
171 | 171 | } |
172 | 172 | |
@@ -180,10 +180,10 @@ discard block |
||
180 | 180 | * @param array $list Associative list of key/value pairs from the mapping |
181 | 181 | * @return boolean True if valid, false if not |
182 | 182 | */ |
183 | - protected function checkEntry( array $list ) |
|
183 | + protected function checkEntry(array $list) |
|
184 | 184 | { |
185 | - if( !isset( $list['text.content'] ) || trim( $list['text.content'] ) === '' || isset( $list['product.lists.type'] ) |
|
186 | - && $this->listTypes !== null && !in_array( trim( $list['product.lists.type'] ), (array) $this->listTypes ) |
|
185 | + if (!isset($list['text.content']) || trim($list['text.content']) === '' || isset($list['product.lists.type']) |
|
186 | + && $this->listTypes !== null && !in_array(trim($list['product.lists.type']), (array) $this->listTypes) |
|
187 | 187 | ) { |
188 | 188 | return false; |
189 | 189 | } |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value |
43 | 43 | * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor |
44 | 44 | */ |
45 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
46 | - \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null ) |
|
45 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
46 | + \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null) |
|
47 | 47 | { |
48 | - parent::__construct( $context, $mapping, $object ); |
|
48 | + parent::__construct($context, $mapping, $object); |
|
49 | 49 | |
50 | 50 | /** controller/common/product/import/csv/processor/price/listtypes |
51 | 51 | * Names of the product list types for prices that are updated or removed |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @see controller/common/product/import/csv/processor/product/listtypes |
67 | 67 | * @see controller/common/product/import/csv/processor/text/listtypes |
68 | 68 | */ |
69 | - $this->listTypes = $context->getConfig()->get( 'controller/common/product/import/csv/processor/price/listtypes' ); |
|
69 | + $this->listTypes = $context->getConfig()->get('controller/common/product/import/csv/processor/price/listtypes'); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | |
@@ -77,40 +77,40 @@ discard block |
||
77 | 77 | * @param array $data List of CSV fields with position as key and data as value |
78 | 78 | * @return array List of data which hasn't been imported |
79 | 79 | */ |
80 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
80 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
81 | 81 | { |
82 | - $listManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists' ); |
|
83 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'price' ); |
|
82 | + $listManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists'); |
|
83 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'price'); |
|
84 | 84 | $manager->begin(); |
85 | 85 | |
86 | 86 | try |
87 | 87 | { |
88 | 88 | $delete = $listMap = []; |
89 | - $map = $this->getMappedChunk( $data, $this->getMapping() ); |
|
90 | - $listItems = $product->getListItems( 'price', $this->listTypes ); |
|
89 | + $map = $this->getMappedChunk($data, $this->getMapping()); |
|
90 | + $listItems = $product->getListItems('price', $this->listTypes); |
|
91 | 91 | |
92 | - foreach( $listItems as $listItem ) |
|
92 | + foreach ($listItems as $listItem) |
|
93 | 93 | { |
94 | - if( ( $refItem = $listItem->getRefItem() ) !== null ) { |
|
95 | - $listMap[ $refItem->getValue() ][ $refItem->getType() ][ $listItem->getType() ] = $listItem; |
|
94 | + if (($refItem = $listItem->getRefItem()) !== null) { |
|
95 | + $listMap[$refItem->getValue()][$refItem->getType()][$listItem->getType()] = $listItem; |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
99 | - foreach( $map as $pos => $list ) |
|
99 | + foreach ($map as $pos => $list) |
|
100 | 100 | { |
101 | - if( $this->checkEntry( $list ) === false ) { |
|
101 | + if ($this->checkEntry($list) === false) { |
|
102 | 102 | continue; |
103 | 103 | } |
104 | 104 | |
105 | - $value = trim( isset( $list['price.value'] ) ? $list['price.value'] : '0.00' ); |
|
106 | - $type = trim( isset( $list['price.type'] ) ? $list['price.type'] : 'default' ); |
|
107 | - $typecode = trim( isset( $list['product.lists.type'] ) ? $list['product.lists.type'] : 'default' ); |
|
105 | + $value = trim(isset($list['price.value']) ? $list['price.value'] : '0.00'); |
|
106 | + $type = trim(isset($list['price.type']) ? $list['price.type'] : 'default'); |
|
107 | + $typecode = trim(isset($list['product.lists.type']) ? $list['product.lists.type'] : 'default'); |
|
108 | 108 | |
109 | - if( isset( $listMap[$value][$type][$typecode] ) ) |
|
109 | + if (isset($listMap[$value][$type][$typecode])) |
|
110 | 110 | { |
111 | 111 | $listItem = $listMap[$value][$type][$typecode]; |
112 | 112 | $refItem = $listItem->getRefItem(); |
113 | - unset( $listItems[ $listItem->getId() ] ); |
|
113 | + unset($listItems[$listItem->getId()]); |
|
114 | 114 | } |
115 | 115 | else |
116 | 116 | { |
@@ -118,33 +118,33 @@ discard block |
||
118 | 118 | $refItem = $manager->createItem(); |
119 | 119 | } |
120 | 120 | |
121 | - $list['price.typeid'] = $this->getTypeId( 'price/type', 'product', $type ); |
|
121 | + $list['price.typeid'] = $this->getTypeId('price/type', 'product', $type); |
|
122 | 122 | $list['price.domain'] = 'product'; |
123 | 123 | |
124 | - $refItem->fromArray( $this->addItemDefaults( $list ) ); |
|
125 | - $refItem = $manager->saveItem( $refItem ); |
|
124 | + $refItem->fromArray($this->addItemDefaults($list)); |
|
125 | + $refItem = $manager->saveItem($refItem); |
|
126 | 126 | |
127 | - $list['product.lists.typeid'] = $this->getTypeId( 'product/lists/type', 'price', $typecode ); |
|
127 | + $list['product.lists.typeid'] = $this->getTypeId('product/lists/type', 'price', $typecode); |
|
128 | 128 | $list['product.lists.parentid'] = $product->getId(); |
129 | 129 | $list['product.lists.refid'] = $refItem->getId(); |
130 | 130 | $list['product.lists.domain'] = 'price'; |
131 | 131 | |
132 | - $listItem->fromArray( $this->addListItemDefaults( $list, $pos ) ); |
|
133 | - $listManager->saveItem( $listItem, false ); |
|
132 | + $listItem->fromArray($this->addListItemDefaults($list, $pos)); |
|
133 | + $listManager->saveItem($listItem, false); |
|
134 | 134 | } |
135 | 135 | |
136 | - foreach( $listItems as $listItem ) { |
|
136 | + foreach ($listItems as $listItem) { |
|
137 | 137 | $delete[] = $listItem->getRefId(); |
138 | 138 | } |
139 | 139 | |
140 | - $manager->deleteItems( $delete ); |
|
141 | - $listManager->deleteItems( array_keys( $listItems ) ); |
|
140 | + $manager->deleteItems($delete); |
|
141 | + $listManager->deleteItems(array_keys($listItems)); |
|
142 | 142 | |
143 | - $data = $this->getObject()->process( $product, $data ); |
|
143 | + $data = $this->getObject()->process($product, $data); |
|
144 | 144 | |
145 | 145 | $manager->commit(); |
146 | 146 | } |
147 | - catch( \Exception $e ) |
|
147 | + catch (\Exception $e) |
|
148 | 148 | { |
149 | 149 | $manager->rollback(); |
150 | 150 | throw $e; |
@@ -160,13 +160,13 @@ discard block |
||
160 | 160 | * @param array $list Associative list of domain item keys and their values, e.g. "price.status" => 1 |
161 | 161 | * @return array Given associative list enriched by default values if they were not already set |
162 | 162 | */ |
163 | - protected function addItemDefaults( array $list ) |
|
163 | + protected function addItemDefaults(array $list) |
|
164 | 164 | { |
165 | - if( !isset( $list['price.label'] ) ) { |
|
165 | + if (!isset($list['price.label'])) { |
|
166 | 166 | $list['price.label'] = $list['price.currencyid'] . ' ' . $list['price.value']; |
167 | 167 | } |
168 | 168 | |
169 | - if( !isset( $list['price.status'] ) ) { |
|
169 | + if (!isset($list['price.status'])) { |
|
170 | 170 | $list['price.status'] = 1; |
171 | 171 | } |
172 | 172 | |
@@ -180,10 +180,10 @@ discard block |
||
180 | 180 | * @param array $list Associative list of key/value pairs from the mapping |
181 | 181 | * @return boolean True if valid, false if not |
182 | 182 | */ |
183 | - protected function checkEntry( array $list ) |
|
183 | + protected function checkEntry(array $list) |
|
184 | 184 | { |
185 | - if( !isset( $list['price.value'] ) || trim( $list['price.value'] ) === '' || isset( $list['product.lists.type'] ) |
|
186 | - && $this->listTypes !== null && !in_array( trim( $list['product.lists.type'] ), (array) $this->listTypes ) |
|
185 | + if (!isset($list['price.value']) || trim($list['price.value']) === '' || isset($list['product.lists.type']) |
|
186 | + && $this->listTypes !== null && !in_array(trim($list['product.lists.type']), (array) $this->listTypes) |
|
187 | 187 | ) { |
188 | 188 | return false; |
189 | 189 | } |
@@ -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\Product\Import\Csv\Processor\Done( $this->context, [] ); |
|
23 | + $this->endpoint = new \Aimeos\Controller\Common\Product\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 | |
@@ -57,38 +57,38 @@ discard block |
||
57 | 57 | 8 => 1, |
58 | 58 | ); |
59 | 59 | |
60 | - $product = $this->create( 'job_csv_test' ); |
|
60 | + $product = $this->create('job_csv_test'); |
|
61 | 61 | |
62 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard( $this->context, $mapping, $this->endpoint ); |
|
63 | - $object->process( $product, $data ); |
|
62 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard($this->context, $mapping, $this->endpoint); |
|
63 | + $object->process($product, $data); |
|
64 | 64 | |
65 | - $product = $this->get( 'job_csv_test' ); |
|
66 | - $this->delete( $product ); |
|
65 | + $product = $this->get('job_csv_test'); |
|
66 | + $this->delete($product); |
|
67 | 67 | |
68 | 68 | |
69 | 69 | $listItems = $product->getListItems(); |
70 | - $listItem = reset( $listItems ); |
|
70 | + $listItem = reset($listItems); |
|
71 | 71 | |
72 | - $this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem ); |
|
73 | - $this->assertEquals( 1, count( $listItems ) ); |
|
72 | + $this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem); |
|
73 | + $this->assertEquals(1, count($listItems)); |
|
74 | 74 | |
75 | - $this->assertEquals( 1, $listItem->getStatus() ); |
|
76 | - $this->assertEquals( 0, $listItem->getPosition() ); |
|
77 | - $this->assertEquals( 'price', $listItem->getDomain() ); |
|
78 | - $this->assertEquals( 'default', $listItem->getType() ); |
|
75 | + $this->assertEquals(1, $listItem->getStatus()); |
|
76 | + $this->assertEquals(0, $listItem->getPosition()); |
|
77 | + $this->assertEquals('price', $listItem->getDomain()); |
|
78 | + $this->assertEquals('default', $listItem->getType()); |
|
79 | 79 | |
80 | 80 | $refItem = $listItem->getRefItem(); |
81 | 81 | |
82 | - $this->assertEquals( 1, $refItem->getStatus() ); |
|
83 | - $this->assertEquals( 'default', $refItem->getType() ); |
|
84 | - $this->assertEquals( 'product', $refItem->getDomain() ); |
|
85 | - $this->assertEquals( 'EUR 1.00', $refItem->getLabel() ); |
|
86 | - $this->assertEquals( 5, $refItem->getQuantity() ); |
|
87 | - $this->assertEquals( '1.00', $refItem->getValue() ); |
|
88 | - $this->assertEquals( '0.20', $refItem->getCosts() ); |
|
89 | - $this->assertEquals( '0.10', $refItem->getRebate() ); |
|
90 | - $this->assertEquals( '20.00', $refItem->getTaxrate() ); |
|
91 | - $this->assertEquals( 1, $refItem->getStatus() ); |
|
82 | + $this->assertEquals(1, $refItem->getStatus()); |
|
83 | + $this->assertEquals('default', $refItem->getType()); |
|
84 | + $this->assertEquals('product', $refItem->getDomain()); |
|
85 | + $this->assertEquals('EUR 1.00', $refItem->getLabel()); |
|
86 | + $this->assertEquals(5, $refItem->getQuantity()); |
|
87 | + $this->assertEquals('1.00', $refItem->getValue()); |
|
88 | + $this->assertEquals('0.20', $refItem->getCosts()); |
|
89 | + $this->assertEquals('0.10', $refItem->getRebate()); |
|
90 | + $this->assertEquals('20.00', $refItem->getTaxrate()); |
|
91 | + $this->assertEquals(1, $refItem->getStatus()); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
@@ -116,24 +116,24 @@ discard block |
||
116 | 116 | 7 => '4.00', |
117 | 117 | ); |
118 | 118 | |
119 | - $product = $this->create( 'job_csv_test' ); |
|
119 | + $product = $this->create('job_csv_test'); |
|
120 | 120 | |
121 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard( $this->context, $mapping, $this->endpoint ); |
|
122 | - $object->process( $product, $data ); |
|
121 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard($this->context, $mapping, $this->endpoint); |
|
122 | + $object->process($product, $data); |
|
123 | 123 | |
124 | - $product = $this->get( 'job_csv_test' ); |
|
125 | - $this->delete( $product ); |
|
124 | + $product = $this->get('job_csv_test'); |
|
125 | + $this->delete($product); |
|
126 | 126 | |
127 | 127 | |
128 | 128 | $pos = 0; |
129 | 129 | $listItems = $product->getListItems(); |
130 | 130 | |
131 | - $this->assertEquals( 4, count( $listItems ) ); |
|
131 | + $this->assertEquals(4, count($listItems)); |
|
132 | 132 | |
133 | - foreach( $listItems as $listItem ) |
|
133 | + foreach ($listItems as $listItem) |
|
134 | 134 | { |
135 | - $this->assertEquals( $data[$pos++], $listItem->getRefItem()->getCurrencyId() ); |
|
136 | - $this->assertEquals( $data[$pos++], $listItem->getRefItem()->getValue() ); |
|
135 | + $this->assertEquals($data[$pos++], $listItem->getRefItem()->getCurrencyId()); |
|
136 | + $this->assertEquals($data[$pos++], $listItem->getRefItem()->getValue()); |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
@@ -155,26 +155,26 @@ discard block |
||
155 | 155 | 1 => '2.00', |
156 | 156 | ); |
157 | 157 | |
158 | - $product = $this->create( 'job_csv_test' ); |
|
158 | + $product = $this->create('job_csv_test'); |
|
159 | 159 | |
160 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard( $this->context, $mapping, $this->endpoint ); |
|
161 | - $object->process( $product, $data ); |
|
160 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard($this->context, $mapping, $this->endpoint); |
|
161 | + $object->process($product, $data); |
|
162 | 162 | |
163 | - $product = $this->get( 'job_csv_test' ); |
|
163 | + $product = $this->get('job_csv_test'); |
|
164 | 164 | |
165 | - $object->process( $product, $dataUpdate ); |
|
165 | + $object->process($product, $dataUpdate); |
|
166 | 166 | |
167 | - $product = $this->get( 'job_csv_test' ); |
|
168 | - $this->delete( $product ); |
|
167 | + $product = $this->get('job_csv_test'); |
|
168 | + $this->delete($product); |
|
169 | 169 | |
170 | 170 | |
171 | 171 | $listItems = $product->getListItems(); |
172 | - $listItem = reset( $listItems ); |
|
172 | + $listItem = reset($listItems); |
|
173 | 173 | |
174 | - $this->assertEquals( 1, count( $listItems ) ); |
|
175 | - $this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem ); |
|
174 | + $this->assertEquals(1, count($listItems)); |
|
175 | + $this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem); |
|
176 | 176 | |
177 | - $this->assertEquals( '2.00', $listItem->getRefItem()->getValue() ); |
|
177 | + $this->assertEquals('2.00', $listItem->getRefItem()->getValue()); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | |
@@ -190,23 +190,23 @@ discard block |
||
190 | 190 | 1 => '1.00', |
191 | 191 | ); |
192 | 192 | |
193 | - $product = $this->create( 'job_csv_test' ); |
|
193 | + $product = $this->create('job_csv_test'); |
|
194 | 194 | |
195 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard( $this->context, $mapping, $this->endpoint ); |
|
196 | - $object->process( $product, $data ); |
|
195 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard($this->context, $mapping, $this->endpoint); |
|
196 | + $object->process($product, $data); |
|
197 | 197 | |
198 | - $product = $this->get( 'job_csv_test' ); |
|
198 | + $product = $this->get('job_csv_test'); |
|
199 | 199 | |
200 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard( $this->context, [], $this->endpoint ); |
|
201 | - $object->process( $product, [] ); |
|
200 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard($this->context, [], $this->endpoint); |
|
201 | + $object->process($product, []); |
|
202 | 202 | |
203 | - $product = $this->get( 'job_csv_test' ); |
|
204 | - $this->delete( $product ); |
|
203 | + $product = $this->get('job_csv_test'); |
|
204 | + $this->delete($product); |
|
205 | 205 | |
206 | 206 | |
207 | 207 | $listItems = $product->getListItems(); |
208 | 208 | |
209 | - $this->assertEquals( 0, count( $listItems ) ); |
|
209 | + $this->assertEquals(0, count($listItems)); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | |
@@ -226,18 +226,18 @@ discard block |
||
226 | 226 | 3 => '', |
227 | 227 | ); |
228 | 228 | |
229 | - $product = $this->create( 'job_csv_test' ); |
|
229 | + $product = $this->create('job_csv_test'); |
|
230 | 230 | |
231 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard( $this->context, $mapping, $this->endpoint ); |
|
232 | - $object->process( $product, $data ); |
|
231 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard($this->context, $mapping, $this->endpoint); |
|
232 | + $object->process($product, $data); |
|
233 | 233 | |
234 | - $product = $this->get( 'job_csv_test' ); |
|
235 | - $this->delete( $product ); |
|
234 | + $product = $this->get('job_csv_test'); |
|
235 | + $this->delete($product); |
|
236 | 236 | |
237 | 237 | |
238 | 238 | $listItems = $product->getListItems(); |
239 | 239 | |
240 | - $this->assertEquals( 1, count( $listItems ) ); |
|
240 | + $this->assertEquals(1, count($listItems)); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | |
@@ -261,82 +261,82 @@ discard block |
||
261 | 261 | 5 => 'default', |
262 | 262 | ); |
263 | 263 | |
264 | - $this->context->getConfig()->set( 'controller/common/product/import/csv/processor/price/listtypes', array( 'default' ) ); |
|
264 | + $this->context->getConfig()->set('controller/common/product/import/csv/processor/price/listtypes', array('default')); |
|
265 | 265 | |
266 | - $product = $this->create( 'job_csv_test' ); |
|
266 | + $product = $this->create('job_csv_test'); |
|
267 | 267 | |
268 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard( $this->context, $mapping, $this->endpoint ); |
|
269 | - $object->process( $product, $data ); |
|
268 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard($this->context, $mapping, $this->endpoint); |
|
269 | + $object->process($product, $data); |
|
270 | 270 | |
271 | - $product = $this->get( 'job_csv_test' ); |
|
272 | - $this->delete( $product ); |
|
271 | + $product = $this->get('job_csv_test'); |
|
272 | + $this->delete($product); |
|
273 | 273 | |
274 | 274 | |
275 | 275 | $listItems = $product->getListItems(); |
276 | - $listItem = reset( $listItems ); |
|
276 | + $listItem = reset($listItems); |
|
277 | 277 | |
278 | - $this->assertEquals( 1, count( $listItems ) ); |
|
279 | - $this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem ); |
|
278 | + $this->assertEquals(1, count($listItems)); |
|
279 | + $this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem); |
|
280 | 280 | |
281 | - $this->assertEquals( 'default', $listItem->getType() ); |
|
282 | - $this->assertEquals( '2.00', $listItem->getRefItem()->getValue() ); |
|
281 | + $this->assertEquals('default', $listItem->getType()); |
|
282 | + $this->assertEquals('2.00', $listItem->getRefItem()->getValue()); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | |
286 | 286 | /** |
287 | 287 | * @param string $code |
288 | 288 | */ |
289 | - protected function create( $code ) |
|
289 | + protected function create($code) |
|
290 | 290 | { |
291 | - $manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context ); |
|
292 | - $typeManager = $manager->getSubManager( 'type' ); |
|
291 | + $manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context); |
|
292 | + $typeManager = $manager->getSubManager('type'); |
|
293 | 293 | |
294 | 294 | $typeSearch = $typeManager->createSearch(); |
295 | - $typeSearch->setConditions( $typeSearch->compare( '==', 'product.type.code', 'default' ) ); |
|
296 | - $typeResult = $typeManager->searchItems( $typeSearch ); |
|
295 | + $typeSearch->setConditions($typeSearch->compare('==', 'product.type.code', 'default')); |
|
296 | + $typeResult = $typeManager->searchItems($typeSearch); |
|
297 | 297 | |
298 | - if( ( $typeItem = reset( $typeResult ) ) === false ) { |
|
299 | - throw new \RuntimeException( 'No product type "default" found' ); |
|
298 | + if (($typeItem = reset($typeResult)) === false) { |
|
299 | + throw new \RuntimeException('No product type "default" found'); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | $item = $manager->createItem(); |
303 | - $item->setTypeid( $typeItem->getId() ); |
|
304 | - $item->setCode( $code ); |
|
303 | + $item->setTypeid($typeItem->getId()); |
|
304 | + $item->setCode($code); |
|
305 | 305 | |
306 | - return $manager->saveItem( $item ); |
|
306 | + return $manager->saveItem($item); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | |
310 | - protected function delete( \Aimeos\MShop\Product\Item\Iface $product ) |
|
310 | + protected function delete(\Aimeos\MShop\Product\Item\Iface $product) |
|
311 | 311 | { |
312 | - $priceManager = \Aimeos\MShop\Price\Manager\Factory::createManager( $this->context ); |
|
313 | - $manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context ); |
|
314 | - $listManager = $manager->getSubManager( 'lists' ); |
|
312 | + $priceManager = \Aimeos\MShop\Price\Manager\Factory::createManager($this->context); |
|
313 | + $manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context); |
|
314 | + $listManager = $manager->getSubManager('lists'); |
|
315 | 315 | |
316 | - foreach( $product->getListItems('price') as $listItem ) |
|
316 | + foreach ($product->getListItems('price') as $listItem) |
|
317 | 317 | { |
318 | - $priceManager->deleteItem( $listItem->getRefItem()->getId() ); |
|
319 | - $listManager->deleteItem( $listItem->getId() ); |
|
318 | + $priceManager->deleteItem($listItem->getRefItem()->getId()); |
|
319 | + $listManager->deleteItem($listItem->getId()); |
|
320 | 320 | } |
321 | 321 | |
322 | - $manager->deleteItem( $product->getId() ); |
|
322 | + $manager->deleteItem($product->getId()); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | |
326 | 326 | /** |
327 | 327 | * @param string $code |
328 | 328 | */ |
329 | - protected function get( $code ) |
|
329 | + protected function get($code) |
|
330 | 330 | { |
331 | - $manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context ); |
|
331 | + $manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context); |
|
332 | 332 | |
333 | 333 | $search = $manager->createSearch(); |
334 | - $search->setConditions( $search->compare( '==', 'product.code', $code ) ); |
|
334 | + $search->setConditions($search->compare('==', 'product.code', $code)); |
|
335 | 335 | |
336 | - $result = $manager->searchItems( $search, array('price') ); |
|
336 | + $result = $manager->searchItems($search, array('price')); |
|
337 | 337 | |
338 | - if( ( $item = reset( $result ) ) === false ) { |
|
339 | - throw new \RuntimeException( sprintf( 'No product item for code "%1$s"', $code ) ); |
|
338 | + if (($item = reset($result)) === false) { |
|
339 | + throw new \RuntimeException(sprintf('No product item for code "%1$s"', $code)); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | return $item; |
@@ -104,37 +104,37 @@ |
||
104 | 104 | * @param array $mappings Associative list of processor types as keys and index/data mappings as values |
105 | 105 | * @return \Aimeos\Controller\Common\Subscription\Export\Csv\Processor\Iface Processor object |
106 | 106 | */ |
107 | - protected function getProcessors( array $mappings ) |
|
107 | + protected function getProcessors(array $mappings) |
|
108 | 108 | { |
109 | 109 | $list = []; |
110 | 110 | $context = $this->getContext(); |
111 | 111 | $config = $context->getConfig(); |
112 | 112 | |
113 | - foreach( $mappings as $type => $mapping ) |
|
113 | + foreach ($mappings as $type => $mapping) |
|
114 | 114 | { |
115 | - if( ctype_alnum( $type ) === false ) |
|
115 | + if (ctype_alnum($type) === false) |
|
116 | 116 | { |
117 | 117 | $classname = is_string($type) ? '\\Aimeos\\Controller\\Common\\Subscription\\Export\\Csv\\Processor\\' . $type : '<not a string>'; |
118 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
118 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
119 | 119 | } |
120 | 120 | |
121 | - $name = $config->get( 'controller/common/subscription/export/csv/processor/' . $type . '/name', 'Standard' ); |
|
121 | + $name = $config->get('controller/common/subscription/export/csv/processor/' . $type . '/name', 'Standard'); |
|
122 | 122 | |
123 | - if( ctype_alnum( $name ) === false ) |
|
123 | + if (ctype_alnum($name) === false) |
|
124 | 124 | { |
125 | 125 | $classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Subscription\\Export\\Csv\\Processor\\' . $type . '\\' . $name : '<not a string>'; |
126 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
126 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
127 | 127 | } |
128 | 128 | |
129 | - $classname = '\\Aimeos\\Controller\\Common\\Subscription\\Export\\Csv\\Processor\\' . ucfirst( $type ) . '\\' . $name; |
|
129 | + $classname = '\\Aimeos\\Controller\\Common\\Subscription\\Export\\Csv\\Processor\\' . ucfirst($type) . '\\' . $name; |
|
130 | 130 | |
131 | - if( class_exists( $classname ) === false ) { |
|
132 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) ); |
|
131 | + if (class_exists($classname) === false) { |
|
132 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname)); |
|
133 | 133 | } |
134 | 134 | |
135 | - $object = new $classname( $context, $mapping ); |
|
135 | + $object = new $classname($context, $mapping); |
|
136 | 136 | |
137 | - \Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Common\\Subscription\\Export\\Csv\\Processor\\Iface', $object ); |
|
137 | + \Aimeos\MW\Common\Base::checkClass('\\Aimeos\\Controller\\Common\\Subscription\\Export\\Csv\\Processor\\Iface', $object); |
|
138 | 138 | |
139 | 139 | $list[$type] = $object; |
140 | 140 | } |
@@ -27,37 +27,37 @@ |
||
27 | 27 | * @param array $pnames List of processor names |
28 | 28 | * @return \Aimeos\Controller\Common\Subscription\Export\Csv\Processor\Iface Processor object |
29 | 29 | */ |
30 | - protected function getProcessors( array $pnames ) |
|
30 | + protected function getProcessors(array $pnames) |
|
31 | 31 | { |
32 | 32 | $list = []; |
33 | 33 | $context = $this->getContext(); |
34 | 34 | $config = $context->getConfig(); |
35 | 35 | |
36 | - foreach( $pnames as $pname ) |
|
36 | + foreach ($pnames as $pname) |
|
37 | 37 | { |
38 | - if( ctype_alnum( $pname ) === false ) |
|
38 | + if (ctype_alnum($pname) === false) |
|
39 | 39 | { |
40 | 40 | $classname = is_string($pname) ? '\\Aimeos\\Controller\\Common\\Subscription\\Process\\Processor\\' . $pname : '<not a string>'; |
41 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
41 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
42 | 42 | } |
43 | 43 | |
44 | - $name = $config->get( 'controller/common/subscription/process/processor/' . $pname . '/name', 'Standard' ); |
|
44 | + $name = $config->get('controller/common/subscription/process/processor/' . $pname . '/name', 'Standard'); |
|
45 | 45 | |
46 | - if( ctype_alnum( $name ) === false ) |
|
46 | + if (ctype_alnum($name) === false) |
|
47 | 47 | { |
48 | 48 | $classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Subscription\\Process\\Processor\\' . $pname . '\\' . $name : '<not a string>'; |
49 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
49 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
50 | 50 | } |
51 | 51 | |
52 | - $classname = '\\Aimeos\\Controller\\Common\\Subscription\\Process\\Processor\\' . ucfirst( $pname ) . '\\' . $name; |
|
52 | + $classname = '\\Aimeos\\Controller\\Common\\Subscription\\Process\\Processor\\' . ucfirst($pname) . '\\' . $name; |
|
53 | 53 | |
54 | - if( class_exists( $classname ) === false ) { |
|
55 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) ); |
|
54 | + if (class_exists($classname) === false) { |
|
55 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname)); |
|
56 | 56 | } |
57 | 57 | |
58 | - $object = new $classname( $context ); |
|
58 | + $object = new $classname($context); |
|
59 | 59 | |
60 | - \Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Common\\Subscription\\Process\\Processor\\Iface', $object ); |
|
60 | + \Aimeos\MW\Common\Base::checkClass('\\Aimeos\\Controller\\Common\\Subscription\\Process\\Processor\\Iface', $object); |
|
61 | 61 | |
62 | 62 | $list[$pname] = $object; |
63 | 63 | } |
@@ -142,37 +142,37 @@ |
||
142 | 142 | * @param array $mappings Associative list of processor types as keys and index/data mappings as values |
143 | 143 | * @return \Aimeos\Controller\Common\Order\Export\Csv\Processor\Iface Processor object |
144 | 144 | */ |
145 | - protected function getProcessors( array $mappings ) |
|
145 | + protected function getProcessors(array $mappings) |
|
146 | 146 | { |
147 | 147 | $list = []; |
148 | 148 | $context = $this->getContext(); |
149 | 149 | $config = $context->getConfig(); |
150 | 150 | |
151 | - foreach( $mappings as $type => $mapping ) |
|
151 | + foreach ($mappings as $type => $mapping) |
|
152 | 152 | { |
153 | - if( ctype_alnum( $type ) === false ) |
|
153 | + if (ctype_alnum($type) === false) |
|
154 | 154 | { |
155 | 155 | $classname = is_string($type) ? '\\Aimeos\\Controller\\Common\\Order\\Export\\Csv\\Processor\\' . $type : '<not a string>'; |
156 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
156 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
157 | 157 | } |
158 | 158 | |
159 | - $name = $config->get( 'controller/common/order/export/csv/processor/' . $type . '/name', 'Standard' ); |
|
159 | + $name = $config->get('controller/common/order/export/csv/processor/' . $type . '/name', 'Standard'); |
|
160 | 160 | |
161 | - if( ctype_alnum( $name ) === false ) |
|
161 | + if (ctype_alnum($name) === false) |
|
162 | 162 | { |
163 | 163 | $classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Order\\Export\\Csv\\Processor\\' . $type . '\\' . $name : '<not a string>'; |
164 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
164 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
165 | 165 | } |
166 | 166 | |
167 | - $classname = '\\Aimeos\\Controller\\Common\\Order\\Export\\Csv\\Processor\\' . ucfirst( $type ) . '\\' . $name; |
|
167 | + $classname = '\\Aimeos\\Controller\\Common\\Order\\Export\\Csv\\Processor\\' . ucfirst($type) . '\\' . $name; |
|
168 | 168 | |
169 | - if( class_exists( $classname ) === false ) { |
|
170 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) ); |
|
169 | + if (class_exists($classname) === false) { |
|
170 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname)); |
|
171 | 171 | } |
172 | 172 | |
173 | - $object = new $classname( $context, $mapping ); |
|
173 | + $object = new $classname($context, $mapping); |
|
174 | 174 | |
175 | - \Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Common\\Order\\Export\\Csv\\Processor\\Iface', $object ); |
|
175 | + \Aimeos\MW\Common\Base::checkClass('\\Aimeos\\Controller\\Common\\Order\\Export\\Csv\\Processor\\Iface', $object); |
|
176 | 176 | |
177 | 177 | $list[$type] = $object; |
178 | 178 | } |
@@ -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\Product\Import\Csv\Processor\Iface $processor Decorated processor |
29 | 29 | */ |
30 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
31 | - \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor = null ) |
|
30 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
31 | + \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor = 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\Product\Item\Iface $item, array $data ) |
|
43 | + public function process(\Aimeos\MShop\Product\Item\Iface $item, array $data) |
|
44 | 44 | { |
45 | 45 | return $data; |
46 | 46 | } |
@@ -30,14 +30,14 @@ discard block |
||
30 | 30 | * @param array $data Associative list of product codes and lists of CSV field indexes and their data |
31 | 31 | * @return array Associative list of CSV field indexes and their converted data |
32 | 32 | */ |
33 | - protected function convertData( array $convlist, array $data ) |
|
33 | + protected function convertData(array $convlist, array $data) |
|
34 | 34 | { |
35 | - foreach( $convlist as $idx => $converter ) |
|
35 | + foreach ($convlist as $idx => $converter) |
|
36 | 36 | { |
37 | - foreach( $data as $code => $list ) |
|
37 | + foreach ($data as $code => $list) |
|
38 | 38 | { |
39 | - if( isset( $list[$idx] ) ) { |
|
40 | - $data[$code][$idx] = $converter->translate( $list[$idx] ); |
|
39 | + if (isset($list[$idx])) { |
|
40 | + $data[$code][$idx] = $converter->translate($list[$idx]); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | } |
@@ -53,36 +53,36 @@ discard block |
||
53 | 53 | * @param string|null Name of the cache implementation |
54 | 54 | * @return \Aimeos\Controller\Common\Product\Import\Csv\Cache\Iface Cache object |
55 | 55 | */ |
56 | - protected function getCache( $type, $name = null ) |
|
56 | + protected function getCache($type, $name = null) |
|
57 | 57 | { |
58 | 58 | $context = $this->getContext(); |
59 | 59 | $config = $context->getConfig(); |
60 | 60 | |
61 | - if( ctype_alnum( $type ) === false ) |
|
61 | + if (ctype_alnum($type) === false) |
|
62 | 62 | { |
63 | 63 | $classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\' . $type : '<not a string>'; |
64 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
64 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
65 | 65 | } |
66 | 66 | |
67 | - if( $name === null ) { |
|
68 | - $name = $config->get( 'controller/common/product/import/csv/cache/' . $type . '/name', 'Standard' ); |
|
67 | + if ($name === null) { |
|
68 | + $name = $config->get('controller/common/product/import/csv/cache/' . $type . '/name', 'Standard'); |
|
69 | 69 | } |
70 | 70 | |
71 | - if( ctype_alnum( $name ) === false ) |
|
71 | + if (ctype_alnum($name) === false) |
|
72 | 72 | { |
73 | 73 | $classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\' . $type . '\\' . $name : '<not a string>'; |
74 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
74 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
75 | 75 | } |
76 | 76 | |
77 | - $classname = '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\' . ucfirst( $type ) . '\\' . $name; |
|
77 | + $classname = '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\' . ucfirst($type) . '\\' . $name; |
|
78 | 78 | |
79 | - if( class_exists( $classname ) === false ) { |
|
80 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) ); |
|
79 | + if (class_exists($classname) === false) { |
|
80 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname)); |
|
81 | 81 | } |
82 | 82 | |
83 | - $object = new $classname( $context ); |
|
83 | + $object = new $classname($context); |
|
84 | 84 | |
85 | - \Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\Iface', $object ); |
|
85 | + \Aimeos\MW\Common\Base::checkClass('\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\Iface', $object); |
|
86 | 86 | |
87 | 87 | return $object; |
88 | 88 | } |
@@ -94,12 +94,12 @@ discard block |
||
94 | 94 | * @param array $convmap List of converter names for the values at the position in the CSV file |
95 | 95 | * @return array Associative list of positions and converter objects |
96 | 96 | */ |
97 | - protected function getConverterList( array $convmap ) |
|
97 | + protected function getConverterList(array $convmap) |
|
98 | 98 | { |
99 | 99 | $convlist = []; |
100 | 100 | |
101 | - foreach( $convmap as $idx => $name ) { |
|
102 | - $convlist[$idx] = \Aimeos\MW\Convert\Factory::createConverter( $name ); |
|
101 | + foreach ($convmap as $idx => $name) { |
|
102 | + $convlist[$idx] = \Aimeos\MW\Convert\Factory::createConverter($name); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | return $convlist; |
@@ -114,15 +114,15 @@ discard block |
||
114 | 114 | * @param integer $codePos Column position which contains the unique product code (starting from 0) |
115 | 115 | * @return array List of arrays with product codes as keys and list of values from the CSV file |
116 | 116 | */ |
117 | - protected function getData( \Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos ) |
|
117 | + protected function getData(\Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos) |
|
118 | 118 | { |
119 | 119 | $count = 0; |
120 | 120 | $data = []; |
121 | 121 | |
122 | - while( $content->valid() && $count++ < $maxcnt ) |
|
122 | + while ($content->valid() && $count++ < $maxcnt) |
|
123 | 123 | { |
124 | 124 | $row = $content->current(); |
125 | - $data[ $row[$codePos] ] = $row; |
|
125 | + $data[$row[$codePos]] = $row; |
|
126 | 126 | $content->next(); |
127 | 127 | } |
128 | 128 | |
@@ -221,21 +221,21 @@ discard block |
||
221 | 221 | * @param array $mapping List of domain item keys with the CSV field position as key |
222 | 222 | * @return array List of associative arrays containing the chunked properties |
223 | 223 | */ |
224 | - protected function getMappedChunk( array &$data, array $mapping ) |
|
224 | + protected function getMappedChunk(array &$data, array $mapping) |
|
225 | 225 | { |
226 | 226 | $idx = 0; |
227 | 227 | $map = []; |
228 | 228 | |
229 | - foreach( $mapping as $pos => $key ) |
|
229 | + foreach ($mapping as $pos => $key) |
|
230 | 230 | { |
231 | - if( isset( $map[$idx][$key] ) ) { |
|
231 | + if (isset($map[$idx][$key])) { |
|
232 | 232 | $idx++; |
233 | 233 | } |
234 | 234 | |
235 | - if( isset( $data[$pos] ) ) |
|
235 | + if (isset($data[$pos])) |
|
236 | 236 | { |
237 | 237 | $map[$idx][$key] = $data[$pos]; |
238 | - unset( $data[$pos] ); |
|
238 | + unset($data[$pos]); |
|
239 | 239 | } |
240 | 240 | } |
241 | 241 | |
@@ -249,37 +249,37 @@ discard block |
||
249 | 249 | * @param array $mappings Associative list of processor types as keys and index/data mappings as values |
250 | 250 | * @return \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface Processor object |
251 | 251 | */ |
252 | - protected function getProcessors( array $mappings ) |
|
252 | + protected function getProcessors(array $mappings) |
|
253 | 253 | { |
254 | 254 | $context = $this->getContext(); |
255 | 255 | $config = $context->getConfig(); |
256 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done( $context, [] ); |
|
256 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done($context, []); |
|
257 | 257 | |
258 | - foreach( $mappings as $type => $mapping ) |
|
258 | + foreach ($mappings as $type => $mapping) |
|
259 | 259 | { |
260 | - if( ctype_alnum( $type ) === false ) |
|
260 | + if (ctype_alnum($type) === false) |
|
261 | 261 | { |
262 | 262 | $classname = is_string($type) ? '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\' . $type : '<not a string>'; |
263 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
263 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
264 | 264 | } |
265 | 265 | |
266 | - $name = $config->get( 'controller/common/product/import/csv/processor/' . $type . '/name', 'Standard' ); |
|
266 | + $name = $config->get('controller/common/product/import/csv/processor/' . $type . '/name', 'Standard'); |
|
267 | 267 | |
268 | - if( ctype_alnum( $name ) === false ) |
|
268 | + if (ctype_alnum($name) === false) |
|
269 | 269 | { |
270 | 270 | $classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\' . $type . '\\' . $name : '<not a string>'; |
271 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
271 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
272 | 272 | } |
273 | 273 | |
274 | - $classname = '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\' . ucfirst( $type ) . '\\' . $name; |
|
274 | + $classname = '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\' . ucfirst($type) . '\\' . $name; |
|
275 | 275 | |
276 | - if( class_exists( $classname ) === false ) { |
|
277 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) ); |
|
276 | + if (class_exists($classname) === false) { |
|
277 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname)); |
|
278 | 278 | } |
279 | 279 | |
280 | - $object = new $classname( $context, $mapping, $object ); |
|
280 | + $object = new $classname($context, $mapping, $object); |
|
281 | 281 | |
282 | - \Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\Iface', $object ); |
|
282 | + \Aimeos\MW\Common\Base::checkClass('\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\Iface', $object); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | return $object; |
@@ -293,17 +293,17 @@ discard block |
||
293 | 293 | * @param array $domains List of domains whose items should be fetched too |
294 | 294 | * @return array Associative list of product codes as key and product items as value |
295 | 295 | */ |
296 | - protected function getProducts( array $codes, array $domains ) |
|
296 | + protected function getProducts(array $codes, array $domains) |
|
297 | 297 | { |
298 | 298 | $result = []; |
299 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
299 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
300 | 300 | |
301 | 301 | $search = $manager->createSearch(); |
302 | - $search->setConditions( $search->compare( '==', 'product.code', $codes ) ); |
|
303 | - $search->setSlice( 0, count( $codes ) ); |
|
302 | + $search->setConditions($search->compare('==', 'product.code', $codes)); |
|
303 | + $search->setSlice(0, count($codes)); |
|
304 | 304 | |
305 | - foreach( $manager->searchItems( $search, $domains ) as $item ) { |
|
306 | - $result[ $item->getCode() ] = $item; |
|
305 | + foreach ($manager->searchItems($search, $domains) as $item) { |
|
306 | + $result[$item->getCode()] = $item; |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | return $result; |
@@ -318,23 +318,23 @@ discard block |
||
318 | 318 | * @param string $code Unique code of the type item |
319 | 319 | * @return string Unique ID of the type item |
320 | 320 | */ |
321 | - protected function getTypeId( $path, $domain, $code ) |
|
321 | + protected function getTypeId($path, $domain, $code) |
|
322 | 322 | { |
323 | - if( !isset( self::$types[$path][$domain] ) ) |
|
323 | + if (!isset(self::$types[$path][$domain])) |
|
324 | 324 | { |
325 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $path ); |
|
326 | - $key = str_replace( '/', '.', $path ); |
|
325 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $path); |
|
326 | + $key = str_replace('/', '.', $path); |
|
327 | 327 | |
328 | 328 | $search = $manager->createSearch(); |
329 | - $search->setConditions( $search->compare( '==', $key . '.domain', $domain ) ); |
|
329 | + $search->setConditions($search->compare('==', $key . '.domain', $domain)); |
|
330 | 330 | |
331 | - foreach( $manager->searchItems( $search ) as $id => $item ) { |
|
332 | - self::$types[$path][$domain][ $item->getCode() ] = $id; |
|
331 | + foreach ($manager->searchItems($search) as $id => $item) { |
|
332 | + self::$types[$path][$domain][$item->getCode()] = $id; |
|
333 | 333 | } |
334 | 334 | } |
335 | 335 | |
336 | - if( !isset( self::$types[$path][$domain][$code] ) ) { |
|
337 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'No type item for "%1$s/%2$s" in "%3$s" found', $domain, $code, $path ) ); |
|
336 | + if (!isset(self::$types[$path][$domain][$code])) { |
|
337 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('No type item for "%1$s/%2$s" in "%3$s" found', $domain, $code, $path)); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | return self::$types[$path][$domain][$code]; |
@@ -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,37 +126,37 @@ 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 | - $object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Done( $context, [] ); |
|
133 | + $object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Done($context, []); |
|
134 | 134 | |
135 | - foreach( $mappings as $type => $mapping ) |
|
135 | + foreach ($mappings as $type => $mapping) |
|
136 | 136 | { |
137 | - if( ctype_alnum( $type ) === false ) |
|
137 | + if (ctype_alnum($type) === false) |
|
138 | 138 | { |
139 | 139 | $classname = is_string($type) ? '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\' . $type : '<not a string>'; |
140 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
140 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
141 | 141 | } |
142 | 142 | |
143 | - $name = $config->get( 'controller/common/coupon/import/csv/processor/' . $type . '/name', 'Standard' ); |
|
143 | + $name = $config->get('controller/common/coupon/import/csv/processor/' . $type . '/name', 'Standard'); |
|
144 | 144 | |
145 | - if( ctype_alnum( $name ) === false ) |
|
145 | + if (ctype_alnum($name) === false) |
|
146 | 146 | { |
147 | 147 | $classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\' . $type . '\\' . $name : '<not a string>'; |
148 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
148 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
149 | 149 | } |
150 | 150 | |
151 | - $classname = '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\' . ucfirst( $type ) . '\\' . $name; |
|
151 | + $classname = '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\' . ucfirst($type) . '\\' . $name; |
|
152 | 152 | |
153 | - if( class_exists( $classname ) === false ) { |
|
154 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) ); |
|
153 | + if (class_exists($classname) === false) { |
|
154 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname)); |
|
155 | 155 | } |
156 | 156 | |
157 | - $object = new $classname( $context, $mapping, $object ); |
|
157 | + $object = new $classname($context, $mapping, $object); |
|
158 | 158 | |
159 | - \Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\Iface', $object ); |
|
159 | + \Aimeos\MW\Common\Base::checkClass('\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\Iface', $object); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | return $object; |