Completed
Push — master ( b6a23a...c3c77b )
by Aimeos
03:07
created
src/Controller/Common/Product/Import/Csv/Processor/Catalog/Standard.php 2 patches
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -81,8 +81,7 @@  discard block
 block discarded – undo
81 81
 			foreach( $manager->searchItems( $search ) as $item ) {
82 82
 				$this->listTypes[$item->getCode()] = $item->getCode();
83 83
 			}
84
-		}
85
-		else
84
+		} else
86 85
 		{
87 86
 			$this->listTypes = array_flip( $this->listTypes );
88 87
 		}
@@ -164,8 +163,7 @@  discard block
 block discarded – undo
164 163
 					{
165 164
 						$listItem = $listMap[$catid][$listtype];
166 165
 						unset( $listItems[ $listItem->getId() ] );
167
-					}
168
-					else
166
+					} else
169 167
 					{
170 168
 						$listItem = $listManager->createItem()->setType( $listtype );
171 169
 					}
@@ -179,8 +177,7 @@  discard block
 block discarded – undo
179 177
 			$data = $this->getObject()->process( $product, $data );
180 178
 
181 179
 			$manager->commit();
182
-		}
183
-		catch( \Exception $e )
180
+		} catch( \Exception $e )
184 181
 		{
185 182
 			$manager->rollback();
186 183
 			throw $e;
Please login to merge, or discard this patch.
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
44 44
 	 * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor
45 45
 	 */
46
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping,
47
-		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null )
46
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
47
+		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null)
48 48
 	{
49
-		parent::__construct( $context, $mapping, $object );
49
+		parent::__construct($context, $mapping, $object);
50 50
 
51 51
 		/** controller/common/product/import/csv/processor/catalog/listtypes
52 52
 		 * Names of the catalog list types that are updated or removed
@@ -68,26 +68,26 @@  discard block
 block discarded – undo
68 68
 		 * @see controller/common/product/import/csv/processor/text/listtypes
69 69
 		 */
70 70
 		$key = 'controller/common/product/import/csv/processor/catalog/listtypes';
71
-		$this->listTypes = $context->getConfig()->get( $key );
71
+		$this->listTypes = $context->getConfig()->get($key);
72 72
 
73
-		if( $this->listTypes === null )
73
+		if ($this->listTypes === null)
74 74
 		{
75 75
 			$this->listTypes = [];
76
-			$manager = \Aimeos\MShop::create( $context, 'catalog/lists/type' );
76
+			$manager = \Aimeos\MShop::create($context, 'catalog/lists/type');
77 77
 
78
-			$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
79
-			$search->setConditions( $search->compare( '==', 'catalog.lists.type.domain', 'product' ) );
78
+			$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
79
+			$search->setConditions($search->compare('==', 'catalog.lists.type.domain', 'product'));
80 80
 
81
-			foreach( $manager->searchItems( $search ) as $item ) {
81
+			foreach ($manager->searchItems($search) as $item) {
82 82
 				$this->listTypes[$item->getCode()] = $item->getCode();
83 83
 			}
84 84
 		}
85 85
 		else
86 86
 		{
87
-			$this->listTypes = array_flip( $this->listTypes );
87
+			$this->listTypes = array_flip($this->listTypes);
88 88
 		}
89 89
 
90
-		$this->cache = $this->getCache( 'catalog' );
90
+		$this->cache = $this->getCache('catalog');
91 91
 	}
92 92
 
93 93
 
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
 	 * @param array $data List of CSV fields with position as key and data as value
99 99
 	 * @return array List of data which hasn't been imported
100 100
 	 */
101
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
101
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
102 102
 	{
103 103
 		$context = $this->getContext();
104
-		$manager = \Aimeos\MShop::create( $context, 'catalog' );
105
-		$listManager = \Aimeos\MShop::create( $context, 'catalog/lists' );
104
+		$manager = \Aimeos\MShop::create($context, 'catalog');
105
+		$listManager = \Aimeos\MShop::create($context, 'catalog/lists');
106 106
 
107 107
 		/** controller/common/product/import/csv/separator
108 108
 		 * Single separator character for multiple entries in one field of the import file
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 		 * @category Developer
123 123
 		 * @see controller/common/product/import/csv/domains
124 124
 		 */
125
-		$separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" );
125
+		$separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n");
126 126
 
127 127
 		$manager->begin();
128 128
 
@@ -130,57 +130,57 @@  discard block
 block discarded – undo
130 130
 		{
131 131
 			$listMap = [];
132 132
 			$prodid = $product->getId();
133
-			$map = $this->getMappedChunk( $data, $this->getMapping() );
134
-			$listItems = $this->getListItems( $prodid, $this->listTypes );
133
+			$map = $this->getMappedChunk($data, $this->getMapping());
134
+			$listItems = $this->getListItems($prodid, $this->listTypes);
135 135
 
136
-			foreach( $listItems as $listItem ) {
137
-				$listMap[ $listItem->getParentId() ][ $listItem->getType() ] = $listItem;
136
+			foreach ($listItems as $listItem) {
137
+				$listMap[$listItem->getParentId()][$listItem->getType()] = $listItem;
138 138
 			}
139 139
 
140
-			foreach( $map as $pos => $list )
140
+			foreach ($map as $pos => $list)
141 141
 			{
142
-				if( $this->checkEntry( $list ) === false ) {
142
+				if ($this->checkEntry($list) === false) {
143 143
 					continue;
144 144
 				}
145 145
 
146
-				$codes = explode( $separator, $this->getValue( $list, 'catalog.code', '' ) );
147
-				$listtype = $this->getValue( $list, 'catalog.lists.type', 'default' );
146
+				$codes = explode($separator, $this->getValue($list, 'catalog.code', ''));
147
+				$listtype = $this->getValue($list, 'catalog.lists.type', 'default');
148 148
 
149
-				foreach( $codes as $code )
149
+				foreach ($codes as $code)
150 150
 				{
151
-					$code = trim( $code );
151
+					$code = trim($code);
152 152
 
153
-					if( ( $catid = $this->cache->get( $code ) ) === null )
153
+					if (($catid = $this->cache->get($code)) === null)
154 154
 					{
155 155
 						$msg = 'No category for code "%1$s" available when importing product with code "%2$s"';
156
-						throw new \Aimeos\Controller\Jobs\Exception( sprintf( $msg, $code, $product->getCode() ) );
156
+						throw new \Aimeos\Controller\Jobs\Exception(sprintf($msg, $code, $product->getCode()));
157 157
 					}
158 158
 
159 159
 					$list['catalog.lists.parentid'] = $catid;
160 160
 					$list['catalog.lists.refid'] = $prodid;
161 161
 					$list['catalog.lists.domain'] = 'product';
162 162
 
163
-					if( isset( $listMap[$catid][$listtype] ) )
163
+					if (isset($listMap[$catid][$listtype]))
164 164
 					{
165 165
 						$listItem = $listMap[$catid][$listtype];
166
-						unset( $listItems[ $listItem->getId() ] );
166
+						unset($listItems[$listItem->getId()]);
167 167
 					}
168 168
 					else
169 169
 					{
170
-						$listItem = $listManager->createItem()->setType( $listtype );
170
+						$listItem = $listManager->createItem()->setType($listtype);
171 171
 					}
172 172
 
173
-					$listItem = $listItem->setPosition( $pos++ )->fromArray( $list );
174
-					$listManager->saveItem( $listItem, false );
173
+					$listItem = $listItem->setPosition($pos++)->fromArray($list);
174
+					$listManager->saveItem($listItem, false);
175 175
 				}
176 176
 			}
177 177
 
178
-			$listManager->deleteItems( array_keys( $listItems ) );
179
-			$data = $this->getObject()->process( $product, $data );
178
+			$listManager->deleteItems(array_keys($listItems));
179
+			$data = $this->getObject()->process($product, $data);
180 180
 
181 181
 			$manager->commit();
182 182
 		}
183
-		catch( \Exception $e )
183
+		catch (\Exception $e)
184 184
 		{
185 185
 			$manager->rollback();
186 186
 			throw $e;
@@ -197,13 +197,13 @@  discard block
 block discarded – undo
197 197
 	 * @param integer $pos Computed position of the list item in the associated list of items
198 198
 	 * @return array Given associative list enriched by default values if they were not already set
199 199
 	 */
200
-	protected function addListItemDefaults( array $list, $pos )
200
+	protected function addListItemDefaults(array $list, $pos)
201 201
 	{
202
-		if( !isset( $list['catalog.lists.position'] ) ) {
202
+		if (!isset($list['catalog.lists.position'])) {
203 203
 			$list['catalog.lists.position'] = $pos;
204 204
 		}
205 205
 
206
-		if( !isset( $list['catalog.lists.status'] ) ) {
206
+		if (!isset($list['catalog.lists.status'])) {
207 207
 			$list['catalog.lists.status'] = 1;
208 208
 		}
209 209
 
@@ -217,16 +217,16 @@  discard block
 block discarded – undo
217 217
 	 * @param array $list Associative list of key/value pairs from the mapped data
218 218
 	 * @return boolean True if the entry is valid, false if not
219 219
 	 */
220
-	protected function checkEntry( array $list )
220
+	protected function checkEntry(array $list)
221 221
 	{
222
-		if( $this->getValue( $list, 'catalog.code' ) === null ) {
222
+		if ($this->getValue($list, 'catalog.code') === null) {
223 223
 			return false;
224 224
 		}
225 225
 
226
-		if( ( $type = $this->getValue( $list, 'catalog.lists.type' ) ) && !isset( $this->listTypes[$type] ) )
226
+		if (($type = $this->getValue($list, 'catalog.lists.type')) && !isset($this->listTypes[$type]))
227 227
 		{
228
-			$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'catalog list' );
229
-			throw new \Aimeos\Controller\Common\Exception( $msg );
228
+			$msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'catalog list');
229
+			throw new \Aimeos\Controller\Common\Exception($msg);
230 230
 		}
231 231
 
232 232
 		return true;
@@ -240,24 +240,24 @@  discard block
 block discarded – undo
240 240
 	 * @param array|null $types List of catalog list types
241 241
 	 * @return array List of catalog list items
242 242
 	 */
243
-	protected function getListItems( $prodid, $types )
243
+	protected function getListItems($prodid, $types)
244 244
 	{
245
-		$manager = \Aimeos\MShop::create( $this->getContext(), 'catalog/lists' );
245
+		$manager = \Aimeos\MShop::create($this->getContext(), 'catalog/lists');
246 246
 		$search = $manager->createSearch();
247 247
 
248 248
 		$expr = array(
249
-			$search->compare( '==', 'catalog.lists.domain', 'product' ),
250
-			$search->compare( '==', 'catalog.lists.refid', $prodid ),
249
+			$search->compare('==', 'catalog.lists.domain', 'product'),
250
+			$search->compare('==', 'catalog.lists.refid', $prodid),
251 251
 		);
252 252
 
253
-		if( $types !== null ) {
254
-			$expr[] = $search->compare( '==', 'catalog.lists.type', $types );
253
+		if ($types !== null) {
254
+			$expr[] = $search->compare('==', 'catalog.lists.type', $types);
255 255
 		}
256 256
 
257
-		$search->setConditions( $search->combine( '&&', $expr ) );
258
-		$search->setSortations( array( $search->sort( '+', 'catalog.lists.position' ) ) );
259
-		$search->setSlice( 0, 0x7FFFFFFF );
257
+		$search->setConditions($search->combine('&&', $expr));
258
+		$search->setSortations(array($search->sort('+', 'catalog.lists.position')));
259
+		$search->setSlice(0, 0x7FFFFFFF);
260 260
 
261
-		return $manager->searchItems( $search );
261
+		return $manager->searchItems($search);
262 262
 	}
263 263
 }
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Processor/Media/Standard.php 2 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -81,8 +81,7 @@  discard block
 block discarded – undo
81 81
 			foreach( $manager->searchItems( $search ) as $item ) {
82 82
 				$this->listTypes[$item->getCode()] = $item->getCode();
83 83
 			}
84
-		}
85
-		else
84
+		} else
86 85
 		{
87 86
 			$this->listTypes = array_flip( $this->listTypes );
88 87
 		}
@@ -143,8 +142,7 @@  discard block
 block discarded – undo
143 142
 					$listItem = $listMap[$url][$type][$listtype];
144 143
 					$refItem = $listItem->getRefItem();
145 144
 					unset( $listItems[ $listItem->getId() ] );
146
-				}
147
-				else
145
+				} else
148 146
 				{
149 147
 					$listItem = $listManager->createItem()->setType( $listtype );
150 148
 					$refItem = $manager->createItem()->setType( $type );
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
44 44
 	 * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor
45 45
 	 */
46
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping,
47
-			\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null )
46
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
47
+			\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null)
48 48
 	{
49
-		parent::__construct( $context, $mapping, $object );
49
+		parent::__construct($context, $mapping, $object);
50 50
 
51 51
 		/** controller/common/product/import/csv/processor/media/listtypes
52 52
 		 * Names of the product list types for media that are updated or removed
@@ -68,32 +68,32 @@  discard block
 block discarded – undo
68 68
 		 * @see controller/common/product/import/csv/processor/text/listtypes
69 69
 		 */
70 70
 		$key = 'controller/common/product/import/csv/processor/media/listtypes';
71
-		$this->listTypes = $context->getConfig()->get( $key );
71
+		$this->listTypes = $context->getConfig()->get($key);
72 72
 
73
-		if( $this->listTypes === null )
73
+		if ($this->listTypes === null)
74 74
 		{
75 75
 			$this->listTypes = [];
76
-			$manager = \Aimeos\MShop::create( $context, 'product/lists/type' );
76
+			$manager = \Aimeos\MShop::create($context, 'product/lists/type');
77 77
 
78
-			$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
79
-			$search->setConditions( $search->compare( '==', 'product.lists.type.domain', 'media' ) );
78
+			$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
79
+			$search->setConditions($search->compare('==', 'product.lists.type.domain', 'media'));
80 80
 
81
-			foreach( $manager->searchItems( $search ) as $item ) {
81
+			foreach ($manager->searchItems($search) as $item) {
82 82
 				$this->listTypes[$item->getCode()] = $item->getCode();
83 83
 			}
84 84
 		}
85 85
 		else
86 86
 		{
87
-			$this->listTypes = array_flip( $this->listTypes );
87
+			$this->listTypes = array_flip($this->listTypes);
88 88
 		}
89 89
 
90 90
 
91
-		$manager = \Aimeos\MShop::create( $context, 'media/type' );
91
+		$manager = \Aimeos\MShop::create($context, 'media/type');
92 92
 
93
-		$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
94
-		$search->setConditions( $search->compare( '==', 'media.type.domain', 'product' ) );
93
+		$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
94
+		$search->setConditions($search->compare('==', 'media.type.domain', 'product'));
95 95
 
96
-		foreach( $manager->searchItems( $search ) as $item ) {
96
+		foreach ($manager->searchItems($search) as $item) {
97 97
 			$this->types[$item->getCode()] = $item->getCode();
98 98
 		}
99 99
 	}
@@ -106,60 +106,60 @@  discard block
 block discarded – undo
106 106
 	 * @param array $data List of CSV fields with position as key and data as value
107 107
 	 * @return array List of data which hasn't been imported
108 108
 	 */
109
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
109
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
110 110
 	{
111 111
 		$context = $this->getContext();
112
-		$manager = \Aimeos\MShop::create( $context, 'media' );
113
-		$listManager = \Aimeos\MShop::create( $context, 'product/lists' );
114
-		$separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" );
112
+		$manager = \Aimeos\MShop::create($context, 'media');
113
+		$listManager = \Aimeos\MShop::create($context, 'product/lists');
114
+		$separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n");
115 115
 
116 116
 		$listMap = [];
117
-		$map = $this->getMappedChunk( $data, $this->getMapping() );
118
-		$listItems = $product->getListItems( 'media', $this->listTypes );
117
+		$map = $this->getMappedChunk($data, $this->getMapping());
118
+		$listItems = $product->getListItems('media', $this->listTypes);
119 119
 
120
-		foreach( $listItems as $listItem )
120
+		foreach ($listItems as $listItem)
121 121
 		{
122
-			if( ( $refItem = $listItem->getRefItem() ) !== null ) {
123
-				$listMap[ $refItem->getUrl() ][ $refItem->getType() ][ $listItem->getType() ] = $listItem;
122
+			if (($refItem = $listItem->getRefItem()) !== null) {
123
+				$listMap[$refItem->getUrl()][$refItem->getType()][$listItem->getType()] = $listItem;
124 124
 			}
125 125
 		}
126 126
 
127
-		foreach( $map as $pos => $list )
127
+		foreach ($map as $pos => $list)
128 128
 		{
129
-			if( $this->checkEntry( $list ) === false ) {
129
+			if ($this->checkEntry($list) === false) {
130 130
 				continue;
131 131
 			}
132 132
 
133
-			$type = $this->getValue( $list, 'media.type', 'default' );
134
-			$listtype = $this->getValue( $list, 'product.lists.type', 'default' );
135
-			$urls = explode( $separator, $this->getValue( $list, 'media.url', '' ) );
133
+			$type = $this->getValue($list, 'media.type', 'default');
134
+			$listtype = $this->getValue($list, 'product.lists.type', 'default');
135
+			$urls = explode($separator, $this->getValue($list, 'media.url', ''));
136 136
 
137
-			foreach( $urls as $url )
137
+			foreach ($urls as $url)
138 138
 			{
139
-				$url = trim( $url );
139
+				$url = trim($url);
140 140
 
141
-				if( isset( $listMap[$url][$type][$listtype] ) )
141
+				if (isset($listMap[$url][$type][$listtype]))
142 142
 				{
143 143
 					$listItem = $listMap[$url][$type][$listtype];
144 144
 					$refItem = $listItem->getRefItem();
145
-					unset( $listItems[ $listItem->getId() ] );
145
+					unset($listItems[$listItem->getId()]);
146 146
 				}
147 147
 				else
148 148
 				{
149
-					$listItem = $listManager->createItem()->setType( $listtype );
150
-					$refItem = $manager->createItem()->setType( $type );
149
+					$listItem = $listManager->createItem()->setType($listtype);
150
+					$refItem = $manager->createItem()->setType($type);
151 151
 				}
152 152
 
153
-				$listItem = $listItem->setPosition( $pos++ )->fromArray( $list );
154
-				$refItem = $refItem->setLabel( $url )->setPreview( $url )->fromArray( $list )->setUrl( $url );
153
+				$listItem = $listItem->setPosition($pos++)->fromArray($list);
154
+				$refItem = $refItem->setLabel($url)->setPreview($url)->fromArray($list)->setUrl($url);
155 155
 
156
-				$product->addListItem( 'media', $listItem, $refItem );
156
+				$product->addListItem('media', $listItem, $refItem);
157 157
 			}
158 158
 		}
159 159
 
160
-		$product->deleteListItems( $listItems, true );
160
+		$product->deleteListItems($listItems, true);
161 161
 
162
-		return $this->getObject()->process( $product, $data );
162
+		return $this->getObject()->process($product, $data);
163 163
 	}
164 164
 
165 165
 
@@ -169,22 +169,22 @@  discard block
 block discarded – undo
169 169
 	 * @param array $list Associative list of key/value pairs from the mapping
170 170
 	 * @return boolean True if valid, false if not
171 171
 	 */
172
-	protected function checkEntry( array $list )
172
+	protected function checkEntry(array $list)
173 173
 	{
174
-		if( $this->getValue( $list, 'media.url' ) === null ) {
174
+		if ($this->getValue($list, 'media.url') === null) {
175 175
 			return false;
176 176
 		}
177 177
 
178
-		if( ( $type = $this->getValue( $list, 'product.lists.type' ) ) && !isset( $this->listTypes[$type] ) )
178
+		if (($type = $this->getValue($list, 'product.lists.type')) && !isset($this->listTypes[$type]))
179 179
 		{
180
-			$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'product list' );
181
-			throw new \Aimeos\Controller\Common\Exception( $msg );
180
+			$msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'product list');
181
+			throw new \Aimeos\Controller\Common\Exception($msg);
182 182
 		}
183 183
 
184
-		if( ( $type = $this->getValue( $list, 'media.type' ) ) && !isset( $this->types[$type] ) )
184
+		if (($type = $this->getValue($list, 'media.type')) && !isset($this->types[$type]))
185 185
 		{
186
-			$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'media' );
187
-			throw new \Aimeos\Controller\Common\Exception( $msg );
186
+			$msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'media');
187
+			throw new \Aimeos\Controller\Common\Exception($msg);
188 188
 		}
189 189
 
190 190
 		return true;
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Processor/Price/Standard.php 2 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -81,8 +81,7 @@  discard block
 block discarded – undo
81 81
 			foreach( $manager->searchItems( $search ) as $item ) {
82 82
 				$this->listTypes[$item->getCode()] = $item->getCode();
83 83
 			}
84
-		}
85
-		else
84
+		} else
86 85
 		{
87 86
 			$this->listTypes = array_flip( $this->listTypes );
88 87
 		}
@@ -137,8 +136,7 @@  discard block
 block discarded – undo
137 136
 				$listItem = $listMap[$value][$type][$listtype];
138 137
 				$refItem = $listItem->getRefItem();
139 138
 				unset( $listItems[ $listItem->getId() ] );
140
-			}
141
-			else
139
+			} else
142 140
 			{
143 141
 				$listItem = $listManager->createItem()->setType( $listtype );
144 142
 				$refItem = $manager->createItem()->setType( $type );
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
44 44
 	 * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor
45 45
 	 */
46
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping,
47
-			\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null )
46
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
47
+			\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null)
48 48
 	{
49
-		parent::__construct( $context, $mapping, $object );
49
+		parent::__construct($context, $mapping, $object);
50 50
 
51 51
 		/** controller/common/product/import/csv/processor/price/listtypes
52 52
 		 * Names of the product list types for prices that are updated or removed
@@ -68,32 +68,32 @@  discard block
 block discarded – undo
68 68
 		 * @see controller/common/product/import/csv/processor/text/listtypes
69 69
 		 */
70 70
 		$key = 'controller/common/product/import/csv/processor/price/listtypes';
71
-		$this->listTypes = $context->getConfig()->get( $key );
71
+		$this->listTypes = $context->getConfig()->get($key);
72 72
 
73
-		if( $this->listTypes === null )
73
+		if ($this->listTypes === null)
74 74
 		{
75 75
 			$this->listTypes = [];
76
-			$manager = \Aimeos\MShop::create( $context, 'product/lists/type' );
76
+			$manager = \Aimeos\MShop::create($context, 'product/lists/type');
77 77
 
78
-			$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
79
-			$search->setConditions( $search->compare( '==', 'product.lists.type.domain', 'price' ) );
78
+			$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
79
+			$search->setConditions($search->compare('==', 'product.lists.type.domain', 'price'));
80 80
 
81
-			foreach( $manager->searchItems( $search ) as $item ) {
81
+			foreach ($manager->searchItems($search) as $item) {
82 82
 				$this->listTypes[$item->getCode()] = $item->getCode();
83 83
 			}
84 84
 		}
85 85
 		else
86 86
 		{
87
-			$this->listTypes = array_flip( $this->listTypes );
87
+			$this->listTypes = array_flip($this->listTypes);
88 88
 		}
89 89
 
90 90
 
91
-		$manager = \Aimeos\MShop::create( $context, 'price/type' );
91
+		$manager = \Aimeos\MShop::create($context, 'price/type');
92 92
 
93
-		$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
94
-		$search->setConditions( $search->compare( '==', 'price.type.domain', 'product' ) );
93
+		$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
94
+		$search->setConditions($search->compare('==', 'price.type.domain', 'product'));
95 95
 
96
-		foreach( $manager->searchItems( $search ) as $item ) {
96
+		foreach ($manager->searchItems($search) as $item) {
97 97
 			$this->types[$item->getCode()] = $item->getCode();
98 98
 		}
99 99
 	}
@@ -106,55 +106,55 @@  discard block
 block discarded – undo
106 106
 	 * @param array $data List of CSV fields with position as key and data as value
107 107
 	 * @return array List of data which hasn't been imported
108 108
 	 */
109
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
109
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
110 110
 	{
111
-		$listManager = \Aimeos\MShop::create( $this->getContext(), 'product/lists' );
112
-		$manager = \Aimeos\MShop::create( $this->getContext(), 'price' );
111
+		$listManager = \Aimeos\MShop::create($this->getContext(), 'product/lists');
112
+		$manager = \Aimeos\MShop::create($this->getContext(), 'price');
113 113
 
114 114
 		$listMap = [];
115
-		$map = $this->getMappedChunk( $data, $this->getMapping() );
116
-		$listItems = $product->getListItems( 'price', $this->listTypes );
115
+		$map = $this->getMappedChunk($data, $this->getMapping());
116
+		$listItems = $product->getListItems('price', $this->listTypes);
117 117
 
118
-		foreach( $listItems as $listItem )
118
+		foreach ($listItems as $listItem)
119 119
 		{
120
-			if( ( $refItem = $listItem->getRefItem() ) !== null ) {
121
-				$listMap[ $refItem->getValue() ][ $refItem->getType() ][ $listItem->getType() ] = $listItem;
120
+			if (($refItem = $listItem->getRefItem()) !== null) {
121
+				$listMap[$refItem->getValue()][$refItem->getType()][$listItem->getType()] = $listItem;
122 122
 			}
123 123
 		}
124 124
 
125
-		foreach( $map as $pos => $list )
125
+		foreach ($map as $pos => $list)
126 126
 		{
127
-			if( $this->checkEntry( $list ) === false ) {
127
+			if ($this->checkEntry($list) === false) {
128 128
 				continue;
129 129
 			}
130 130
 
131
-			$value = $this->getValue( $list, 'price.value', '0.00' );
132
-			$type = $this->getValue( $list, 'price.type', 'default' );
133
-			$listtype = $this->getValue( $list, 'product.lists.type', 'default' );
131
+			$value = $this->getValue($list, 'price.value', '0.00');
132
+			$type = $this->getValue($list, 'price.type', 'default');
133
+			$listtype = $this->getValue($list, 'product.lists.type', 'default');
134 134
 
135
-			if( isset( $listMap[$value][$type][$listtype] ) )
135
+			if (isset($listMap[$value][$type][$listtype]))
136 136
 			{
137 137
 				$listItem = $listMap[$value][$type][$listtype];
138 138
 				$refItem = $listItem->getRefItem();
139
-				unset( $listItems[ $listItem->getId() ] );
139
+				unset($listItems[$listItem->getId()]);
140 140
 			}
141 141
 			else
142 142
 			{
143
-				$listItem = $listManager->createItem()->setType( $listtype );
144
-				$refItem = $manager->createItem()->setType( $type );
143
+				$listItem = $listManager->createItem()->setType($listtype);
144
+				$refItem = $manager->createItem()->setType($type);
145 145
 			}
146 146
 
147
-			$listItem = $listItem->setPosition( $pos )->fromArray( $list );
147
+			$listItem = $listItem->setPosition($pos)->fromArray($list);
148 148
 
149
-			$label = $this->getValue( $list, 'price.currencyid', '' ) . ' ' . $this->getValue( $list, 'price.value', '' );
150
-			$refItem = $refItem->setLabel( $label )->fromArray( $list );
149
+			$label = $this->getValue($list, 'price.currencyid', '') . ' ' . $this->getValue($list, 'price.value', '');
150
+			$refItem = $refItem->setLabel($label)->fromArray($list);
151 151
 
152
-			$product->addListItem( 'price', $listItem, $refItem );
152
+			$product->addListItem('price', $listItem, $refItem);
153 153
 		}
154 154
 
155
-		$product->deleteListItems( $listItems, true );
155
+		$product->deleteListItems($listItems, true);
156 156
 
157
-		return $this->getObject()->process( $product, $data );
157
+		return $this->getObject()->process($product, $data);
158 158
 	}
159 159
 
160 160
 
@@ -164,22 +164,22 @@  discard block
 block discarded – undo
164 164
 	 * @param array $list Associative list of key/value pairs from the mapping
165 165
 	 * @return boolean True if valid, false if not
166 166
 	 */
167
-	protected function checkEntry( array $list )
167
+	protected function checkEntry(array $list)
168 168
 	{
169
-		if( $this->getValue( $list, 'price.value' ) === null ) {
169
+		if ($this->getValue($list, 'price.value') === null) {
170 170
 			return false;
171 171
 		}
172 172
 
173
-		if( ( $type = $this->getValue( $list, 'product.lists.type' ) ) && !isset( $this->listTypes[$type] ) )
173
+		if (($type = $this->getValue($list, 'product.lists.type')) && !isset($this->listTypes[$type]))
174 174
 		{
175
-			$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'product list' );
176
-			throw new \Aimeos\Controller\Common\Exception( $msg );
175
+			$msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'product list');
176
+			throw new \Aimeos\Controller\Common\Exception($msg);
177 177
 		}
178 178
 
179
-		if( ( $type = $this->getValue( $list, 'price.type' ) ) && !isset( $this->types[$type] ) )
179
+		if (($type = $this->getValue($list, 'price.type')) && !isset($this->types[$type]))
180 180
 		{
181
-			$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'price' );
182
-			throw new \Aimeos\Controller\Common\Exception( $msg );
181
+			$msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'price');
182
+			throw new \Aimeos\Controller\Common\Exception($msg);
183 183
 		}
184 184
 
185 185
 		return true;
Please login to merge, or discard this patch.
common/src/Controller/Common/Product/Import/Csv/Processor/Text/Standard.php 2 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -81,8 +81,7 @@  discard block
 block discarded – undo
81 81
 			foreach( $manager->searchItems( $search ) as $item ) {
82 82
 				$this->listTypes[$item->getCode()] = $item->getCode();
83 83
 			}
84
-		}
85
-		else
84
+		} else
86 85
 		{
87 86
 			$this->listTypes = array_flip( $this->listTypes );
88 87
 		}
@@ -137,8 +136,7 @@  discard block
 block discarded – undo
137 136
 				$listItem = $listMap[$content][$type][$listtype];
138 137
 				$refItem = $listItem->getRefItem();
139 138
 				unset( $listItems[ $listItem->getId() ] );
140
-			}
141
-			else
139
+			} else
142 140
 			{
143 141
 				$listItem = $listManager->createItem()->setType( $listtype );
144 142
 				$refItem = $manager->createItem()->setType( $type );
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
44 44
 	 * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor
45 45
 	 */
46
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping,
47
-			\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null )
46
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
47
+			\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null)
48 48
 	{
49
-		parent::__construct( $context, $mapping, $object );
49
+		parent::__construct($context, $mapping, $object);
50 50
 
51 51
 		/** controller/common/product/import/csv/processor/text/listtypes
52 52
 		 * Names of the product list types for texts that are updated or removed
@@ -68,32 +68,32 @@  discard block
 block discarded – undo
68 68
 		 * @see controller/common/product/import/csv/processor/product/listtypes
69 69
 		 */
70 70
 		$key = 'controller/common/product/import/csv/processor/text/listtypes';
71
-		$this->listTypes = $context->getConfig()->get( $key );
71
+		$this->listTypes = $context->getConfig()->get($key);
72 72
 
73
-		if( $this->listTypes === null )
73
+		if ($this->listTypes === null)
74 74
 		{
75 75
 			$this->listTypes = [];
76
-			$manager = \Aimeos\MShop::create( $context, 'product/lists/type' );
76
+			$manager = \Aimeos\MShop::create($context, 'product/lists/type');
77 77
 
78
-			$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
79
-			$search->setConditions( $search->compare( '==', 'product.lists.type.domain', 'text' ) );
78
+			$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
79
+			$search->setConditions($search->compare('==', 'product.lists.type.domain', 'text'));
80 80
 
81
-			foreach( $manager->searchItems( $search ) as $item ) {
81
+			foreach ($manager->searchItems($search) as $item) {
82 82
 				$this->listTypes[$item->getCode()] = $item->getCode();
83 83
 			}
84 84
 		}
85 85
 		else
86 86
 		{
87
-			$this->listTypes = array_flip( $this->listTypes );
87
+			$this->listTypes = array_flip($this->listTypes);
88 88
 		}
89 89
 
90 90
 
91
-		$manager = \Aimeos\MShop::create( $context, 'text/type' );
91
+		$manager = \Aimeos\MShop::create($context, 'text/type');
92 92
 
93
-		$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
94
-		$search->setConditions( $search->compare( '==', 'text.type.domain', 'product' ) );
93
+		$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
94
+		$search->setConditions($search->compare('==', 'text.type.domain', 'product'));
95 95
 
96
-		foreach( $manager->searchItems( $search ) as $item ) {
96
+		foreach ($manager->searchItems($search) as $item) {
97 97
 			$this->types[$item->getCode()] = $item->getCode();
98 98
 		}
99 99
 	}
@@ -106,55 +106,55 @@  discard block
 block discarded – undo
106 106
 	 * @param array $data List of CSV fields with position as key and data as value
107 107
 	 * @return array List of data which hasn't been imported
108 108
 	 */
109
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
109
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
110 110
 	{
111
-		$listManager = \Aimeos\MShop::create( $this->getContext(), 'product/lists' );
112
-		$manager = \Aimeos\MShop::create( $this->getContext(), 'text' );
111
+		$listManager = \Aimeos\MShop::create($this->getContext(), 'product/lists');
112
+		$manager = \Aimeos\MShop::create($this->getContext(), 'text');
113 113
 
114 114
 		$listMap = [];
115
-		$map = $this->getMappedChunk( $data, $this->getMapping() );
116
-		$listItems = $product->getListItems( 'text', $this->listTypes );
115
+		$map = $this->getMappedChunk($data, $this->getMapping());
116
+		$listItems = $product->getListItems('text', $this->listTypes);
117 117
 
118
-		foreach( $listItems as $listItem )
118
+		foreach ($listItems as $listItem)
119 119
 		{
120
-			if( ( $refItem = $listItem->getRefItem() ) !== null ) {
121
-				$listMap[ $refItem->getContent() ][ $refItem->getType() ][ $listItem->getType() ] = $listItem;
120
+			if (($refItem = $listItem->getRefItem()) !== null) {
121
+				$listMap[$refItem->getContent()][$refItem->getType()][$listItem->getType()] = $listItem;
122 122
 			}
123 123
 		}
124 124
 
125
-		foreach( $map as $pos => $list )
125
+		foreach ($map as $pos => $list)
126 126
 		{
127
-			if( $this->checkEntry( $list ) === false ) {
127
+			if ($this->checkEntry($list) === false) {
128 128
 				continue;
129 129
 			}
130 130
 
131
-			$type = $this->getValue( $list, 'text.type', 'name' );
132
-			$listtype = $this->getValue( $list, 'product.lists.type', 'default' );
133
-			$content = $this->getValue( $list, 'text.content', '' );
131
+			$type = $this->getValue($list, 'text.type', 'name');
132
+			$listtype = $this->getValue($list, 'product.lists.type', 'default');
133
+			$content = $this->getValue($list, 'text.content', '');
134 134
 
135
-			if( isset( $listMap[$content][$type][$listtype] ) )
135
+			if (isset($listMap[$content][$type][$listtype]))
136 136
 			{
137 137
 				$listItem = $listMap[$content][$type][$listtype];
138 138
 				$refItem = $listItem->getRefItem();
139
-				unset( $listItems[ $listItem->getId() ] );
139
+				unset($listItems[$listItem->getId()]);
140 140
 			}
141 141
 			else
142 142
 			{
143
-				$listItem = $listManager->createItem()->setType( $listtype );
144
-				$refItem = $manager->createItem()->setType( $type );
143
+				$listItem = $listManager->createItem()->setType($listtype);
144
+				$refItem = $manager->createItem()->setType($type);
145 145
 			}
146 146
 
147
-			$listItem = $listItem->setPosition( $pos )->fromArray( $list );
147
+			$listItem = $listItem->setPosition($pos)->fromArray($list);
148 148
 
149
-			$label = mb_strcut( $this->getValue( $list, 'text.content', '' ), 0, 255 );
150
-			$refItem = $refItem->setLabel( $label )->fromArray( $list );
149
+			$label = mb_strcut($this->getValue($list, 'text.content', ''), 0, 255);
150
+			$refItem = $refItem->setLabel($label)->fromArray($list);
151 151
 
152
-			$product->addListItem( 'text', $listItem, $refItem );
152
+			$product->addListItem('text', $listItem, $refItem);
153 153
 		}
154 154
 
155
-		$product->deleteListItems( $listItems, true );
155
+		$product->deleteListItems($listItems, true);
156 156
 
157
-		return $this->getObject()->process( $product, $data );
157
+		return $this->getObject()->process($product, $data);
158 158
 	}
159 159
 
160 160
 
@@ -164,22 +164,22 @@  discard block
 block discarded – undo
164 164
 	 * @param array $list Associative list of key/value pairs from the mapping
165 165
 	 * @return boolean True if valid, false if not
166 166
 	 */
167
-	protected function checkEntry( array $list )
167
+	protected function checkEntry(array $list)
168 168
 	{
169
-		if( $this->getValue( $list, 'text.content' ) === null ) {
169
+		if ($this->getValue($list, 'text.content') === null) {
170 170
 			return false;
171 171
 		}
172 172
 
173
-		if( ( $type = $this->getValue( $list, 'product.lists.type' ) ) && !isset( $this->listTypes[$type] ) )
173
+		if (($type = $this->getValue($list, 'product.lists.type')) && !isset($this->listTypes[$type]))
174 174
 		{
175
-			$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'product list' );
176
-			throw new \Aimeos\Controller\Common\Exception( $msg );
175
+			$msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'product list');
176
+			throw new \Aimeos\Controller\Common\Exception($msg);
177 177
 		}
178 178
 
179
-		if( ( $type = $this->getValue( $list, 'text.type' ) ) && !isset( $this->types[$type] ) )
179
+		if (($type = $this->getValue($list, 'text.type')) && !isset($this->types[$type]))
180 180
 		{
181
-			$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'text' );
182
-			throw new \Aimeos\Controller\Common\Exception( $msg );
181
+			$msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'text');
182
+			throw new \Aimeos\Controller\Common\Exception($msg);
183 183
 		}
184 184
 
185 185
 		return true;
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Processor/Attribute/Standard.php 2 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -82,8 +82,7 @@  discard block
 block discarded – undo
82 82
 			foreach( $manager->searchItems( $search ) as $item ) {
83 83
 				$this->listTypes[$item->getCode()] = $item->getCode();
84 84
 			}
85
-		}
86
-		else
85
+		} else
87 86
 		{
88 87
 			$this->listTypes = array_flip( $this->listTypes );
89 88
 		}
@@ -144,8 +143,7 @@  discard block
 block discarded – undo
144 143
 				{
145 144
 					$listItem = $listMap[$code][$listtype];
146 145
 					unset( $listItems[ $listItem->getId() ] );
147
-				}
148
-				else
146
+				} else
149 147
 				{
150 148
 					$listItem = $listManager->createItem()->setType( $listtype );
151 149
 				}
Please login to merge, or discard this patch.
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -44,10 +44,10 @@  discard block
 block discarded – undo
44 44
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
45 45
 	 * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor
46 46
 	 */
47
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping,
48
-		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null )
47
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
48
+		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null)
49 49
 	{
50
-		parent::__construct( $context, $mapping, $object );
50
+		parent::__construct($context, $mapping, $object);
51 51
 
52 52
 		/** controller/common/product/import/csv/processor/attribute/listtypes
53 53
 		 * Names of the product list types for attributes that are updated or removed
@@ -69,37 +69,37 @@  discard block
 block discarded – undo
69 69
 		 * @see controller/common/product/import/csv/processor/text/listtypes
70 70
 		 */
71 71
 		$key = 'controller/common/product/import/csv/processor/attribute/listtypes';
72
-		$this->listTypes = $context->getConfig()->get( $key );
72
+		$this->listTypes = $context->getConfig()->get($key);
73 73
 
74
-		if( $this->listTypes === null )
74
+		if ($this->listTypes === null)
75 75
 		{
76 76
 			$this->listTypes = [];
77
-			$manager = \Aimeos\MShop::create( $context, 'product/lists/type' );
77
+			$manager = \Aimeos\MShop::create($context, 'product/lists/type');
78 78
 
79
-			$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
80
-			$search->setConditions( $search->compare( '==', 'product.lists.type.domain', 'attribute' ) );
79
+			$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
80
+			$search->setConditions($search->compare('==', 'product.lists.type.domain', 'attribute'));
81 81
 
82
-			foreach( $manager->searchItems( $search ) as $item ) {
82
+			foreach ($manager->searchItems($search) as $item) {
83 83
 				$this->listTypes[$item->getCode()] = $item->getCode();
84 84
 			}
85 85
 		}
86 86
 		else
87 87
 		{
88
-			$this->listTypes = array_flip( $this->listTypes );
88
+			$this->listTypes = array_flip($this->listTypes);
89 89
 		}
90 90
 
91 91
 
92
-		$manager = \Aimeos\MShop::create( $context, 'attribute/type' );
92
+		$manager = \Aimeos\MShop::create($context, 'attribute/type');
93 93
 
94
-		$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
95
-		$search->setConditions( $search->compare( '==', 'attribute.type.domain', 'product' ) );
94
+		$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
95
+		$search->setConditions($search->compare('==', 'attribute.type.domain', 'product'));
96 96
 
97
-		foreach( $manager->searchItems( $search ) as $item ) {
97
+		foreach ($manager->searchItems($search) as $item) {
98 98
 			$this->types[$item->getCode()] = $item->getCode();
99 99
 		}
100 100
 
101 101
 
102
-		$this->cache = $this->getCache( 'attribute' );
102
+		$this->cache = $this->getCache('attribute');
103 103
 	}
104 104
 
105 105
 
@@ -110,58 +110,58 @@  discard block
 block discarded – undo
110 110
 	 * @param array $data List of CSV fields with position as key and data as value
111 111
 	 * @return array List of data which hasn't been imported
112 112
 	 */
113
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
113
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
114 114
 	{
115 115
 		$context = $this->getContext();
116
-		$listManager = \Aimeos\MShop::create( $context, 'product/lists' );
117
-		$separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" );
116
+		$listManager = \Aimeos\MShop::create($context, 'product/lists');
117
+		$separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n");
118 118
 
119 119
 		$listMap = [];
120
-		$map = $this->getMappedChunk( $data, $this->getMapping() );
121
-		$listItems = $product->getListItems( 'attribute', $this->listTypes );
120
+		$map = $this->getMappedChunk($data, $this->getMapping());
121
+		$listItems = $product->getListItems('attribute', $this->listTypes);
122 122
 
123
-		foreach( $listItems as $listItem )
123
+		foreach ($listItems as $listItem)
124 124
 		{
125
-			if( ( $refItem = $listItem->getRefItem() ) !== null ) {
126
-				$listMap[ $refItem->getCode() ][ $listItem->getType() ] = $listItem;
125
+			if (($refItem = $listItem->getRefItem()) !== null) {
126
+				$listMap[$refItem->getCode()][$listItem->getType()] = $listItem;
127 127
 			}
128 128
 		}
129 129
 
130
-		foreach( $map as $pos => $list )
130
+		foreach ($map as $pos => $list)
131 131
 		{
132
-			if( $this->checkEntry( $list ) === false ) {
132
+			if ($this->checkEntry($list) === false) {
133 133
 				continue;
134 134
 			}
135 135
 
136
-			$codes = explode( $separator, $this->getValue( $list, 'attribute.code', '' ) );
136
+			$codes = explode($separator, $this->getValue($list, 'attribute.code', ''));
137 137
 
138
-			foreach( $codes as $code )
138
+			foreach ($codes as $code)
139 139
 			{
140
-				$code = trim( $code );
141
-				$listtype = $this->getValue( $list, 'product.lists.type', 'default' );
140
+				$code = trim($code);
141
+				$listtype = $this->getValue($list, 'product.lists.type', 'default');
142 142
 
143
-				if( isset( $listMap[$code][$listtype] ) )
143
+				if (isset($listMap[$code][$listtype]))
144 144
 				{
145 145
 					$listItem = $listMap[$code][$listtype];
146
-					unset( $listItems[ $listItem->getId() ] );
146
+					unset($listItems[$listItem->getId()]);
147 147
 				}
148 148
 				else
149 149
 				{
150
-					$listItem = $listManager->createItem()->setType( $listtype );
150
+					$listItem = $listManager->createItem()->setType($listtype);
151 151
 				}
152 152
 
153
-				$listItem = $listItem->setPosition( $pos )->fromArray( $list );
153
+				$listItem = $listItem->setPosition($pos)->fromArray($list);
154 154
 
155
-				$attrItem = $this->getAttributeItem( $code, $this->getValue( $list, 'attribute.type' ) );
156
-				$attrItem = $attrItem->setCode( $code )->fromArray( $list );
155
+				$attrItem = $this->getAttributeItem($code, $this->getValue($list, 'attribute.type'));
156
+				$attrItem = $attrItem->setCode($code)->fromArray($list);
157 157
 
158
-				$product->addListItem( 'attribute', $listItem, $attrItem );
158
+				$product->addListItem('attribute', $listItem, $attrItem);
159 159
 			}
160 160
 		}
161 161
 
162
-		$product->deleteListItems( $listItems );
162
+		$product->deleteListItems($listItems);
163 163
 
164
-		return $this->getObject()->process( $product, $data );
164
+		return $this->getObject()->process($product, $data);
165 165
 	}
166 166
 
167 167
 
@@ -171,22 +171,22 @@  discard block
 block discarded – undo
171 171
 	 * @param array $list Associative list of key/value pairs from the mapped data
172 172
 	 * @return boolean True if the entry is valid, false if not
173 173
 	 */
174
-	protected function checkEntry( array $list )
174
+	protected function checkEntry(array $list)
175 175
 	{
176
-		if( $this->getValue( $list, 'attribute.code' ) === null ) {
176
+		if ($this->getValue($list, 'attribute.code') === null) {
177 177
 			return false;
178 178
 		}
179 179
 
180
-		if( ( $type = $this->getValue( $list, 'product.lists.type' ) ) && !isset( $this->listTypes[$type] ) )
180
+		if (($type = $this->getValue($list, 'product.lists.type')) && !isset($this->listTypes[$type]))
181 181
 		{
182
-			$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'product list' );
183
-			throw new \Aimeos\Controller\Common\Exception( $msg );
182
+			$msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'product list');
183
+			throw new \Aimeos\Controller\Common\Exception($msg);
184 184
 		}
185 185
 
186
-		if( ( $type = $this->getValue( $list, 'attribute.type' ) ) && !isset( $this->types[$type] ) )
186
+		if (($type = $this->getValue($list, 'attribute.type')) && !isset($this->types[$type]))
187 187
 		{
188
-			$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'attribute' );
189
-			throw new \Aimeos\Controller\Common\Exception( $msg );
188
+			$msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'attribute');
189
+			throw new \Aimeos\Controller\Common\Exception($msg);
190 190
 		}
191 191
 
192 192
 		return true;
@@ -200,22 +200,22 @@  discard block
 block discarded – undo
200 200
 	 * @param string $type Attribute type
201 201
 	 * @return \Aimeos\MShop\Attribute\Item\Iface Attribute item object
202 202
 	 */
203
-	protected function getAttributeItem( $code, $type )
203
+	protected function getAttributeItem($code, $type)
204 204
 	{
205
-		if( ( $item = $this->cache->get( $code, $type ) ) === null )
205
+		if (($item = $this->cache->get($code, $type)) === null)
206 206
 		{
207
-			$manager = \Aimeos\MShop::create( $this->getContext(), 'attribute' );
207
+			$manager = \Aimeos\MShop::create($this->getContext(), 'attribute');
208 208
 
209 209
 			$item = $manager->createItem();
210
-			$item->setType( $type );
211
-			$item->setDomain( 'product' );
212
-			$item->setLabel( $code );
213
-			$item->setCode( $code );
214
-			$item->setStatus( 1 );
210
+			$item->setType($type);
211
+			$item->setDomain('product');
212
+			$item->setLabel($code);
213
+			$item->setCode($code);
214
+			$item->setStatus(1);
215 215
 
216
-			$item = $manager->saveItem( $item );
216
+			$item = $manager->saveItem($item);
217 217
 
218
-			$this->cache->set( $item );
218
+			$this->cache->set($item);
219 219
 		}
220 220
 
221 221
 		return $item;
Please login to merge, or discard this patch.
src/Controller/Common/Catalog/Import/Csv/Processor/Media/Standard.php 2 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -81,8 +81,7 @@  discard block
 block discarded – undo
81 81
 			foreach( $manager->searchItems( $search ) as $item ) {
82 82
 				$this->listTypes[$item->getCode()] = $item->getCode();
83 83
 			}
84
-		}
85
-		else
84
+		} else
86 85
 		{
87 86
 			$this->listTypes = array_flip( $this->listTypes );
88 87
 		}
@@ -143,8 +142,7 @@  discard block
 block discarded – undo
143 142
 					$listItem = $listMap[$url][$type][$listtype];
144 143
 					$refItem = $listItem->getRefItem();
145 144
 					unset( $listItems[ $listItem->getId() ] );
146
-				}
147
-				else
145
+				} else
148 146
 				{
149 147
 					$listItem = $listManager->createItem()->setType( $listtype );
150 148
 					$refItem = $manager->createItem()->setType( $type );
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
44 44
 	 * @param \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $object Decorated processor
45 45
 	 */
46
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping,
47
-			\Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $object = null )
46
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
47
+			\Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $object = null)
48 48
 	{
49
-		parent::__construct( $context, $mapping, $object );
49
+		parent::__construct($context, $mapping, $object);
50 50
 
51 51
 		/** controller/common/catalog/import/csv/processor/media/listtypes
52 52
 		 * Names of the catalog list types for media that are updated or removed
@@ -68,32 +68,32 @@  discard block
 block discarded – undo
68 68
 		 * @see controller/common/catalog/import/csv/processor/text/listtypes
69 69
 		 */
70 70
 		$key = 'controller/common/catalog/import/csv/processor/media/listtypes';
71
-		$this->listTypes = $context->getConfig()->get( $key );
71
+		$this->listTypes = $context->getConfig()->get($key);
72 72
 
73
-		if( $this->listTypes === null )
73
+		if ($this->listTypes === null)
74 74
 		{
75 75
 			$this->listTypes = [];
76
-			$manager = \Aimeos\MShop::create( $context, 'catalog/lists/type' );
76
+			$manager = \Aimeos\MShop::create($context, 'catalog/lists/type');
77 77
 
78
-			$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
79
-			$search->setConditions( $search->compare( '==', 'catalog.lists.type.domain', 'media' ) );
78
+			$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
79
+			$search->setConditions($search->compare('==', 'catalog.lists.type.domain', 'media'));
80 80
 
81
-			foreach( $manager->searchItems( $search ) as $item ) {
81
+			foreach ($manager->searchItems($search) as $item) {
82 82
 				$this->listTypes[$item->getCode()] = $item->getCode();
83 83
 			}
84 84
 		}
85 85
 		else
86 86
 		{
87
-			$this->listTypes = array_flip( $this->listTypes );
87
+			$this->listTypes = array_flip($this->listTypes);
88 88
 		}
89 89
 
90 90
 
91
-		$manager = \Aimeos\MShop::create( $context, 'media/type' );
91
+		$manager = \Aimeos\MShop::create($context, 'media/type');
92 92
 
93
-		$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
94
-		$search->setConditions( $search->compare( '==', 'media.type.domain', 'catalog' ) );
93
+		$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
94
+		$search->setConditions($search->compare('==', 'media.type.domain', 'catalog'));
95 95
 
96
-		foreach( $manager->searchItems( $search ) as $item ) {
96
+		foreach ($manager->searchItems($search) as $item) {
97 97
 			$this->types[$item->getCode()] = $item->getCode();
98 98
 		}
99 99
 	}
@@ -106,58 +106,58 @@  discard block
 block discarded – undo
106 106
 	 * @param array $data List of CSV fields with position as key and data as value
107 107
 	 * @return array List of data which hasn't been imported
108 108
 	 */
109
-	public function process( \Aimeos\MShop\Catalog\Item\Iface $catalog, array $data )
109
+	public function process(\Aimeos\MShop\Catalog\Item\Iface $catalog, array $data)
110 110
 	{
111 111
 		$context = $this->getContext();
112
-		$manager = \Aimeos\MShop::create( $context, 'media' );
113
-		$listManager = \Aimeos\MShop::create( $context, 'catalog/lists' );
114
-		$separator = $context->getConfig()->get( 'controller/common/catalog/import/csv/separator', "\n" );
112
+		$manager = \Aimeos\MShop::create($context, 'media');
113
+		$listManager = \Aimeos\MShop::create($context, 'catalog/lists');
114
+		$separator = $context->getConfig()->get('controller/common/catalog/import/csv/separator', "\n");
115 115
 
116 116
 		$listMap = [];
117
-		$map = $this->getMappedChunk( $data, $this->getMapping() );
118
-		$listItems = $catalog->getListItems( 'media', $this->listTypes );
117
+		$map = $this->getMappedChunk($data, $this->getMapping());
118
+		$listItems = $catalog->getListItems('media', $this->listTypes);
119 119
 
120
-		foreach( $listItems as $listItem )
120
+		foreach ($listItems as $listItem)
121 121
 		{
122
-			if( ( $refItem = $listItem->getRefItem() ) !== null ) {
123
-				$listMap[ $refItem->getUrl() ][ $refItem->getType() ][ $listItem->getType() ] = $listItem;
122
+			if (($refItem = $listItem->getRefItem()) !== null) {
123
+				$listMap[$refItem->getUrl()][$refItem->getType()][$listItem->getType()] = $listItem;
124 124
 			}
125 125
 		}
126 126
 
127
-		foreach( $map as $pos => $list )
127
+		foreach ($map as $pos => $list)
128 128
 		{
129
-			if( $this->checkEntry( $list ) === false ) {
129
+			if ($this->checkEntry($list) === false) {
130 130
 				continue;
131 131
 			}
132 132
 
133
-			$type = $this->getValue( $list, 'media.type', 'default' );
134
-			$listtype = $this->getValue( $list, 'catalog.lists.type', 'default' );
135
-			$urls = explode( $separator, $this->getValue( $list, 'media.url', '' ) );
133
+			$type = $this->getValue($list, 'media.type', 'default');
134
+			$listtype = $this->getValue($list, 'catalog.lists.type', 'default');
135
+			$urls = explode($separator, $this->getValue($list, 'media.url', ''));
136 136
 
137
-			foreach( $urls as $url )
137
+			foreach ($urls as $url)
138 138
 			{
139
-				if( isset( $listMap[$url][$type][$listtype] ) )
139
+				if (isset($listMap[$url][$type][$listtype]))
140 140
 				{
141 141
 					$listItem = $listMap[$url][$type][$listtype];
142 142
 					$refItem = $listItem->getRefItem();
143
-					unset( $listItems[ $listItem->getId() ] );
143
+					unset($listItems[$listItem->getId()]);
144 144
 				}
145 145
 				else
146 146
 				{
147
-					$listItem = $listManager->createItem()->setType( $listtype );
148
-					$refItem = $manager->createItem()->setType( $type );
147
+					$listItem = $listManager->createItem()->setType($listtype);
148
+					$refItem = $manager->createItem()->setType($type);
149 149
 				}
150 150
 
151
-				$listItem = $listItem->setPosition( $pos++ )->fromArray( $list );
152
-				$refItem = $refItem->setLabel( $url )->setPreview( $url )->fromArray( $list )->setUrl( $url );
151
+				$listItem = $listItem->setPosition($pos++)->fromArray($list);
152
+				$refItem = $refItem->setLabel($url)->setPreview($url)->fromArray($list)->setUrl($url);
153 153
 
154
-				$catalog->addListItem( 'media', $listItem, $refItem );
154
+				$catalog->addListItem('media', $listItem, $refItem);
155 155
 			}
156 156
 		}
157 157
 
158
-		$catalog->deleteListItems( $listItems, true );
158
+		$catalog->deleteListItems($listItems, true);
159 159
 
160
-		return $this->getObject()->process( $catalog, $data );
160
+		return $this->getObject()->process($catalog, $data);
161 161
 	}
162 162
 
163 163
 
@@ -167,22 +167,22 @@  discard block
 block discarded – undo
167 167
 	 * @param array $list Associative list of key/value pairs from the mapping
168 168
 	 * @return boolean True if valid, false if not
169 169
 	 */
170
-	protected function checkEntry( array $list )
170
+	protected function checkEntry(array $list)
171 171
 	{
172
-		if( $this->getValue( $list, 'media.url' ) === null ) {
172
+		if ($this->getValue($list, 'media.url') === null) {
173 173
 			return false;
174 174
 		}
175 175
 
176
-		if( ( $type = $this->getValue( $list, 'catalog.lists.type' ) ) && !isset( $this->listTypes[$type] ) )
176
+		if (($type = $this->getValue($list, 'catalog.lists.type')) && !isset($this->listTypes[$type]))
177 177
 		{
178
-			$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'catalog list' );
179
-			throw new \Aimeos\Controller\Common\Exception( $msg );
178
+			$msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'catalog list');
179
+			throw new \Aimeos\Controller\Common\Exception($msg);
180 180
 		}
181 181
 
182
-		if( ( $type = $this->getValue( $list, 'media.type' ) ) && !isset( $this->types[$type] ) )
182
+		if (($type = $this->getValue($list, 'media.type')) && !isset($this->types[$type]))
183 183
 		{
184
-			$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'media' );
185
-			throw new \Aimeos\Controller\Common\Exception( $msg );
184
+			$msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'media');
185
+			throw new \Aimeos\Controller\Common\Exception($msg);
186 186
 		}
187 187
 
188 188
 		return true;
Please login to merge, or discard this patch.
common/src/Controller/Common/Catalog/Import/Csv/Processor/Text/Standard.php 2 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -81,8 +81,7 @@  discard block
 block discarded – undo
81 81
 			foreach( $manager->searchItems( $search ) as $item ) {
82 82
 				$this->listTypes[$item->getCode()] = $item->getCode();
83 83
 			}
84
-		}
85
-		else
84
+		} else
86 85
 		{
87 86
 			$this->listTypes = array_flip( $this->listTypes );
88 87
 		}
@@ -137,8 +136,7 @@  discard block
 block discarded – undo
137 136
 				$listItem = $listMap[$content][$type][$listtype];
138 137
 				$refItem = $listItem->getRefItem();
139 138
 				unset( $listItems[ $listItem->getId() ] );
140
-			}
141
-			else
139
+			} else
142 140
 			{
143 141
 				$listItem = $listManager->createItem()->setType( $listtype );
144 142
 				$refItem = $manager->createItem()->setType( $type );
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
44 44
 	 * @param \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $object Decorated processor
45 45
 	 */
46
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping,
47
-			\Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $object = null )
46
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
47
+			\Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $object = null)
48 48
 	{
49
-		parent::__construct( $context, $mapping, $object );
49
+		parent::__construct($context, $mapping, $object);
50 50
 
51 51
 		/** controller/common/catalog/import/csv/processor/text/listtypes
52 52
 		 * Names of the catalog list types for texts that are updated or removed
@@ -68,32 +68,32 @@  discard block
 block discarded – undo
68 68
 		 * @see controller/common/catalog/import/csv/processor/catalog/listtypes
69 69
 		 */
70 70
 		$key = 'controller/common/catalog/import/csv/processor/text/listtypes';
71
-		$this->listTypes = $context->getConfig()->get( $key );
71
+		$this->listTypes = $context->getConfig()->get($key);
72 72
 
73
-		if( $this->listTypes === null )
73
+		if ($this->listTypes === null)
74 74
 		{
75 75
 			$this->listTypes = [];
76
-			$manager = \Aimeos\MShop::create( $context, 'catalog/lists/type' );
76
+			$manager = \Aimeos\MShop::create($context, 'catalog/lists/type');
77 77
 
78
-			$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
79
-			$search->setConditions( $search->compare( '==', 'catalog.lists.type.domain', 'text' ) );
78
+			$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
79
+			$search->setConditions($search->compare('==', 'catalog.lists.type.domain', 'text'));
80 80
 
81
-			foreach( $manager->searchItems( $search ) as $item ) {
81
+			foreach ($manager->searchItems($search) as $item) {
82 82
 				$this->listTypes[$item->getCode()] = $item->getCode();
83 83
 			}
84 84
 		}
85 85
 		else
86 86
 		{
87
-			$this->listTypes = array_flip( $this->listTypes );
87
+			$this->listTypes = array_flip($this->listTypes);
88 88
 		}
89 89
 
90 90
 
91
-		$manager = \Aimeos\MShop::create( $context, 'text/type' );
91
+		$manager = \Aimeos\MShop::create($context, 'text/type');
92 92
 
93
-		$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
94
-		$search->setConditions( $search->compare( '==', 'text.type.domain', 'catalog' ) );
93
+		$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
94
+		$search->setConditions($search->compare('==', 'text.type.domain', 'catalog'));
95 95
 
96
-		foreach( $manager->searchItems( $search ) as $item ) {
96
+		foreach ($manager->searchItems($search) as $item) {
97 97
 			$this->types[$item->getCode()] = $item->getCode();
98 98
 		}
99 99
 	}
@@ -106,55 +106,55 @@  discard block
 block discarded – undo
106 106
 	 * @param array $data List of CSV fields with position as key and data as value
107 107
 	 * @return array List of data which hasn't been imported
108 108
 	 */
109
-	public function process( \Aimeos\MShop\Catalog\Item\Iface $catalog, array $data )
109
+	public function process(\Aimeos\MShop\Catalog\Item\Iface $catalog, array $data)
110 110
 	{
111
-		$listManager = \Aimeos\MShop::create( $this->getContext(), 'catalog/lists' );
112
-		$manager = \Aimeos\MShop::create( $this->getContext(), 'text' );
111
+		$listManager = \Aimeos\MShop::create($this->getContext(), 'catalog/lists');
112
+		$manager = \Aimeos\MShop::create($this->getContext(), 'text');
113 113
 
114 114
 		$listMap = [];
115
-		$map = $this->getMappedChunk( $data, $this->getMapping() );
116
-		$listItems = $catalog->getListItems( 'text', $this->listTypes );
115
+		$map = $this->getMappedChunk($data, $this->getMapping());
116
+		$listItems = $catalog->getListItems('text', $this->listTypes);
117 117
 
118
-		foreach( $listItems as $listItem )
118
+		foreach ($listItems as $listItem)
119 119
 		{
120
-			if( ( $refItem = $listItem->getRefItem() ) !== null ) {
121
-				$listMap[ $refItem->getContent() ][ $refItem->getType() ][ $listItem->getType() ] = $listItem;
120
+			if (($refItem = $listItem->getRefItem()) !== null) {
121
+				$listMap[$refItem->getContent()][$refItem->getType()][$listItem->getType()] = $listItem;
122 122
 			}
123 123
 		}
124 124
 
125
-		foreach( $map as $pos => $list )
125
+		foreach ($map as $pos => $list)
126 126
 		{
127
-			if( $this->checkEntry( $list ) === false ) {
127
+			if ($this->checkEntry($list) === false) {
128 128
 				continue;
129 129
 			}
130 130
 
131
-			$type = $this->getValue( $list, 'text.type', 'name' );
132
-			$listtype = $this->getValue( $list, 'catalog.lists.type', 'default' );
133
-			$content = $this->getValue( $list, 'text.content', '' );
131
+			$type = $this->getValue($list, 'text.type', 'name');
132
+			$listtype = $this->getValue($list, 'catalog.lists.type', 'default');
133
+			$content = $this->getValue($list, 'text.content', '');
134 134
 
135
-			if( isset( $listMap[$content][$type][$listtype] ) )
135
+			if (isset($listMap[$content][$type][$listtype]))
136 136
 			{
137 137
 				$listItem = $listMap[$content][$type][$listtype];
138 138
 				$refItem = $listItem->getRefItem();
139
-				unset( $listItems[ $listItem->getId() ] );
139
+				unset($listItems[$listItem->getId()]);
140 140
 			}
141 141
 			else
142 142
 			{
143
-				$listItem = $listManager->createItem()->setType( $listtype );
144
-				$refItem = $manager->createItem()->setType( $type );
143
+				$listItem = $listManager->createItem()->setType($listtype);
144
+				$refItem = $manager->createItem()->setType($type);
145 145
 			}
146 146
 
147
-			$listItem = $listItem->setPosition( $pos )->fromArray( $list );
147
+			$listItem = $listItem->setPosition($pos)->fromArray($list);
148 148
 
149
-			$label = mb_strcut( $this->getValue( $list, 'text.content', '' ), 0, 255 );
150
-			$refItem = $refItem->setLabel( $label )->fromArray( $list );
149
+			$label = mb_strcut($this->getValue($list, 'text.content', ''), 0, 255);
150
+			$refItem = $refItem->setLabel($label)->fromArray($list);
151 151
 
152
-			$catalog->addListItem( 'text', $listItem, $refItem );
152
+			$catalog->addListItem('text', $listItem, $refItem);
153 153
 		}
154 154
 
155
-		$catalog->deleteListItems( $listItems, true );
155
+		$catalog->deleteListItems($listItems, true);
156 156
 
157
-		return $this->getObject()->process( $catalog, $data );
157
+		return $this->getObject()->process($catalog, $data);
158 158
 	}
159 159
 
160 160
 
@@ -164,22 +164,22 @@  discard block
 block discarded – undo
164 164
 	 * @param array $list Associative list of key/value pairs from the mapping
165 165
 	 * @return boolean True if valid, false if not
166 166
 	 */
167
-	protected function checkEntry( array $list )
167
+	protected function checkEntry(array $list)
168 168
 	{
169
-		if( $this->getValue( $list, 'text.content' ) === null ) {
169
+		if ($this->getValue($list, 'text.content') === null) {
170 170
 			return false;
171 171
 		}
172 172
 
173
-		if( ( $type = $this->getValue( $list, 'catalog.lists.type' ) ) && !isset( $this->listTypes[$type] ) )
173
+		if (($type = $this->getValue($list, 'catalog.lists.type')) && !isset($this->listTypes[$type]))
174 174
 		{
175
-			$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'catalog list' );
176
-			throw new \Aimeos\Controller\Common\Exception( $msg );
175
+			$msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'catalog list');
176
+			throw new \Aimeos\Controller\Common\Exception($msg);
177 177
 		}
178 178
 
179
-		if( ( $type = $this->getValue( $list, 'text.type' ) ) && !isset( $this->types[$type] ) )
179
+		if (($type = $this->getValue($list, 'text.type')) && !isset($this->types[$type]))
180 180
 		{
181
-			$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'text' );
182
-			throw new \Aimeos\Controller\Common\Exception( $msg );
181
+			$msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'text');
182
+			throw new \Aimeos\Controller\Common\Exception($msg);
183 183
 		}
184 184
 
185 185
 		return true;
Please login to merge, or discard this patch.
common/src/Controller/Common/Catalog/Import/Csv/Processor/Base.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
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\Catalog\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\Catalog\Import\Csv\Processor\Iface $object = null )
35
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
36
+		\Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $object = null)
37 37
 	{
38 38
 		$this->context = $context;
39 39
 		$this->mapping = $mapping;
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
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;
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Catalog/Import/Csv/Standard.php 2 patches
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -349,8 +349,7 @@  discard block
 block discarded – undo
349 349
 			}
350 350
 
351 351
 			$container->close();
352
-		}
353
-		catch( \Exception $e )
352
+		} catch( \Exception $e )
354 353
 		{
355 354
 			$logger->log( 'Catalog import error: ' . $e->getMessage() );
356 355
 			$logger->log( $e->getTraceAsString() );
@@ -590,8 +589,7 @@  discard block
 block discarded – undo
590 589
 					{
591 590
 						$manager->moveItem( $item->getId(), $item->getParentId(), $parentid );
592 591
 						$item = $manager->saveItem( $item );
593
-					}
594
-					else
592
+					} else
595 593
 					{
596 594
 						$item = $manager->insertItem( $item, $parentid );
597 595
 					}
@@ -603,8 +601,7 @@  discard block
 block discarded – undo
603 601
 				}
604 602
 
605 603
 				$manager->commit();
606
-			}
607
-			catch( \Exception $e )
604
+			} catch( \Exception $e )
608 605
 			{
609 606
 				$manager->rollback();
610 607
 
Please login to merge, or discard this patch.
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	public function getName()
30 30
 	{
31
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Catalog import CSV' );
31
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Catalog import CSV');
32 32
 	}
33 33
 
34 34
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	public function getDescription()
41 41
 	{
42
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Imports new and updates existing categories from CSV files' );
42
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Imports new and updates existing categories from CSV files');
43 43
 	}
44 44
 
45 45
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		$context = $this->getContext();
55 55
 		$config = $context->getConfig();
56 56
 		$logger = $context->getLogger();
57
-		$domains = array( 'media', 'text' );
57
+		$domains = array('media', 'text');
58 58
 		$mappings = $this->getDefaultMapping();
59 59
 
60 60
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 		 * @see controller/common/catalog/import/csv/converter
75 75
 		 * @see controller/common/catalog/import/csv/max-size
76 76
 		 */
77
-		$domains = $config->get( 'controller/common/catalog/import/csv/domains', $domains );
77
+		$domains = $config->get('controller/common/catalog/import/csv/domains', $domains);
78 78
 
79 79
 		/** controller/jobs/catalog/import/csv/domains
80 80
 		 * List of item domain names that should be retrieved along with the catalog items
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 		 * @see controller/jobs/catalog/import/csv/backup
95 95
 		 * @see controller/common/catalog/import/csv/max-size
96 96
 		 */
97
-		$domains = $config->get( 'controller/jobs/catalog/import/csv/domains', $domains );
97
+		$domains = $config->get('controller/jobs/catalog/import/csv/domains', $domains);
98 98
 
99 99
 
100 100
 		/** controller/common/catalog/import/csv/mapping
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 		 * @see controller/common/catalog/import/csv/converter
120 120
 		 * @see controller/common/catalog/import/csv/max-size
121 121
 		 */
122
-		$mappings = $config->get( 'controller/common/catalog/import/csv/mapping', $mappings );
122
+		$mappings = $config->get('controller/common/catalog/import/csv/mapping', $mappings);
123 123
 
124 124
 		/** controller/jobs/catalog/import/csv/mapping
125 125
 		 * List of mappings between the position in the CSV file and item keys
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 		 * @see controller/jobs/catalog/import/csv/backup
140 140
 		 * @see controller/common/catalog/import/csv/max-size
141 141
 		 */
142
-		$mappings = $config->get( 'controller/jobs/catalog/import/csv/mapping', $mappings );
142
+		$mappings = $config->get('controller/jobs/catalog/import/csv/mapping', $mappings);
143 143
 
144 144
 
145 145
 		/** controller/common/catalog/import/csv/converter
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 		 * @see controller/common/catalog/import/csv/mapping
182 182
 		 * @see controller/common/catalog/import/csv/max-size
183 183
 		 */
184
-		$converters = $config->get( 'controller/common/catalog/import/csv/converter', [] );
184
+		$converters = $config->get('controller/common/catalog/import/csv/converter', []);
185 185
 
186 186
 		/** controller/jobs/catalog/import/csv/converter
187 187
 		 * List of converter names for the values at the position in the CSV file
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 		 * @see controller/jobs/catalog/import/csv/backup
202 202
 		 * @see controller/common/catalog/import/csv/max-size
203 203
 		 */
204
-		$converters = $config->get( 'controller/jobs/catalog/import/csv/converter', $converters );
204
+		$converters = $config->get('controller/jobs/catalog/import/csv/converter', $converters);
205 205
 
206 206
 
207 207
 		/** controller/common/catalog/import/csv/max-size
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 		 * @see controller/common/catalog/import/csv/mapping
222 222
 		 * @see controller/common/catalog/import/csv/converter
223 223
 		 */
224
-		$maxcnt = (int) $config->get( 'controller/common/catalog/import/csv/max-size', 1000 );
224
+		$maxcnt = (int) $config->get('controller/common/catalog/import/csv/max-size', 1000);
225 225
 
226 226
 
227 227
 		/** controller/jobs/catalog/import/csv/skip-lines
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 		 * @see controller/jobs/catalog/import/csv/backup
244 244
 		 * @see controller/common/catalog/import/csv/max-size
245 245
 		 */
246
-		$skiplines = (int) $config->get( 'controller/jobs/catalog/import/csv/skip-lines', 0 );
246
+		$skiplines = (int) $config->get('controller/jobs/catalog/import/csv/skip-lines', 0);
247 247
 
248 248
 
249 249
 		/** controller/jobs/catalog/import/csv/strict
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 		 * @see controller/jobs/catalog/import/csv/backup
268 268
 		 * @see controller/common/catalog/import/csv/max-size
269 269
 		 */
270
-		$strict = (bool) $config->get( 'controller/jobs/catalog/import/csv/strict', true );
270
+		$strict = (bool) $config->get('controller/jobs/catalog/import/csv/strict', true);
271 271
 
272 272
 
273 273
 		/** controller/jobs/catalog/import/csv/backup
@@ -300,75 +300,75 @@  discard block
 block discarded – undo
300 300
 		 * @see controller/jobs/catalog/import/csv/strict
301 301
 		 * @see controller/common/catalog/import/csv/max-size
302 302
 		 */
303
-		$backup = $config->get( 'controller/jobs/catalog/import/csv/backup' );
303
+		$backup = $config->get('controller/jobs/catalog/import/csv/backup');
304 304
 
305 305
 
306
-		if( !isset( $mappings['item'] ) || !is_array( $mappings['item'] ) )
306
+		if (!isset($mappings['item']) || !is_array($mappings['item']))
307 307
 		{
308
-			$msg = sprintf( 'Required mapping key "%1$s" is missing or contains no array', 'item' );
309
-			throw new \Aimeos\Controller\Jobs\Exception( $msg );
308
+			$msg = sprintf('Required mapping key "%1$s" is missing or contains no array', 'item');
309
+			throw new \Aimeos\Controller\Jobs\Exception($msg);
310 310
 		}
311 311
 
312 312
 		try
313 313
 		{
314 314
 			$procMappings = $mappings;
315
-			unset( $procMappings['item'] );
315
+			unset($procMappings['item']);
316 316
 
317
-			$codePos = $this->getCodePosition( $mappings['item'] );
318
-			$convlist = $this->getConverterList( $converters );
319
-			$processor = $this->getProcessors( $procMappings );
320
-			$catalogMap = $this->getCatalogMap( $domains );
317
+			$codePos = $this->getCodePosition($mappings['item']);
318
+			$convlist = $this->getConverterList($converters);
319
+			$processor = $this->getProcessors($procMappings);
320
+			$catalogMap = $this->getCatalogMap($domains);
321 321
 			$container = $this->getContainer();
322 322
 			$path = $container->getName();
323 323
 
324 324
 
325
-			$msg = sprintf( 'Started catalog import from "%1$s" (%2$s)', $path, __CLASS__ );
326
-			$logger->log( $msg, \Aimeos\MW\Logger\Base::NOTICE );
325
+			$msg = sprintf('Started catalog import from "%1$s" (%2$s)', $path, __CLASS__);
326
+			$logger->log($msg, \Aimeos\MW\Logger\Base::NOTICE);
327 327
 
328
-			foreach( $container as $content )
328
+			foreach ($container as $content)
329 329
 			{
330 330
 				$name = $content->getName();
331 331
 
332
-				for( $i = 0; $i < $skiplines; $i++ ) {
332
+				for ($i = 0; $i < $skiplines; $i++) {
333 333
 					$content->next();
334 334
 				}
335 335
 
336
-				while( ( $data = $this->getData( $content, $maxcnt, $codePos ) ) !== [] )
336
+				while (($data = $this->getData($content, $maxcnt, $codePos)) !== [])
337 337
 				{
338
-					$data = $this->convertData( $convlist, $data );
339
-					$errcnt = $this->import( $catalogMap, $data, $mappings['item'], $processor, $strict );
340
-					$chunkcnt = count( $data );
338
+					$data = $this->convertData($convlist, $data);
339
+					$errcnt = $this->import($catalogMap, $data, $mappings['item'], $processor, $strict);
340
+					$chunkcnt = count($data);
341 341
 
342 342
 					$msg = 'Imported catalog lines from "%1$s": %2$d/%3$d (%4$s)';
343
-					$logger->log( sprintf( $msg, $name, $chunkcnt - $errcnt, $chunkcnt, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE );
343
+					$logger->log(sprintf($msg, $name, $chunkcnt - $errcnt, $chunkcnt, __CLASS__), \Aimeos\MW\Logger\Base::NOTICE);
344 344
 
345 345
 					$errors += $errcnt;
346 346
 					$total += $chunkcnt;
347
-					unset( $data );
347
+					unset($data);
348 348
 				}
349 349
 			}
350 350
 
351 351
 			$container->close();
352 352
 		}
353
-		catch( \Exception $e )
353
+		catch (\Exception $e)
354 354
 		{
355
-			$logger->log( 'Catalog import error: ' . $e->getMessage() );
356
-			$logger->log( $e->getTraceAsString() );
355
+			$logger->log('Catalog import error: ' . $e->getMessage());
356
+			$logger->log($e->getTraceAsString());
357 357
 
358
-			throw new \Aimeos\Controller\Jobs\Exception( $e->getMessage() );
358
+			throw new \Aimeos\Controller\Jobs\Exception($e->getMessage());
359 359
 		}
360 360
 
361 361
 		$msg = 'Finished catalog import from "%1$s": %2$d successful, %3$s errors, %4$s total (%5$s)';
362
-		$logger->log( sprintf( $msg, $path, $total - $errors, $errors, $total, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE );
362
+		$logger->log(sprintf($msg, $path, $total - $errors, $errors, $total, __CLASS__), \Aimeos\MW\Logger\Base::NOTICE);
363 363
 
364
-		if( $errors > 0 )
364
+		if ($errors > 0)
365 365
 		{
366
-			$msg = sprintf( 'Invalid catalog lines in "%1$s": %2$d/%3$d', $path, $errors, $total );
367
-			throw new \Aimeos\Controller\Jobs\Exception( $msg );
366
+			$msg = sprintf('Invalid catalog lines in "%1$s": %2$d/%3$d', $path, $errors, $total);
367
+			throw new \Aimeos\Controller\Jobs\Exception($msg);
368 368
 		}
369 369
 
370
-		if( !empty( $backup ) && @rename( $path, strftime( $backup ) ) === false ) {
371
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Unable to move imported file' ) );
370
+		if (!empty($backup) && @rename($path, strftime($backup)) === false) {
371
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('Unable to move imported file'));
372 372
 		}
373 373
 	}
374 374
 
@@ -380,16 +380,16 @@  discard block
 block discarded – undo
380 380
 	 * @return integer Position of the "catalog.code" column
381 381
 	 * @throws \Aimeos\Controller\Jobs\Exception If no mapping for "catalog.code" is found
382 382
 	 */
383
-	protected function getCodePosition( array $mapping )
383
+	protected function getCodePosition(array $mapping)
384 384
 	{
385
-		foreach( $mapping as $pos => $key )
385
+		foreach ($mapping as $pos => $key)
386 386
 		{
387
-			if( $key === 'catalog.code' ) {
387
+			if ($key === 'catalog.code') {
388 388
 				return $pos;
389 389
 			}
390 390
 		}
391 391
 
392
-		throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'No "catalog.code" column in CSV mapping found' ) );
392
+		throw new \Aimeos\Controller\Jobs\Exception(sprintf('No "catalog.code" column in CSV mapping found'));
393 393
 	}
394 394
 
395 395
 
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 		 * @see controller/jobs/catalog/import/csv/container/content
425 425
 		 * @see controller/jobs/catalog/import/csv/container/options
426 426
 		 */
427
-		$location = $config->get( 'controller/jobs/catalog/import/csv/location' );
427
+		$location = $config->get('controller/jobs/catalog/import/csv/location');
428 428
 
429 429
 		/** controller/jobs/catalog/import/csv/container/type
430 430
 		 * Nave of the container type to read the data from
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
 		 * @see controller/jobs/catalog/import/csv/container/content
448 448
 		 * @see controller/jobs/catalog/import/csv/container/options
449 449
 		 */
450
-		$container = $config->get( 'controller/jobs/catalog/import/csv/container/type', 'Directory' );
450
+		$container = $config->get('controller/jobs/catalog/import/csv/container/type', 'Directory');
451 451
 
452 452
 		/** controller/jobs/catalog/import/csv/container/content
453 453
 		 * Name of the content type inside the container to read the data from
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 		 * @see controller/jobs/catalog/import/csv/container/type
469 469
 		 * @see controller/jobs/catalog/import/csv/container/options
470 470
 		 */
471
-		$content = $config->get( 'controller/jobs/catalog/import/csv/container/content', 'CSV' );
471
+		$content = $config->get('controller/jobs/catalog/import/csv/container/content', 'CSV');
472 472
 
473 473
 		/** controller/jobs/catalog/import/csv/container/options
474 474
 		 * List of file container options for the catalog import files
@@ -486,15 +486,15 @@  discard block
 block discarded – undo
486 486
 		 * @see controller/jobs/catalog/import/csv/container/content
487 487
 		 * @see controller/jobs/catalog/import/csv/container/type
488 488
 		 */
489
-		$options = $config->get( 'controller/jobs/catalog/import/csv/container/options', [] );
489
+		$options = $config->get('controller/jobs/catalog/import/csv/container/options', []);
490 490
 
491
-		if( $location === null )
491
+		if ($location === null)
492 492
 		{
493
-			$msg = sprintf( 'Required configuration for "%1$s" is missing', 'controller/jobs/catalog/import/csv/location' );
494
-			throw new \Aimeos\Controller\Jobs\Exception( $msg );
493
+			$msg = sprintf('Required configuration for "%1$s" is missing', 'controller/jobs/catalog/import/csv/location');
494
+			throw new \Aimeos\Controller\Jobs\Exception($msg);
495 495
 		}
496 496
 
497
-		return \Aimeos\MW\Container\Factory::getContainer( $location, $container, $content, $options );
497
+		return \Aimeos\MW\Container\Factory::getContainer($location, $container, $content, $options);
498 498
 	}
499 499
 
500 500
 
@@ -504,13 +504,13 @@  discard block
 block discarded – undo
504 504
 	 * @param array $domains List of domain names whose items should be fetched too
505 505
 	 * @return array Associative list of catalog codes as keys and items implementing \Aimeos\MShop\Catalog\Item\Iface as values
506 506
 	 */
507
-	protected function getCatalogMap( array $domains )
507
+	protected function getCatalogMap(array $domains)
508 508
 	{
509 509
 		$map = [];
510
-		$manager = \Aimeos\MShop::create( $this->getContext(), 'catalog' );
511
-		$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
510
+		$manager = \Aimeos\MShop::create($this->getContext(), 'catalog');
511
+		$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
512 512
 
513
-		foreach( $manager->searchItems( $search, $domains ) as $item ) {
513
+		foreach ($manager->searchItems($search, $domains) as $item) {
514 514
 			$map[$item->getCode()] = $item;
515 515
 		}
516 516
 
@@ -526,23 +526,23 @@  discard block
 block discarded – undo
526 526
 	 * @param string $code Catalog item code of the parent category
527 527
 	 * @return string|null ID of the parent category or null for top level nodes
528 528
 	 */
529
-	protected function getParentId( array $catalogMap, array $map, $code )
529
+	protected function getParentId(array $catalogMap, array $map, $code)
530 530
 	{
531
-		if( !isset( $map['catalog.parent'] ) )
531
+		if (!isset($map['catalog.parent']))
532 532
 		{
533
-			$msg = sprintf( 'Required column "%1$s" not found for code "%2$s"', 'catalog.parent', $code );
534
-			throw new \Aimeos\Controller\Jobs\Exception( $msg );
533
+			$msg = sprintf('Required column "%1$s" not found for code "%2$s"', 'catalog.parent', $code);
534
+			throw new \Aimeos\Controller\Jobs\Exception($msg);
535 535
 		}
536 536
 
537
-		$parent = trim( $map['catalog.parent'] );
537
+		$parent = trim($map['catalog.parent']);
538 538
 
539
-		if( $parent != '' && !isset( $catalogMap[$parent] ) )
539
+		if ($parent != '' && !isset($catalogMap[$parent]))
540 540
 		{
541
-			$msg = sprintf( 'Parent node for code "%1$s" not found', $parent );
542
-			throw new \Aimeos\Controller\Jobs\Exception( $msg );
541
+			$msg = sprintf('Parent node for code "%1$s" not found', $parent);
542
+			throw new \Aimeos\Controller\Jobs\Exception($msg);
543 543
 		}
544 544
 
545
-		return ( $parent != '' ? $catalogMap[$parent]->getId() : null );
545
+		return ($parent != '' ? $catalogMap[$parent]->getId() : null);
546 546
 	}
547 547
 
548 548
 
@@ -557,65 +557,65 @@  discard block
 block discarded – undo
557 557
 	 * @return integer Number of catalogs that couldn't be imported
558 558
 	 * @throws \Aimeos\Controller\Jobs\Exception
559 559
 	 */
560
-	protected function import( array &$catalogMap, array $data, array $mapping,
561
-		\Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $processor, $strict )
560
+	protected function import(array &$catalogMap, array $data, array $mapping,
561
+		\Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $processor, $strict)
562 562
 	{
563 563
 		$errors = 0;
564 564
 		$context = $this->getContext();
565
-		$manager = \Aimeos\MShop::create( $context, 'catalog' );
565
+		$manager = \Aimeos\MShop::create($context, 'catalog');
566 566
 
567
-		foreach( $data as $code => $list )
567
+		foreach ($data as $code => $list)
568 568
 		{
569 569
 			$manager->begin();
570 570
 
571 571
 			try
572 572
 			{
573
-				$code = trim( $code );
573
+				$code = trim($code);
574 574
 
575
-				if( isset( $catalogMap[$code] )  ) {
575
+				if (isset($catalogMap[$code])) {
576 576
 					$item = $catalogMap[$code];
577 577
 				} else {
578 578
 					$item = $manager->createItem();
579 579
 				}
580 580
 
581
-				$map = $this->getMappedChunk( $list, $mapping );
581
+				$map = $this->getMappedChunk($list, $mapping);
582 582
 
583
-				if( isset( $map[0] ) )
583
+				if (isset($map[0]))
584 584
 				{
585 585
 					$map = $map[0]; // there can only be one chunk for the base catalog data
586
-					$parentid = $this->getParentId( $catalogMap, $map, $code );
587
-					$item->fromArray( $map );
586
+					$parentid = $this->getParentId($catalogMap, $map, $code);
587
+					$item->fromArray($map);
588 588
 
589
-					if( isset( $catalogMap[$code] ) )
589
+					if (isset($catalogMap[$code]))
590 590
 					{
591
-						$manager->moveItem( $item->getId(), $item->getParentId(), $parentid );
592
-						$item = $manager->saveItem( $item );
591
+						$manager->moveItem($item->getId(), $item->getParentId(), $parentid);
592
+						$item = $manager->saveItem($item);
593 593
 					}
594 594
 					else
595 595
 					{
596
-						$item = $manager->insertItem( $item, $parentid );
596
+						$item = $manager->insertItem($item, $parentid);
597 597
 					}
598 598
 
599
-					$list = $processor->process( $item, $list );
599
+					$list = $processor->process($item, $list);
600 600
 					$catalogMap[$code] = $item;
601 601
 
602
-					$manager->saveItem( $item );
602
+					$manager->saveItem($item);
603 603
 				}
604 604
 
605 605
 				$manager->commit();
606 606
 			}
607
-			catch( \Exception $e )
607
+			catch (\Exception $e)
608 608
 			{
609 609
 				$manager->rollback();
610 610
 
611
-				$msg = sprintf( 'Unable to import catalog with code "%1$s": %2$s', $code, $e->getMessage() );
612
-				$context->getLogger()->log( $msg );
611
+				$msg = sprintf('Unable to import catalog with code "%1$s": %2$s', $code, $e->getMessage());
612
+				$context->getLogger()->log($msg);
613 613
 
614 614
 				$errors++;
615 615
 			}
616 616
 
617
-			if( $strict && !empty( $list ) ) {
618
-				$context->getLogger()->log( 'Not imported: ' . print_r( $list, true ) );
617
+			if ($strict && !empty($list)) {
618
+				$context->getLogger()->log('Not imported: ' . print_r($list, true));
619 619
 			}
620 620
 		}
621 621
 
Please login to merge, or discard this patch.