Completed
Push — master ( 14839e...9c4bb8 )
by Aimeos
07:11 queued 01:55
created
controller/common/src/Controller/Common/Product/Import/Csv/Base.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -242,7 +242,7 @@
 block discarded – undo
242 242
 	/**
243 243
 	 * Returns the processor object for saving the product related information
244 244
 	 *
245
-	 * @param array $mapping Associative list of processor types as keys and index/data mappings as values
245
+	 * @param array $mappings Associative list of processor types as keys and index/data mappings as values
246 246
 	 * @return \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface Processor object
247 247
 	 */
248 248
 	protected function getProcessors( array $mappings )
Please login to merge, or discard this patch.
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -30,14 +30,14 @@  discard block
 block discarded – undo
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,38 +53,38 @@  discard block
 block discarded – undo
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
 		$iface = '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\Iface';
61 61
 
62
-		if( ctype_alnum( $type ) === false )
62
+		if (ctype_alnum($type) === false)
63 63
 		{
64 64
 			$classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\' . $type : '<not a string>';
65
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
65
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
66 66
 		}
67 67
 
68
-		if( $name === null ) {
69
-			$name = $config->get( 'controller/common/product/import/csv/cache/' . $type . '/name', 'Standard' );
68
+		if ($name === null) {
69
+			$name = $config->get('controller/common/product/import/csv/cache/' . $type . '/name', 'Standard');
70 70
 		}
71 71
 
72
-		if( ctype_alnum( $name ) === false )
72
+		if (ctype_alnum($name) === false)
73 73
 		{
74 74
 			$classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\' . $type . '\\' . $name : '<not a string>';
75
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
75
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
76 76
 		}
77 77
 
78
-		$classname = '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\' . ucfirst( $type ) . '\\' . $name;
78
+		$classname = '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\' . ucfirst($type) . '\\' . $name;
79 79
 
80
-		if( class_exists( $classname ) === false ) {
81
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) );
80
+		if (class_exists($classname) === false) {
81
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname));
82 82
 		}
83 83
 
84
-		$object = new $classname( $context );
84
+		$object = new $classname($context);
85 85
 
86
-		if( !( $object instanceof $iface ) ) {
87
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" does not implement interface "%2$s"', $classname, $iface ) );
86
+		if (!($object instanceof $iface)) {
87
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" does not implement interface "%2$s"', $classname, $iface));
88 88
 		}
89 89
 
90 90
 		return $object;
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
 	 * @param array $convmap List of converter names for the values at the position in the CSV file
98 98
 	 * @return array Associative list of positions and converter objects
99 99
 	 */
100
-	protected function getConverterList( array $convmap )
100
+	protected function getConverterList(array $convmap)
101 101
 	{
102 102
 		$convlist = array();
103 103
 
104
-		foreach( $convmap as $idx => $name ) {
105
-			$convlist[$idx] = \Aimeos\MW\Convert\Factory::createConverter( $name );
104
+		foreach ($convmap as $idx => $name) {
105
+			$convlist[$idx] = \Aimeos\MW\Convert\Factory::createConverter($name);
106 106
 		}
107 107
 
108 108
 		return $convlist;
@@ -117,15 +117,15 @@  discard block
 block discarded – undo
117 117
 	 * @param integer $codePos Column position which contains the unique product code (starting from 0)
118 118
 	 * @return array List of arrays with product codes as keys and list of values from the CSV file
119 119
 	 */
120
-	protected function getData( \Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos )
120
+	protected function getData(\Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos)
121 121
 	{
122 122
 		$count = 0;
123 123
 		$data = array();
124 124
 
125
-		while( $content->valid() && $count++ < $maxcnt )
125
+		while ($content->valid() && $count++ < $maxcnt)
126 126
 		{
127 127
 			$row = $content->current();
128
-			$data[ $row[$codePos] ] = $row;
128
+			$data[$row[$codePos]] = $row;
129 129
 			$content->next();
130 130
 		}
131 131
 
@@ -222,13 +222,13 @@  discard block
 block discarded – undo
222 222
 	 * @param array $list List of CSV fields with the CSV field position as key
223 223
 	 * @return Associative list of domain item keys and the converted values
224 224
 	 */
225
-	protected function getMappedData( array $mapping, array $list )
225
+	protected function getMappedData(array $mapping, array $list)
226 226
 	{
227 227
 		$map = array();
228 228
 
229
-		foreach( $mapping as $idx => $key )
229
+		foreach ($mapping as $idx => $key)
230 230
 		{
231
-			if( !isset( $list[$idx] ) ) {
231
+			if (!isset($list[$idx])) {
232 232
 				break;
233 233
 			}
234 234
 
@@ -245,39 +245,39 @@  discard block
 block discarded – undo
245 245
 	 * @param array $mapping Associative list of processor types as keys and index/data mappings as values
246 246
 	 * @return \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface Processor object
247 247
 	 */
248
-	protected function getProcessors( array $mappings )
248
+	protected function getProcessors(array $mappings)
249 249
 	{
250 250
 		$context = $this->getContext();
251 251
 		$config = $context->getConfig();
252 252
 		$iface = '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\Iface';
253
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done( $context, array() );
253
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done($context, array());
254 254
 
255
-		foreach( $mappings as $type => $mapping )
255
+		foreach ($mappings as $type => $mapping)
256 256
 		{
257
-			if( ctype_alnum( $type ) === false )
257
+			if (ctype_alnum($type) === false)
258 258
 			{
259 259
 				$classname = is_string($type) ? '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\' . $type : '<not a string>';
260
-				throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
260
+				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
261 261
 			}
262 262
 
263
-			$name = $config->get( 'controller/common/product/import/csv/processor/' . $type . '/name', 'Standard' );
263
+			$name = $config->get('controller/common/product/import/csv/processor/' . $type . '/name', 'Standard');
264 264
 
265
-			if( ctype_alnum( $name ) === false )
265
+			if (ctype_alnum($name) === false)
266 266
 			{
267 267
 				$classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\' . $type . '\\' . $name : '<not a string>';
268
-				throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
268
+				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
269 269
 			}
270 270
 
271
-			$classname = '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\' . ucfirst( $type ) . '\\' . $name;
271
+			$classname = '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\' . ucfirst($type) . '\\' . $name;
272 272
 
273
-			if( class_exists( $classname ) === false ) {
274
-				throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) );
273
+			if (class_exists($classname) === false) {
274
+				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname));
275 275
 			}
276 276
 
277
-			$object = new $classname( $context, $mapping, $object );
277
+			$object = new $classname($context, $mapping, $object);
278 278
 
279
-			if( !( $object instanceof $iface ) ) {
280
-				throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" does not implement interface "%2$s"', $classname, $iface ) );
279
+			if (!($object instanceof $iface)) {
280
+				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" does not implement interface "%2$s"', $classname, $iface));
281 281
 			}
282 282
 		}
283 283
 
@@ -292,17 +292,17 @@  discard block
 block discarded – undo
292 292
 	 * @param array $domains List of domains whose items should be fetched too
293 293
 	 * @return array Associative list of product codes as key and product items as value
294 294
 	 */
295
-	protected function getProducts( array $codes, array $domains )
295
+	protected function getProducts(array $codes, array $domains)
296 296
 	{
297 297
 		$result = array();
298
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' );
298
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product');
299 299
 
300 300
 		$search = $manager->createSearch();
301
-		$search->setConditions( $search->compare( '==', 'product.code', $codes ) );
302
-		$search->setSlice( 0, count( $codes ) );
301
+		$search->setConditions($search->compare('==', 'product.code', $codes));
302
+		$search->setSlice(0, count($codes));
303 303
 
304
-		foreach( $manager->searchItems( $search, $domains ) as $item ) {
305
-			$result[ $item->getCode() ] = $item;
304
+		foreach ($manager->searchItems($search, $domains) as $item) {
305
+			$result[$item->getCode()] = $item;
306 306
 		}
307 307
 
308 308
 		return $result;
@@ -317,23 +317,23 @@  discard block
 block discarded – undo
317 317
 	 * @param string $code Unique code of the type item
318 318
 	 * @return string Unique ID of the type item
319 319
 	 */
320
-	protected function getTypeId( $path, $domain, $code )
320
+	protected function getTypeId($path, $domain, $code)
321 321
 	{
322
-		if( !isset( self::$types[$path][$domain] ) )
322
+		if (!isset(self::$types[$path][$domain]))
323 323
 		{
324
-			$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $path );
325
-			$key = str_replace( '/', '.', $path );
324
+			$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $path);
325
+			$key = str_replace('/', '.', $path);
326 326
 
327 327
 			$search = $manager->createSearch();
328
-			$search->setConditions( $search->compare( '==', $key . '.domain', $domain ) );
328
+			$search->setConditions($search->compare('==', $key . '.domain', $domain));
329 329
 
330
-			foreach( $manager->searchItems( $search ) as $id => $item ) {
331
-				self::$types[$path][$domain][ $item->getCode() ] = $id;
330
+			foreach ($manager->searchItems($search) as $id => $item) {
331
+				self::$types[$path][$domain][$item->getCode()] = $id;
332 332
 			}
333 333
 		}
334 334
 
335
-		if( !isset( self::$types[$path][$domain][$code] ) ) {
336
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'No type item for "%1$s/%2$s" in "%3$s" found', $domain, $code, $path ) );
335
+		if (!isset(self::$types[$path][$domain][$code])) {
336
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('No type item for "%1$s/%2$s" in "%3$s" found', $domain, $code, $path));
337 337
 		}
338 338
 
339 339
 		return self::$types[$path][$domain][$code];
Please login to merge, or discard this patch.
tests/Controller/Common/Product/Import/Csv/Processor/Text/StandardTest.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -291,6 +291,9 @@  discard block
 block discarded – undo
291 291
 	}
292 292
 
293 293
 
294
+	/**
295
+	 * @param string $code
296
+	 */
294 297
 	protected function create( $code )
295 298
 	{
296 299
 		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context );
@@ -330,6 +333,9 @@  discard block
 block discarded – undo
330 333
 	}
331 334
 
332 335
 
336
+	/**
337
+	 * @param string $code
338
+	 */
333 339
 	protected function get( $code )
334 340
 	{
335 341
 		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context );
Please login to merge, or discard this patch.
Spacing   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
 	 */
22 22
 	protected function setUp()
23 23
 	{
24
-		\Aimeos\MShop\Factory::setCache( true );
24
+		\Aimeos\MShop\Factory::setCache(true);
25 25
 
26 26
 		$this->context = \TestHelperCntl::getContext();
27
-		$this->endpoint = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done( $this->context, array() );
27
+		$this->endpoint = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done($this->context, array());
28 28
 	}
29 29
 
30 30
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 */
37 37
 	protected function tearDown()
38 38
 	{
39
-		\Aimeos\MShop\Factory::setCache( false );
39
+		\Aimeos\MShop\Factory::setCache(false);
40 40
 		\Aimeos\MShop\Factory::clear();
41 41
 	}
42 42
 
@@ -59,35 +59,35 @@  discard block
 block discarded – undo
59 59
 			4 => 1,
60 60
 		);
61 61
 
62
-		$product = $this->create( 'job_csv_test' );
62
+		$product = $this->create('job_csv_test');
63 63
 
64
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Text\Standard( $this->context, $mapping, $this->endpoint );
65
-		$result = $object->process( $product, $data );
64
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Text\Standard($this->context, $mapping, $this->endpoint);
65
+		$result = $object->process($product, $data);
66 66
 
67
-		$product = $this->get( 'job_csv_test' );
68
-		$this->delete( $product );
67
+		$product = $this->get('job_csv_test');
68
+		$this->delete($product);
69 69
 
70 70
 
71 71
 		$listItems = $product->getListItems();
72
-		$listItem = reset( $listItems );
72
+		$listItem = reset($listItems);
73 73
 
74
-		$this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem );
75
-		$this->assertEquals( 1, count( $listItems ) );
74
+		$this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem);
75
+		$this->assertEquals(1, count($listItems));
76 76
 
77
-		$this->assertEquals( 1, $listItem->getStatus() );
78
-		$this->assertEquals( 0, $listItem->getPosition() );
79
-		$this->assertEquals( 'text', $listItem->getDomain() );
80
-		$this->assertEquals( 'default', $listItem->getType() );
77
+		$this->assertEquals(1, $listItem->getStatus());
78
+		$this->assertEquals(0, $listItem->getPosition());
79
+		$this->assertEquals('text', $listItem->getDomain());
80
+		$this->assertEquals('default', $listItem->getType());
81 81
 
82 82
 		$refItem = $listItem->getRefItem();
83 83
 
84
-		$this->assertEquals( 1, $refItem->getStatus() );
85
-		$this->assertEquals( 'name', $refItem->getType() );
86
-		$this->assertEquals( 'product', $refItem->getDomain() );
87
-		$this->assertEquals( 'test text', $refItem->getLabel() );
88
-		$this->assertEquals( 'Job CSV test', $refItem->getContent() );
89
-		$this->assertEquals( 'de', $refItem->getLanguageId() );
90
-		$this->assertEquals( 1, $refItem->getStatus() );
84
+		$this->assertEquals(1, $refItem->getStatus());
85
+		$this->assertEquals('name', $refItem->getType());
86
+		$this->assertEquals('product', $refItem->getDomain());
87
+		$this->assertEquals('test text', $refItem->getLabel());
88
+		$this->assertEquals('Job CSV test', $refItem->getContent());
89
+		$this->assertEquals('de', $refItem->getLanguageId());
90
+		$this->assertEquals(1, $refItem->getStatus());
91 91
 	}
92 92
 
93 93
 
@@ -115,30 +115,30 @@  discard block
 block discarded – undo
115 115
 			7 => 'Long: Job CSV test 2',
116 116
 		);
117 117
 
118
-		$product = $this->create( 'job_csv_test' );
118
+		$product = $this->create('job_csv_test');
119 119
 
120
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Text\Standard( $this->context, $mapping, $this->endpoint );
121
-		$result = $object->process( $product, $data );
120
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Text\Standard($this->context, $mapping, $this->endpoint);
121
+		$result = $object->process($product, $data);
122 122
 
123
-		$product = $this->get( 'job_csv_test' );
124
-		$this->delete( $product );
123
+		$product = $this->get('job_csv_test');
124
+		$this->delete($product);
125 125
 
126 126
 
127 127
 		$pos = 0;
128 128
 		$listItems = $product->getListItems();
129 129
 		$expected = array(
130
-			0 => array( 'name', 'Job CSV test' ),
131
-			1 => array( 'short', 'Short: Job CSV test' ),
132
-			2 => array( 'long', 'Long: Job CSV test' ),
133
-			3 => array( 'long', 'Long: Job CSV test 2' ),
130
+			0 => array('name', 'Job CSV test'),
131
+			1 => array('short', 'Short: Job CSV test'),
132
+			2 => array('long', 'Long: Job CSV test'),
133
+			3 => array('long', 'Long: Job CSV test 2'),
134 134
 		);
135 135
 
136
-		$this->assertEquals( 4, count( $listItems ) );
136
+		$this->assertEquals(4, count($listItems));
137 137
 
138
-		foreach( $listItems as $listItem )
138
+		foreach ($listItems as $listItem)
139 139
 		{
140
-			$this->assertEquals( $expected[$pos][0], $listItem->getRefItem()->getType() );
141
-			$this->assertEquals( $expected[$pos][1], $listItem->getRefItem()->getContent() );
140
+			$this->assertEquals($expected[$pos][0], $listItem->getRefItem()->getType());
141
+			$this->assertEquals($expected[$pos][1], $listItem->getRefItem()->getContent());
142 142
 			$pos++;
143 143
 		}
144 144
 	}
@@ -161,27 +161,27 @@  discard block
 block discarded – undo
161 161
 			1 => 'Short: Job CSV test',
162 162
 		);
163 163
 
164
-		$product = $this->create( 'job_csv_test' );
164
+		$product = $this->create('job_csv_test');
165 165
 
166
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Text\Standard( $this->context, $mapping, $this->endpoint );
167
-		$result = $object->process( $product, $data );
166
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Text\Standard($this->context, $mapping, $this->endpoint);
167
+		$result = $object->process($product, $data);
168 168
 
169
-		$product = $this->get( 'job_csv_test' );
169
+		$product = $this->get('job_csv_test');
170 170
 
171
-		$result = $object->process( $product, $dataUpdate );
171
+		$result = $object->process($product, $dataUpdate);
172 172
 
173
-		$product = $this->get( 'job_csv_test' );
174
-		$this->delete( $product );
173
+		$product = $this->get('job_csv_test');
174
+		$this->delete($product);
175 175
 
176 176
 
177 177
 		$listItems = $product->getListItems();
178
-		$listItem = reset( $listItems );
178
+		$listItem = reset($listItems);
179 179
 
180
-		$this->assertEquals( 1, count( $listItems ) );
181
-		$this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem );
180
+		$this->assertEquals(1, count($listItems));
181
+		$this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem);
182 182
 
183
-		$this->assertEquals( 'short', $listItem->getRefItem()->getType() );
184
-		$this->assertEquals( 'Short: Job CSV test', $listItem->getRefItem()->getContent() );
183
+		$this->assertEquals('short', $listItem->getRefItem()->getType());
184
+		$this->assertEquals('Short: Job CSV test', $listItem->getRefItem()->getContent());
185 185
 	}
186 186
 
187 187
 
@@ -197,23 +197,23 @@  discard block
 block discarded – undo
197 197
 			1 => 'Job CSV test',
198 198
 		);
199 199
 
200
-		$product = $this->create( 'job_csv_test' );
200
+		$product = $this->create('job_csv_test');
201 201
 
202
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Text\Standard( $this->context, $mapping, $this->endpoint );
203
-		$result = $object->process( $product, $data );
202
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Text\Standard($this->context, $mapping, $this->endpoint);
203
+		$result = $object->process($product, $data);
204 204
 
205
-		$product = $this->get( 'job_csv_test' );
205
+		$product = $this->get('job_csv_test');
206 206
 
207
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Text\Standard( $this->context, array(), $this->endpoint );
208
-		$result = $object->process( $product, array() );
207
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Text\Standard($this->context, array(), $this->endpoint);
208
+		$result = $object->process($product, array());
209 209
 
210
-		$product = $this->get( 'job_csv_test' );
211
-		$this->delete( $product );
210
+		$product = $this->get('job_csv_test');
211
+		$this->delete($product);
212 212
 
213 213
 
214 214
 		$listItems = $product->getListItems();
215 215
 
216
-		$this->assertEquals( 0, count( $listItems ) );
216
+		$this->assertEquals(0, count($listItems));
217 217
 	}
218 218
 
219 219
 
@@ -233,18 +233,18 @@  discard block
 block discarded – undo
233 233
 			3 => '',
234 234
 		);
235 235
 
236
-		$product = $this->create( 'job_csv_test' );
236
+		$product = $this->create('job_csv_test');
237 237
 
238
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Text\Standard( $this->context, $mapping, $this->endpoint );
239
-		$result = $object->process( $product, $data );
238
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Text\Standard($this->context, $mapping, $this->endpoint);
239
+		$result = $object->process($product, $data);
240 240
 
241
-		$product = $this->get( 'job_csv_test' );
242
-		$this->delete( $product );
241
+		$product = $this->get('job_csv_test');
242
+		$this->delete($product);
243 243
 
244 244
 
245 245
 		$listItems = $product->getListItems();
246 246
 
247
-		$this->assertEquals( 1, count( $listItems ) );
247
+		$this->assertEquals(1, count($listItems));
248 248
 	}
249 249
 
250 250
 
@@ -268,79 +268,79 @@  discard block
 block discarded – undo
268 268
 			5 => 'default',
269 269
 		);
270 270
 
271
-		$this->context->getConfig()->set( 'controller/common/product/import/csv/processor/text/listtypes', array( 'default' ) );
271
+		$this->context->getConfig()->set('controller/common/product/import/csv/processor/text/listtypes', array('default'));
272 272
 
273
-		$product = $this->create( 'job_csv_test' );
273
+		$product = $this->create('job_csv_test');
274 274
 
275
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Text\Standard( $this->context, $mapping, $this->endpoint );
276
-		$result = $object->process( $product, $data );
275
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Text\Standard($this->context, $mapping, $this->endpoint);
276
+		$result = $object->process($product, $data);
277 277
 
278
-		$product = $this->get( 'job_csv_test' );
279
-		$this->delete( $product );
278
+		$product = $this->get('job_csv_test');
279
+		$this->delete($product);
280 280
 
281 281
 
282 282
 		$listItems = $product->getListItems();
283
-		$listItem = reset( $listItems );
283
+		$listItem = reset($listItems);
284 284
 
285
-		$this->assertEquals( 1, count( $listItems ) );
286
-		$this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem );
285
+		$this->assertEquals(1, count($listItems));
286
+		$this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem);
287 287
 
288
-		$this->assertEquals( 'default', $listItem->getType() );
289
-		$this->assertEquals( 'short', $listItem->getRefItem()->getType() );
290
-		$this->assertEquals( 'test short', $listItem->getRefItem()->getContent() );
288
+		$this->assertEquals('default', $listItem->getType());
289
+		$this->assertEquals('short', $listItem->getRefItem()->getType());
290
+		$this->assertEquals('test short', $listItem->getRefItem()->getContent());
291 291
 	}
292 292
 
293 293
 
294
-	protected function create( $code )
294
+	protected function create($code)
295 295
 	{
296
-		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context );
297
-		$typeManager = $manager->getSubManager( 'type' );
296
+		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context);
297
+		$typeManager = $manager->getSubManager('type');
298 298
 
299 299
 		$typeSearch = $typeManager->createSearch();
300
-		$typeSearch->setConditions( $typeSearch->compare( '==', 'product.type.code', 'default' ) );
301
-		$typeResult = $typeManager->searchItems( $typeSearch );
300
+		$typeSearch->setConditions($typeSearch->compare('==', 'product.type.code', 'default'));
301
+		$typeResult = $typeManager->searchItems($typeSearch);
302 302
 
303
-		if( ( $typeItem = reset( $typeResult ) ) === false ) {
304
-			throw new \Exception( 'No product type "default" found' );
303
+		if (($typeItem = reset($typeResult)) === false) {
304
+			throw new \Exception('No product type "default" found');
305 305
 		}
306 306
 
307 307
 		$item = $manager->createItem();
308
-		$item->setTypeid( $typeItem->getId() );
309
-		$item->setCode( $code );
308
+		$item->setTypeid($typeItem->getId());
309
+		$item->setCode($code);
310 310
 
311
-		$manager->saveItem( $item );
311
+		$manager->saveItem($item);
312 312
 
313 313
 		return $item;
314 314
 	}
315 315
 
316 316
 
317
-	protected function delete( \Aimeos\MShop\Product\Item\Iface $product )
317
+	protected function delete(\Aimeos\MShop\Product\Item\Iface $product)
318 318
 	{
319
-		$textManager = \Aimeos\MShop\Text\Manager\Factory::createManager( $this->context );
320
-		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context );
321
-		$listManager = $manager->getSubManager( 'lists' );
319
+		$textManager = \Aimeos\MShop\Text\Manager\Factory::createManager($this->context);
320
+		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context);
321
+		$listManager = $manager->getSubManager('lists');
322 322
 
323
-		foreach( $product->getListItems('text') as $listItem )
323
+		foreach ($product->getListItems('text') as $listItem)
324 324
 		{
325
-			$textManager->deleteItem( $listItem->getRefItem()->getId() );
326
-			$listManager->deleteItem( $listItem->getId() );
325
+			$textManager->deleteItem($listItem->getRefItem()->getId());
326
+			$listManager->deleteItem($listItem->getId());
327 327
 		}
328 328
 
329
-		$manager->deleteItem( $product->getId() );
329
+		$manager->deleteItem($product->getId());
330 330
 	}
331 331
 
332 332
 
333
-	protected function get( $code )
333
+	protected function get($code)
334 334
 	{
335
-		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context );
335
+		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context);
336 336
 
337 337
 		$search = $manager->createSearch();
338
-		$search->setConditions( $search->compare( '==', 'product.code', $code ) );
338
+		$search->setConditions($search->compare('==', 'product.code', $code));
339 339
 
340
-		$result = $manager->searchItems( $search, array('text') );
340
+		$result = $manager->searchItems($search, array('text'));
341 341
 
342
-		if( ( $item = reset( $result ) ) === false ) {
343
-			throw new \Exception( sprintf( 'No product item for code "%1$s"', $code ) );
342
+		if (($item = reset($result)) === false) {
343
+			throw new \Exception(sprintf('No product item for code "%1$s"', $code));
344 344
 		}
345 345
 
346 346
 		return $item;
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Customer/Email/Account/Standard.php 3 patches
Doc Comments   -3 removed lines patch added patch discarded remove patch
@@ -98,9 +98,6 @@
 block discarded – undo
98 98
 	 * Sends the account creation e-mail to the e-mail address of the customer
99 99
 	 *
100 100
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context item object
101
-	 * @param \Aimeos\MShop\Common\Item\Address\Iface $address Payment address item of the customer
102
-	 * @param string $code Customer login name
103
-	 * @param string $password Customer clear text password
104 101
 	 */
105 102
 	protected function sendEmail( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Customer\Item\Iface $item )
106 103
 	{
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 */
32 32
 	public function getName()
33 33
 	{
34
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Customer account e-mails' );
34
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Customer account e-mails');
35 35
 	}
36 36
 
37 37
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	 */
43 43
 	public function getDescription()
44 44
 	{
45
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Sends e-mails for new customer accounts' );
45
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Sends e-mails for new customer accounts');
46 46
 	}
47 47
 
48 48
 
@@ -54,24 +54,24 @@  discard block
 block discarded – undo
54 54
 	public function run()
55 55
 	{
56 56
 		$context = $this->getContext();
57
-		$queue = $context->getMessageQueue( 'mq-email', 'customer/email/account' );
58
-		$custManager = \Aimeos\MShop\Factory::createManager( $context, 'customer' );
57
+		$queue = $context->getMessageQueue('mq-email', 'customer/email/account');
58
+		$custManager = \Aimeos\MShop\Factory::createManager($context, 'customer');
59 59
 
60
-		while( ( $msg = $queue->get() ) !== null )
60
+		while (($msg = $queue->get()) !== null)
61 61
 		{
62
-			if( ( $list = json_decode( $msg->getBody(), true ) ) !== null )
62
+			if (($list = json_decode($msg->getBody(), true)) !== null)
63 63
 			{
64 64
 				$item = $custManager->createItem();
65
-				$item->fromArray( $list );
65
+				$item->fromArray($list);
66 66
 
67
-				$this->sendEmail( $context, $item );
67
+				$this->sendEmail($context, $item);
68 68
 			}
69 69
 			else
70 70
 			{
71
-				$context->getLogger()->log( sprintf( 'Invalid JSON encode message: %1$s', $msg->getBody() ) );
71
+				$context->getLogger()->log(sprintf('Invalid JSON encode message: %1$s', $msg->getBody()));
72 72
 			}
73 73
 
74
-			$queue->del( $msg );
74
+			$queue->del($msg);
75 75
 		}
76 76
 	}
77 77
 
@@ -82,12 +82,12 @@  discard block
 block discarded – undo
82 82
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context item object
83 83
 	 * @return \Aimeos\Client\Html\Iface Product notification e-mail client
84 84
 	 */
85
-	protected function getClient( \Aimeos\MShop\Context\Item\Iface $context )
85
+	protected function getClient(\Aimeos\MShop\Context\Item\Iface $context)
86 86
 	{
87
-		if( !isset( $this->client ) )
87
+		if (!isset($this->client))
88 88
 		{
89
-			$templatePaths = $this->getAimeos()->getCustomPaths( 'client/html' );
90
-			$this->client = \Aimeos\Client\Html\Email\Account\Factory::createClient( $context, $templatePaths );
89
+			$templatePaths = $this->getAimeos()->getCustomPaths('client/html');
90
+			$this->client = \Aimeos\Client\Html\Email\Account\Factory::createClient($context, $templatePaths);
91 91
 		}
92 92
 
93 93
 		return $this->client;
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 * @param string $code Customer login name
103 103
 	 * @param string $password Customer clear text password
104 104
 	 */
105
-	protected function sendEmail( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Customer\Item\Iface $item )
105
+	protected function sendEmail(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Customer\Item\Iface $item)
106 106
 	{
107 107
 		$address = $item->getPaymentAddress();
108 108
 
@@ -111,20 +111,20 @@  discard block
 block discarded – undo
111 111
 		$view->extAccountCode = $item->getCode();
112 112
 		$view->extAccountPassword = $item->getPassword();
113 113
 
114
-		$helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $context->getI18n( $address->getLanguageId() ) );
115
-		$view->addHelper( 'translate', $helper );
114
+		$helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $context->getI18n($address->getLanguageId()));
115
+		$view->addHelper('translate', $helper);
116 116
 
117 117
 		$mailer = $context->getMail();
118 118
 		$message = $mailer->createMessage();
119 119
 
120
-		$helper = new \Aimeos\MW\View\Helper\Mail\Standard( $view, $message );
121
-		$view->addHelper( 'mail', $helper );
120
+		$helper = new \Aimeos\MW\View\Helper\Mail\Standard($view, $message);
121
+		$view->addHelper('mail', $helper);
122 122
 
123
-		$client = $this->getClient( $context );
124
-		$client->setView( $view );
123
+		$client = $this->getClient($context);
124
+		$client->setView($view);
125 125
 		$client->getHeader();
126 126
 		$client->getBody();
127 127
 
128
-		$mailer->send( $message );
128
+		$mailer->send($message);
129 129
 	}
130 130
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -65,8 +65,7 @@
 block discarded – undo
65 65
 				$item->fromArray( $list );
66 66
 
67 67
 				$this->sendEmail( $context, $item );
68
-			}
69
-			else
68
+			} else
70 69
 			{
71 70
 				$context->getLogger()->log( sprintf( 'Invalid JSON encode message: %1$s', $msg->getBody() ) );
72 71
 			}
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Product/Import/Csv/Standard.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -499,7 +499,7 @@
 block discarded – undo
499 499
 	 *
500 500
 	 * @param array $products List of products items implementing \Aimeos\MShop\Product\Item\Iface
501 501
 	 * @param array $data Associative list of import data as index/value pairs
502
-	 * @param array $mappings Associative list of positions and domain item keys
502
+	 * @param array $mapping Associative list of positions and domain item keys
503 503
 	 * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor Processor object
504 504
 	 * @param boolean $strict Log columns not mapped or silently ignore them
505 505
 	 * @return integer Number of products that couldn't be imported
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 		 * @see controller/jobs/product/import/csv/container/type
426 426
 		 * @see controller/jobs/product/import/csv/container/content
427 427
 		 * @see controller/jobs/product/import/csv/container/options
428
-		*/
428
+		 */
429 429
 		$location = $config->get( 'controller/jobs/product/import/csv/location', '.' );
430 430
 
431 431
 		/** controller/jobs/product/import/csv/container/type
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 		 * @see controller/jobs/product/import/csv/location
449 449
 		 * @see controller/jobs/product/import/csv/container/content
450 450
 		 * @see controller/jobs/product/import/csv/container/options
451
-		*/
451
+		 */
452 452
 		$container = $config->get( 'controller/jobs/product/import/csv/container/type', 'Directory' );
453 453
 
454 454
 		/** controller/jobs/product/import/csv/container/content
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 		 * @see controller/jobs/product/import/csv/location
470 470
 		 * @see controller/jobs/product/import/csv/container/type
471 471
 		 * @see controller/jobs/product/import/csv/container/options
472
-		*/
472
+		 */
473 473
 		$content = $config->get( 'controller/jobs/product/import/csv/container/content', 'CSV' );
474 474
 
475 475
 		/** controller/jobs/product/import/csv/container/options
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 		 * @see controller/jobs/product/import/csv/location
488 488
 		 * @see controller/jobs/product/import/csv/container/content
489 489
 		 * @see controller/jobs/product/import/csv/container/type
490
-		*/
490
+		 */
491 491
 		$options = $config->get( 'controller/jobs/product/import/csv/container/options', array() );
492 492
 
493 493
 		return \Aimeos\MW\Container\Factory::getContainer( $location, $container, $content, $options );
Please login to merge, or discard this patch.
Spacing   +68 added lines, -68 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', 'Product import CSV' );
31
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Product 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 products from CSV files' );
42
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Imports new and updates existing products 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( 'attribute', 'media', 'price', 'product', 'text' );
57
+		$domains = array('attribute', 'media', 'price', 'product', 'text');
58 58
 		$mappings = $this->getDefaultMapping();
59 59
 
60 60
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 		 * @see controller/common/product/import/csv/converter
75 75
 		 * @see controller/common/product/import/csv/max-size
76 76
 		 */
77
-		$domains = $config->get( 'controller/common/product/import/csv/domains', $domains );
77
+		$domains = $config->get('controller/common/product/import/csv/domains', $domains);
78 78
 
79 79
 		/** controller/jobs/product/import/csv/domains
80 80
 		 * List of item domain names that should be retrieved along with the product items
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 		 * @see controller/jobs/product/import/csv/backup
95 95
 		 * @see controller/common/product/import/csv/max-size
96 96
 		 */
97
-		$domains = $config->get( 'controller/jobs/product/import/csv/domains', $domains );
97
+		$domains = $config->get('controller/jobs/product/import/csv/domains', $domains);
98 98
 
99 99
 
100 100
 		/** controller/common/product/import/csv/mapping
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 		 * @see controller/common/product/import/csv/converter
123 123
 		 * @see controller/common/product/import/csv/max-size
124 124
 		 */
125
-		$mappings = $config->get( 'controller/common/product/import/csv/mapping', $mappings );
125
+		$mappings = $config->get('controller/common/product/import/csv/mapping', $mappings);
126 126
 
127 127
 		/** controller/jobs/product/import/csv/mapping
128 128
 		 * List of mappings between the position in the CSV file and item keys
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 		 * @see controller/jobs/product/import/csv/backup
143 143
 		 * @see controller/common/product/import/csv/max-size
144 144
 		 */
145
-		$mappings = $config->get( 'controller/jobs/product/import/csv/mapping', $mappings );
145
+		$mappings = $config->get('controller/jobs/product/import/csv/mapping', $mappings);
146 146
 
147 147
 
148 148
 		/** controller/common/product/import/csv/converter
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 		 * @see controller/common/product/import/csv/mapping
185 185
 		 * @see controller/common/product/import/csv/max-size
186 186
 		 */
187
-		$converters = $config->get( 'controller/common/product/import/csv/converter', array() );
187
+		$converters = $config->get('controller/common/product/import/csv/converter', array());
188 188
 
189 189
 		/** controller/jobs/product/import/csv/converter
190 190
 		 * List of converter names for the values at the position in the CSV file
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 		 * @see controller/jobs/product/import/csv/backup
205 205
 		 * @see controller/common/product/import/csv/max-size
206 206
 		 */
207
-		$converters = $config->get( 'controller/jobs/product/import/csv/converter', $converters );
207
+		$converters = $config->get('controller/jobs/product/import/csv/converter', $converters);
208 208
 
209 209
 
210 210
 		/** controller/common/product/import/csv/max-size
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 		 * @see controller/common/product/import/csv/mapping
225 225
 		 * @see controller/common/product/import/csv/converter
226 226
 		 */
227
-		$maxcnt = (int) $config->get( 'controller/common/product/import/csv/max-size', 1000 );
227
+		$maxcnt = (int) $config->get('controller/common/product/import/csv/max-size', 1000);
228 228
 
229 229
 
230 230
 		/** controller/jobs/product/import/csv/skip-lines
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 		 * @see controller/jobs/product/import/csv/backup
247 247
 		 * @see controller/common/product/import/csv/max-size
248 248
 		 */
249
-		$skiplines = (int) $config->get( 'controller/jobs/product/import/csv/skip-lines', 0 );
249
+		$skiplines = (int) $config->get('controller/jobs/product/import/csv/skip-lines', 0);
250 250
 
251 251
 
252 252
 		/** controller/jobs/product/import/csv/strict
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 		 * @see controller/jobs/product/import/csv/backup
271 271
 		 * @see controller/common/product/import/csv/max-size
272 272
 		 */
273
-		$strict = (bool) $config->get( 'controller/jobs/product/import/csv/strict', true );
273
+		$strict = (bool) $config->get('controller/jobs/product/import/csv/strict', true);
274 274
 
275 275
 
276 276
 		/** controller/jobs/product/import/csv/backup
@@ -303,74 +303,74 @@  discard block
 block discarded – undo
303 303
 		 * @see controller/jobs/product/import/csv/strict
304 304
 		 * @see controller/common/product/import/csv/max-size
305 305
 		 */
306
-		$backup = $config->get( 'controller/jobs/product/import/csv/backup' );
306
+		$backup = $config->get('controller/jobs/product/import/csv/backup');
307 307
 
308 308
 
309
-		if( !isset( $mappings['item'] ) || !is_array( $mappings['item'] ) )
309
+		if (!isset($mappings['item']) || !is_array($mappings['item']))
310 310
 		{
311
-			$msg = sprintf( 'Required mapping key "%1$s" is missing or contains no array', 'item' );
312
-			throw new \Aimeos\Controller\Jobs\Exception( $msg );
311
+			$msg = sprintf('Required mapping key "%1$s" is missing or contains no array', 'item');
312
+			throw new \Aimeos\Controller\Jobs\Exception($msg);
313 313
 		}
314 314
 
315 315
 		try
316 316
 		{
317 317
 			$procMappings = $mappings;
318
-			unset( $procMappings['item'] );
318
+			unset($procMappings['item']);
319 319
 
320
-			$codePos = $this->getCodePosition( $mappings['item'] );
321
-			$convlist = $this->getConverterList( $converters );
322
-			$processor = $this->getProcessors( $procMappings );
320
+			$codePos = $this->getCodePosition($mappings['item']);
321
+			$convlist = $this->getConverterList($converters);
322
+			$processor = $this->getProcessors($procMappings);
323 323
 			$container = $this->getContainer();
324 324
 			$path = $container->getName();
325 325
 
326
-			$msg = sprintf( 'Started product import from "%1$s" (%2$s)', $path, __CLASS__ );
327
-			$logger->log( $msg, \Aimeos\MW\Logger\Base::NOTICE );
326
+			$msg = sprintf('Started product import from "%1$s" (%2$s)', $path, __CLASS__);
327
+			$logger->log($msg, \Aimeos\MW\Logger\Base::NOTICE);
328 328
 
329
-			foreach( $container as $content )
329
+			foreach ($container as $content)
330 330
 			{
331 331
 				$name = $content->getName();
332 332
 
333
-				for( $i = 0; $i < $skiplines; $i++ ) {
333
+				for ($i = 0; $i < $skiplines; $i++) {
334 334
 					$content->next();
335 335
 				}
336 336
 
337
-				while( ( $data = $this->getData( $content, $maxcnt, $codePos ) ) !== array() )
337
+				while (($data = $this->getData($content, $maxcnt, $codePos)) !== array())
338 338
 				{
339
-					$data = $this->convertData( $convlist, $data );
340
-					$products = $this->getProducts( array_keys( $data ), $domains );
341
-					$errcnt = $this->import( $products, $data, $mappings['item'], $processor, $strict );
342
-					$chunkcnt = count( $data );
339
+					$data = $this->convertData($convlist, $data);
340
+					$products = $this->getProducts(array_keys($data), $domains);
341
+					$errcnt = $this->import($products, $data, $mappings['item'], $processor, $strict);
342
+					$chunkcnt = count($data);
343 343
 
344 344
 					$msg = 'Imported product lines from "%1$s": %2$d/%3$d (%4$s)';
345
-					$logger->log( sprintf( $msg, $name, $chunkcnt - $errcnt, $chunkcnt, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE );
345
+					$logger->log(sprintf($msg, $name, $chunkcnt - $errcnt, $chunkcnt, __CLASS__), \Aimeos\MW\Logger\Base::NOTICE);
346 346
 
347 347
 					$errors += $errcnt;
348 348
 					$total += $chunkcnt;
349
-					unset( $products, $data );
349
+					unset($products, $data);
350 350
 				}
351 351
 			}
352 352
 
353 353
 			$container->close();
354 354
 		}
355
-		catch( \Exception $e )
355
+		catch (\Exception $e)
356 356
 		{
357
-			$logger->log( 'Product import error: ' . $e->getMessage() );
358
-			$logger->log( $e->getTraceAsString() );
357
+			$logger->log('Product import error: ' . $e->getMessage());
358
+			$logger->log($e->getTraceAsString());
359 359
 
360
-			throw new \Aimeos\Controller\Jobs\Exception( $e->getMessage() );
360
+			throw new \Aimeos\Controller\Jobs\Exception($e->getMessage());
361 361
 		}
362 362
 
363 363
 		$msg = 'Finished product import from "%1$s": %2$d successful, %3$s errors, %4$s total (%5$s)';
364
-		$logger->log( sprintf( $msg, $path, $total - $errors, $errors, $total, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE );
364
+		$logger->log(sprintf($msg, $path, $total - $errors, $errors, $total, __CLASS__), \Aimeos\MW\Logger\Base::NOTICE);
365 365
 
366
-		if( $errors > 0 )
366
+		if ($errors > 0)
367 367
 		{
368
-			$msg = sprintf( 'Invalid product lines in "%1$s": %2$d/%3$d', $path, $errors, $total );
369
-			throw new \Aimeos\Controller\Jobs\Exception( $msg );
368
+			$msg = sprintf('Invalid product lines in "%1$s": %2$d/%3$d', $path, $errors, $total);
369
+			throw new \Aimeos\Controller\Jobs\Exception($msg);
370 370
 		}
371 371
 
372
-		if( !empty( $backup ) && @rename( $path, strftime( $backup ) ) === false ) {
373
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Unable to move imported file' ) );
372
+		if (!empty($backup) && @rename($path, strftime($backup)) === false) {
373
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('Unable to move imported file'));
374 374
 		}
375 375
 	}
376 376
 
@@ -382,16 +382,16 @@  discard block
 block discarded – undo
382 382
 	 * @return integer Position of the "product.code" column
383 383
 	 * @throws \Aimeos\Controller\Jobs\Exception If no mapping for "product.code" is found
384 384
 	 */
385
-	protected function getCodePosition( array $mapping )
385
+	protected function getCodePosition(array $mapping)
386 386
 	{
387
-		foreach( $mapping as $pos => $key )
387
+		foreach ($mapping as $pos => $key)
388 388
 		{
389
-			if( $key === 'product.code' ) {
389
+			if ($key === 'product.code') {
390 390
 				return $pos;
391 391
 			}
392 392
 		}
393 393
 
394
-		throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'No "product.code" column in CSV mapping found' ) );
394
+		throw new \Aimeos\Controller\Jobs\Exception(sprintf('No "product.code" column in CSV mapping found'));
395 395
 	}
396 396
 
397 397
 
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 		 * @see controller/jobs/product/import/csv/container/content
427 427
 		 * @see controller/jobs/product/import/csv/container/options
428 428
 		*/
429
-		$location = $config->get( 'controller/jobs/product/import/csv/location', '.' );
429
+		$location = $config->get('controller/jobs/product/import/csv/location', '.');
430 430
 
431 431
 		/** controller/jobs/product/import/csv/container/type
432 432
 		 * Nave of the container type to read the data from
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
 		 * @see controller/jobs/product/import/csv/container/content
450 450
 		 * @see controller/jobs/product/import/csv/container/options
451 451
 		*/
452
-		$container = $config->get( 'controller/jobs/product/import/csv/container/type', 'Directory' );
452
+		$container = $config->get('controller/jobs/product/import/csv/container/type', 'Directory');
453 453
 
454 454
 		/** controller/jobs/product/import/csv/container/content
455 455
 		 * Name of the content type inside the container to read the data from
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 		 * @see controller/jobs/product/import/csv/container/type
471 471
 		 * @see controller/jobs/product/import/csv/container/options
472 472
 		*/
473
-		$content = $config->get( 'controller/jobs/product/import/csv/container/content', 'CSV' );
473
+		$content = $config->get('controller/jobs/product/import/csv/container/content', 'CSV');
474 474
 
475 475
 		/** controller/jobs/product/import/csv/container/options
476 476
 		 * List of file container options for the product import files
@@ -488,9 +488,9 @@  discard block
 block discarded – undo
488 488
 		 * @see controller/jobs/product/import/csv/container/content
489 489
 		 * @see controller/jobs/product/import/csv/container/type
490 490
 		*/
491
-		$options = $config->get( 'controller/jobs/product/import/csv/container/options', array() );
491
+		$options = $config->get('controller/jobs/product/import/csv/container/options', array());
492 492
 
493
-		return \Aimeos\MW\Container\Factory::getContainer( $location, $container, $content, $options );
493
+		return \Aimeos\MW\Container\Factory::getContainer($location, $container, $content, $options);
494 494
 	}
495 495
 
496 496
 
@@ -505,14 +505,14 @@  discard block
 block discarded – undo
505 505
 	 * @return integer Number of products that couldn't be imported
506 506
 	 * @throws \Aimeos\Controller\Jobs\Exception
507 507
 	 */
508
-	protected function import( array $products, array $data, array $mapping,
509
-		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor, $strict )
508
+	protected function import(array $products, array $data, array $mapping,
509
+		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor, $strict)
510 510
 	{
511 511
 		$errors = 0;
512 512
 		$context = $this->getContext();
513
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'product' );
513
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'product');
514 514
 
515
-		foreach( $data as $code => $list )
515
+		foreach ($data as $code => $list)
516 516
 		{
517 517
 			$remaining = array();
518 518
 
@@ -520,36 +520,36 @@  discard block
 block discarded – undo
520 520
 
521 521
 			try
522 522
 			{
523
-				if( isset( $products[$code] ) ) {
523
+				if (isset($products[$code])) {
524 524
 					$product = $products[$code];
525 525
 				} else {
526 526
 					$product = $manager->createItem();
527 527
 				}
528 528
 
529
-				$map = $this->getMappedData( $mapping, $list );
529
+				$map = $this->getMappedData($mapping, $list);
530 530
 
531
-				$typecode = ( isset( $map['product.type'] ) ? $map['product.type'] : 'default' );
532
-				$map['product.typeid'] = $this->getTypeId( 'product/type', 'product', $typecode );
531
+				$typecode = (isset($map['product.type']) ? $map['product.type'] : 'default');
532
+				$map['product.typeid'] = $this->getTypeId('product/type', 'product', $typecode);
533 533
 
534
-				$product->fromArray( $this->addItemDefaults( $map ) );
535
-				$manager->saveItem( $product );
534
+				$product->fromArray($this->addItemDefaults($map));
535
+				$manager->saveItem($product);
536 536
 
537
-				$remaining = $processor->process( $product, $list );
537
+				$remaining = $processor->process($product, $list);
538 538
 
539 539
 				$manager->commit();
540 540
 			}
541
-			catch( \Exception $e )
541
+			catch (\Exception $e)
542 542
 			{
543 543
 				$manager->rollback();
544 544
 
545
-				$msg = sprintf( 'Unable to import product with code "%1$s": %2$s', $code, $e->getMessage() );
546
-				$context->getLogger()->log( $msg );
545
+				$msg = sprintf('Unable to import product with code "%1$s": %2$s', $code, $e->getMessage());
546
+				$context->getLogger()->log($msg);
547 547
 
548 548
 				$errors++;
549 549
 			}
550 550
 
551
-			if( $strict && !empty( $remaining ) ) {
552
-				$context->getLogger()->log( 'Not imported: ' . print_r( $remaining, true ) );
551
+			if ($strict && !empty($remaining)) {
552
+				$context->getLogger()->log('Not imported: ' . print_r($remaining, true));
553 553
 			}
554 554
 		}
555 555
 
@@ -563,9 +563,9 @@  discard block
 block discarded – undo
563 563
 	 * @param array $list Associative list of domain item keys and their values, e.g. "product.status" => 1
564 564
 	 * @return array Given associative list enriched by default values if they were not already set
565 565
 	 */
566
-	protected function addItemDefaults( array $list )
566
+	protected function addItemDefaults(array $list)
567 567
 	{
568
-		if( !isset( $list['product.status'] ) ) {
568
+		if (!isset($list['product.status'])) {
569 569
 			$list['product.status'] = 1;
570 570
 		}
571 571
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -351,8 +351,7 @@  discard block
 block discarded – undo
351 351
 			}
352 352
 
353 353
 			$container->close();
354
-		}
355
-		catch( \Exception $e )
354
+		} catch( \Exception $e )
356 355
 		{
357 356
 			$logger->log( 'Product import error: ' . $e->getMessage() );
358 357
 			$logger->log( $e->getTraceAsString() );
@@ -537,8 +536,7 @@  discard block
 block discarded – undo
537 536
 				$remaining = $processor->process( $product, $list );
538 537
 
539 538
 				$manager->commit();
540
-			}
541
-			catch( \Exception $e )
539
+			} catch( \Exception $e )
542 540
 			{
543 541
 				$manager->rollback();
544 542
 
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Processor/Stock/Standard.php 2 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
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
-		$this->cache = $this->getCache( 'warehouse' );
50
+		$this->cache = $this->getCache('warehouse');
51 51
 	}
52 52
 
53 53
 
@@ -58,55 +58,55 @@  discard block
 block discarded – undo
58 58
 	 * @param array $data List of CSV fields with position as key and data as value
59 59
 	 * @return array List of data which hasn't been imported
60 60
 	 */
61
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
61
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
62 62
 	{
63
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/stock' );
63
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/stock');
64 64
 		$manager->begin();
65 65
 
66 66
 		try
67 67
 		{
68 68
 			$pos = 0;
69 69
 			$delete = array();
70
-			$map = $this->getMappedChunk( $data );
71
-			$items = $this->getStockItems( $product->getId() );
70
+			$map = $this->getMappedChunk($data);
71
+			$items = $this->getStockItems($product->getId());
72 72
 
73
-			foreach( $map as $pos => $list )
73
+			foreach ($map as $pos => $list)
74 74
 			{
75
-				if( !array_key_exists( 'product.stock.stocklevel', $list ) ) {
75
+				if (!array_key_exists('product.stock.stocklevel', $list)) {
76 76
 					continue;
77 77
 				}
78 78
 
79
-				$whcode = ( isset( $list['product.stock.warehouse'] ) ? $list['product.stock.warehouse'] : 'default' );
79
+				$whcode = (isset($list['product.stock.warehouse']) ? $list['product.stock.warehouse'] : 'default');
80 80
 
81
-				if( !isset( $list['product.stock.warehouseid'] ) ) {
82
-					$list['product.stock.warehouseid'] = $this->cache->get( $whcode );
81
+				if (!isset($list['product.stock.warehouseid'])) {
82
+					$list['product.stock.warehouseid'] = $this->cache->get($whcode);
83 83
 				}
84 84
 
85
-				if( isset( $list['product.stock.dateback'] ) && $list['product.stock.dateback'] === '' ) {
85
+				if (isset($list['product.stock.dateback']) && $list['product.stock.dateback'] === '') {
86 86
 					$list['product.stock.dateback'] = null;
87 87
 				}
88 88
 
89
-				if( $list['product.stock.stocklevel'] === '' ) {
89
+				if ($list['product.stock.stocklevel'] === '') {
90 90
 					$list['product.stock.stocklevel'] = null;
91 91
 				}
92 92
 
93 93
 				$list['product.stock.parentid'] = $product->getId();
94 94
 
95
-				if( ( $item = array_pop( $items ) ) === null ) {
95
+				if (($item = array_pop($items)) === null) {
96 96
 					$item = $manager->createItem();
97 97
 				}
98 98
 
99
-				$item->fromArray( $list );
100
-				$manager->saveItem( $item );
99
+				$item->fromArray($list);
100
+				$manager->saveItem($item);
101 101
 			}
102 102
 
103
-			$manager->deleteItems( array_keys( $items ) );
103
+			$manager->deleteItems(array_keys($items));
104 104
 
105
-			$remaining = $this->getObject()->process( $product, $data );
105
+			$remaining = $this->getObject()->process($product, $data);
106 106
 
107 107
 			$manager->commit();
108 108
 		}
109
-		catch( \Exception $e )
109
+		catch (\Exception $e)
110 110
 		{
111 111
 			$manager->rollback();
112 112
 			throw $e;
@@ -122,13 +122,13 @@  discard block
 block discarded – undo
122 122
 	 * @param string $prodid Unique product ID
123 123
 	 * @return array Associative list of product stock items
124 124
 	 */
125
-	protected function getStockItems( $prodid )
125
+	protected function getStockItems($prodid)
126 126
 	{
127
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/stock' );
127
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/stock');
128 128
 
129 129
 		$search = $manager->createSearch();
130
-		$search->setConditions( $search->compare( '==', 'product.stock.parentid', $prodid ) );
130
+		$search->setConditions($search->compare('==', 'product.stock.parentid', $prodid));
131 131
 
132
-		return $manager->searchItems( $search );
132
+		return $manager->searchItems($search);
133 133
 	}
134 134
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -129,8 +129,7 @@
 block discarded – undo
129 129
 			$remaining = $this->getObject()->process( $product, $data );
130 130
 
131 131
 			$manager->commit();
132
-		}
133
-		catch( \Exception $e )
132
+		} catch( \Exception $e )
134 133
 		{
135 134
 			$manager->rollback();
136 135
 			throw $e;
Please login to merge, or discard this patch.
common/src/Controller/Common/Product/Import/Csv/Processor/Done.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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 $product, array $data )
43
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
44 44
 	{
45 45
 		return $data;
46 46
 	}
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Processor/Attribute/Standard.php 2 patches
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/attribute/listtypes
52 52
 		 * Names of the product list types for attributes that are updated or removed
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
 		 * @see controller/common/product/import/csv/processor/price/listtypes
68 68
 		 * @see controller/common/product/import/csv/processor/text/listtypes
69 69
 		 */
70
-		$this->listTypes = $context->getConfig()->get( 'controller/common/product/import/csv/processor/attribute/listtypes');
70
+		$this->listTypes = $context->getConfig()->get('controller/common/product/import/csv/processor/attribute/listtypes');
71 71
 
72
-		$this->cache = $this->getCache( 'attribute' );
72
+		$this->cache = $this->getCache('attribute');
73 73
 	}
74 74
 
75 75
 
@@ -80,12 +80,12 @@  discard block
 block discarded – undo
80 80
 	 * @param array $data List of CSV fields with position as key and data as value
81 81
 	 * @return array List of data which hasn't been imported
82 82
 	 */
83
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
83
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
84 84
 	{
85 85
 		$context = $this->getContext();
86
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'attribute' );
87
-		$listManager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' );
88
-		$separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" );
86
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'attribute');
87
+		$listManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists');
88
+		$separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n");
89 89
 
90 90
 		$manager->begin();
91 91
 
@@ -93,25 +93,25 @@  discard block
 block discarded – undo
93 93
 		{
94 94
 			$pos = 0;
95 95
 			$delete = $attrcodes = array();
96
-			$map = $this->getMappedChunk( $data );
97
-			$listItems = $product->getListItems( 'attribute', $this->listTypes );
96
+			$map = $this->getMappedChunk($data);
97
+			$listItems = $product->getListItems('attribute', $this->listTypes);
98 98
 
99
-			foreach( $listItems as $listId => $listItem )
99
+			foreach ($listItems as $listId => $listItem)
100 100
 			{
101
-				if( isset( $map[$pos] ) )
101
+				if (isset($map[$pos]))
102 102
 				{
103
-					if( !isset( $map[$pos]['attribute.code'] ) || !isset( $map[$pos]['attribute.type'] ) )
103
+					if (!isset($map[$pos]['attribute.code']) || !isset($map[$pos]['attribute.type']))
104 104
 					{
105
-						unset( $map[$pos] );
105
+						unset($map[$pos]);
106 106
 						continue;
107 107
 					}
108 108
 
109 109
 					$refItem = $listItem->getRefItem();
110 110
 
111
-					if( $refItem !== null && $map[$pos]['attribute.code'] === $refItem->getCode()
111
+					if ($refItem !== null && $map[$pos]['attribute.code'] === $refItem->getCode()
112 112
 						&& $map[$pos]['attribute.type'] === $refItem->getType()
113
-						&& ( !isset( $map[$pos]['product.lists.type'] ) || isset( $map[$pos]['product.lists.type'] )
114
-						&& $map[$pos]['product.lists.type'] === $listItem->getType() )
113
+						&& (!isset($map[$pos]['product.lists.type']) || isset($map[$pos]['product.lists.type'])
114
+						&& $map[$pos]['product.lists.type'] === $listItem->getType())
115 115
 					) {
116 116
 						$pos++;
117 117
 						continue;
@@ -123,46 +123,46 @@  discard block
 block discarded – undo
123 123
 				$pos++;
124 124
 			}
125 125
 
126
-			$listManager->deleteItems( $delete );
126
+			$listManager->deleteItems($delete);
127 127
 
128
-			foreach( $map as $pos => $list )
128
+			foreach ($map as $pos => $list)
129 129
 			{
130
-				if( !isset( $list['attribute.code'] ) || $list['attribute.code'] === '' || $list['attribute.type'] === ''
131
-					|| isset( $list['product.lists.type'] ) && $this->listTypes !== null
132
-					&& !in_array( $list['product.lists.type'], (array) $this->listTypes )
130
+				if (!isset($list['attribute.code']) || $list['attribute.code'] === '' || $list['attribute.type'] === ''
131
+					|| isset($list['product.lists.type']) && $this->listTypes !== null
132
+					&& !in_array($list['product.lists.type'], (array) $this->listTypes)
133 133
 				) {
134 134
 					continue;
135 135
 				}
136 136
 
137
-				$codes = explode( $separator, $list['attribute.code'] );
137
+				$codes = explode($separator, $list['attribute.code']);
138 138
 
139
-				foreach( $codes as $code )
139
+				foreach ($codes as $code)
140 140
 				{
141
-					$attrItem = $this->getAttributeItem( $code, $list['attribute.type'] );
142
-					$attrItem->fromArray( $list );
143
-					$attrItem->setCode( $code );
144
-					$manager->saveItem( $attrItem );
141
+					$attrItem = $this->getAttributeItem($code, $list['attribute.type']);
142
+					$attrItem->fromArray($list);
143
+					$attrItem->setCode($code);
144
+					$manager->saveItem($attrItem);
145 145
 
146
-					if( ( $listItem = array_shift( $listItems ) ) === null ) {
146
+					if (($listItem = array_shift($listItems)) === null) {
147 147
 						$listItem = $listManager->createItem();
148 148
 					}
149 149
 
150
-					$typecode = ( isset( $list['product.lists.type'] ) ? $list['product.lists.type'] : 'default' );
151
-					$list['product.lists.typeid'] = $this->getTypeId( 'product/lists/type', 'attribute', $typecode );
150
+					$typecode = (isset($list['product.lists.type']) ? $list['product.lists.type'] : 'default');
151
+					$list['product.lists.typeid'] = $this->getTypeId('product/lists/type', 'attribute', $typecode);
152 152
 					$list['product.lists.refid'] = $attrItem->getId();
153 153
 					$list['product.lists.parentid'] = $product->getId();
154 154
 					$list['product.lists.domain'] = 'attribute';
155 155
 
156
-					$listItem->fromArray( $this->addListItemDefaults( $list, $pos ) );
157
-					$listManager->saveItem( $listItem );
156
+					$listItem->fromArray($this->addListItemDefaults($list, $pos));
157
+					$listManager->saveItem($listItem);
158 158
 				}
159 159
 			}
160 160
 
161
-			$remaining = $this->getObject()->process( $product, $data );
161
+			$remaining = $this->getObject()->process($product, $data);
162 162
 
163 163
 			$manager->commit();
164 164
 		}
165
-		catch( \Exception $e )
165
+		catch (\Exception $e)
166 166
 		{
167 167
 			$manager->rollback();
168 168
 			throw $e;
@@ -179,21 +179,21 @@  discard block
 block discarded – undo
179 179
 	 * @param string $type Attribute type
180 180
 	 * @return \Aimeos\MShop\Attribute\Item\Iface Attribute item object
181 181
 	 */
182
-	protected function getAttributeItem( $code, $type )
182
+	protected function getAttributeItem($code, $type)
183 183
 	{
184
-		if( ( $item = $this->cache->get( $code, $type ) ) === null )
184
+		if (($item = $this->cache->get($code, $type)) === null)
185 185
 		{
186
-			$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' );
186
+			$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute');
187 187
 
188 188
 			$item = $manager->createItem();
189
-			$item->setTypeId( $this->getTypeId( 'attribute/type', 'product', $type ) );
190
-			$item->setCode( $code );
191
-			$item->setLabel( $type . ' ' . $code );
192
-			$item->setStatus( 1 );
189
+			$item->setTypeId($this->getTypeId('attribute/type', 'product', $type));
190
+			$item->setCode($code);
191
+			$item->setLabel($type . ' ' . $code);
192
+			$item->setStatus(1);
193 193
 
194
-			$manager->saveItem( $item );
194
+			$manager->saveItem($item);
195 195
 
196
-			$this->cache->set( $item );
196
+			$this->cache->set($item);
197 197
 		}
198 198
 
199 199
 		return $item;
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -129,8 +129,7 @@
 block discarded – undo
129 129
 			$remaining = $this->getObject()->process( $product, $data );
130 130
 
131 131
 			$manager->commit();
132
-		}
133
-		catch( \Exception $e )
132
+		} catch( \Exception $e )
134 133
 		{
135 134
 			$manager->rollback();
136 135
 			throw $e;
Please login to merge, or discard this patch.
common/src/Controller/Common/Product/Import/Csv/Processor/Iface.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
27 27
 	 * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor Decorated processor
28 28
 	 */
29
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping,
30
-		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor = null );
29
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
30
+		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor = null);
31 31
 
32 32
 
33 33
 	/**
@@ -37,5 +37,5 @@  discard block
 block discarded – undo
37 37
 	 * @param array $data List of CSV fields with position as key and data as value
38 38
 	 * @return array List of data which hasn't been imported
39 39
 	 */
40
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data );
40
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data);
41 41
 }
42 42
\ No newline at end of file
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Processor/Catalog/Standard.php 2 patches
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/catalog/listtypes
52 52
 		 * Names of the catalog list types that are updated or removed
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
 		 * @see controller/common/product/import/csv/processor/product/listtypes
68 68
 		 * @see controller/common/product/import/csv/processor/text/listtypes
69 69
 		 */
70
-		$this->listTypes = $context->getConfig()->get( 'controller/common/product/import/csv/processor/catalog/listtypes' );
70
+		$this->listTypes = $context->getConfig()->get('controller/common/product/import/csv/processor/catalog/listtypes');
71 71
 
72
-		$this->cache = $this->getCache( 'catalog' );
72
+		$this->cache = $this->getCache('catalog');
73 73
 	}
74 74
 
75 75
 
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
 	 * @param array $data List of CSV fields with position as key and data as value
81 81
 	 * @return array List of data which hasn't been imported
82 82
 	 */
83
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
83
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
84 84
 	{
85 85
 		$context = $this->getContext();
86
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'catalog' );
87
-		$listManager = \Aimeos\MShop\Factory::createManager( $context, 'catalog/lists' );
86
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'catalog');
87
+		$listManager = \Aimeos\MShop\Factory::createManager($context, 'catalog/lists');
88 88
 
89 89
 		/** controller/common/product/import/csv/separator
90 90
 		 * Single separator character for multiple entries in one field of the import file
@@ -104,54 +104,54 @@  discard block
 block discarded – undo
104 104
 		 * @category Developer
105 105
 		 * @see controller/common/product/import/csv/domains
106 106
 		 */
107
-		$separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" );
107
+		$separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n");
108 108
 
109 109
 		$manager->begin();
110 110
 
111 111
 		try
112 112
 		{
113 113
 			$prodid = $product->getId();
114
-			$map = $this->getMappedChunk( $data );
115
-			$listItems = $this->getListItemPool( $product, $map );
114
+			$map = $this->getMappedChunk($data);
115
+			$listItems = $this->getListItemPool($product, $map);
116 116
 
117
-			foreach( $map as $pos => $list )
117
+			foreach ($map as $pos => $list)
118 118
 			{
119
-				if( !isset( $list['catalog.code'] ) || $list['catalog.code'] === '' || isset( $list['catalog.lists.type'] )
120
-					&& $this->listTypes !== null && !in_array( $list['catalog.lists.type'], (array) $this->listTypes )
119
+				if (!isset($list['catalog.code']) || $list['catalog.code'] === '' || isset($list['catalog.lists.type'])
120
+					&& $this->listTypes !== null && !in_array($list['catalog.lists.type'], (array) $this->listTypes)
121 121
 				) {
122 122
 					continue;
123 123
 				}
124 124
 
125
-				$codes = explode( $separator, $list['catalog.code'] );
126
-				$type = ( isset( $list['catalog.lists.type'] ) ? $list['catalog.lists.type'] : 'default' );
125
+				$codes = explode($separator, $list['catalog.code']);
126
+				$type = (isset($list['catalog.lists.type']) ? $list['catalog.lists.type'] : 'default');
127 127
 
128
-				foreach( $codes as $code )
128
+				foreach ($codes as $code)
129 129
 				{
130
-					if( ( $catid = $this->cache->get( $code ) ) === null )
130
+					if (($catid = $this->cache->get($code)) === null)
131 131
 					{
132 132
 						$msg = 'No category for code "%1$s" available when importing product with code "%2$s"';
133
-						throw new \Aimeos\Controller\Jobs\Exception( sprintf( $msg, $code, $product->getCode() ) );
133
+						throw new \Aimeos\Controller\Jobs\Exception(sprintf($msg, $code, $product->getCode()));
134 134
 					}
135 135
 
136
-					if( ( $listItem = array_shift( $listItems ) ) === null ) {
136
+					if (($listItem = array_shift($listItems)) === null) {
137 137
 						$listItem = $listManager->createItem();
138 138
 					}
139 139
 
140
-					$list['catalog.lists.typeid'] = $this->getTypeId( 'catalog/lists/type', 'product', $type );
140
+					$list['catalog.lists.typeid'] = $this->getTypeId('catalog/lists/type', 'product', $type);
141 141
 					$list['catalog.lists.parentid'] = $catid;
142 142
 					$list['catalog.lists.refid'] = $prodid;
143 143
 					$list['catalog.lists.domain'] = 'product';
144 144
 
145
-					$listItem->fromArray( $this->addListItemDefaults( $list, $pos++ ) );
146
-					$listManager->saveItem( $listItem );
145
+					$listItem->fromArray($this->addListItemDefaults($list, $pos++));
146
+					$listManager->saveItem($listItem);
147 147
 				}
148 148
 			}
149 149
 
150
-			$remaining = $this->getObject()->process( $product, $data );
150
+			$remaining = $this->getObject()->process($product, $data);
151 151
 
152 152
 			$manager->commit();
153 153
 		}
154
-		catch( \Exception $e )
154
+		catch (\Exception $e)
155 155
 		{
156 156
 			$manager->rollback();
157 157
 			throw $e;
@@ -168,13 +168,13 @@  discard block
 block discarded – undo
168 168
 	 * @param integer $pos Computed position of the list item in the associated list of items
169 169
 	 * @return array Given associative list enriched by default values if they were not already set
170 170
 	 */
171
-	protected function addListItemDefaults( array $list, $pos )
171
+	protected function addListItemDefaults(array $list, $pos)
172 172
 	{
173
-		if( !isset( $list['catalog.lists.position'] ) ) {
173
+		if (!isset($list['catalog.lists.position'])) {
174 174
 			$list['catalog.lists.position'] = $pos;
175 175
 		}
176 176
 
177
-		if( !isset( $list['catalog.lists.status'] ) ) {
177
+		if (!isset($list['catalog.lists.status'])) {
178 178
 			$list['catalog.lists.status'] = 1;
179 179
 		}
180 180
 
@@ -189,25 +189,25 @@  discard block
 block discarded – undo
189 189
 	 * @param array|null $types List of catalog list types
190 190
 	 * @return array List of catalog list items
191 191
 	 */
192
-	protected function getListItems( $prodid, $types )
192
+	protected function getListItems($prodid, $types)
193 193
 	{
194
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' );
194
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists');
195 195
 		$search = $manager->createSearch();
196 196
 
197 197
 		$expr = array(
198
-			$search->compare( '==', 'catalog.lists.domain', 'product' ),
199
-			$search->compare( '==', 'catalog.lists.refid', $prodid ),
198
+			$search->compare('==', 'catalog.lists.domain', 'product'),
199
+			$search->compare('==', 'catalog.lists.refid', $prodid),
200 200
 		);
201 201
 
202
-		if( $types !== null ) {
203
-			$expr[] = $search->compare( '==', 'catalog.lists.type.code', $types );
202
+		if ($types !== null) {
203
+			$expr[] = $search->compare('==', 'catalog.lists.type.code', $types);
204 204
 		}
205 205
 
206
-		$search->setConditions( $search->combine( '&&', $expr ) );
207
-		$search->setSortations( array( $search->sort( '+', 'catalog.lists.position' ) ) );
208
-		$search->setSlice( 0, 0x7FFFFFFF );
206
+		$search->setConditions($search->combine('&&', $expr));
207
+		$search->setSortations(array($search->sort('+', 'catalog.lists.position')));
208
+		$search->setSlice(0, 0x7FFFFFFF);
209 209
 
210
-		return $manager->searchItems( $search );
210
+		return $manager->searchItems($search);
211 211
 	}
212 212
 
213 213
 
@@ -218,16 +218,16 @@  discard block
 block discarded – undo
218 218
 	 * @param array $map List of associative arrays containing the chunked properties
219 219
 	 * @return array List of list items implementing \Aimeos\MShop\Common\Item\Lists\Iface
220 220
 	 */
221
-	protected function getListItemPool( \Aimeos\MShop\Product\Item\Iface $product, array $map )
221
+	protected function getListItemPool(\Aimeos\MShop\Product\Item\Iface $product, array $map)
222 222
 	{
223 223
 		$pos = 0;
224 224
 		$delete = array();
225
-		$listItems = $this->getListItems( $product->getId(), $this->listTypes );
225
+		$listItems = $this->getListItems($product->getId(), $this->listTypes);
226 226
 
227
-		foreach( $listItems as $listId => $listItem )
227
+		foreach ($listItems as $listId => $listItem)
228 228
 		{
229
-			if( isset( $map[$pos] ) && ( !isset( $map[$pos]['catalog.code'] )
230
-				|| $this->cache->get( $map[$pos]['catalog.code'] ) == $listItem->getParentId() )
229
+			if (isset($map[$pos]) && (!isset($map[$pos]['catalog.code'])
230
+				|| $this->cache->get($map[$pos]['catalog.code']) == $listItem->getParentId())
231 231
 			) {
232 232
 				$pos++;
233 233
 				continue;
@@ -238,8 +238,8 @@  discard block
 block discarded – undo
238 238
 			$pos++;
239 239
 		}
240 240
 
241
-		$listManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' );
242
-		$listManager->deleteItems( $delete );
241
+		$listManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists');
242
+		$listManager->deleteItems($delete);
243 243
 
244 244
 		return $listItems;
245 245
 	}
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -129,8 +129,7 @@
 block discarded – undo
129 129
 			$remaining = $this->getObject()->process( $product, $data );
130 130
 
131 131
 			$manager->commit();
132
-		}
133
-		catch( \Exception $e )
132
+		} catch( \Exception $e )
134 133
 		{
135 134
 			$manager->rollback();
136 135
 			throw $e;
Please login to merge, or discard this patch.