Completed
Push — master ( 9d2265...dea319 )
by Aimeos
9s
created
controller/jobs/src/Controller/Jobs/Media/Scale/Standard.php 1 patch
Spacing   +15 added lines, -15 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', 'Rescale product images' );
31
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Rescale product images');
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', 'Rescales product images to the new sizes' );
42
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Rescales product images to the new sizes');
43 43
 	}
44 44
 
45 45
 
@@ -50,33 +50,33 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	public function run()
52 52
 	{
53
-		$cntl = \Aimeos\Controller\Common\Media\Factory::createController( $this->getContext() );
54
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'media' );
53
+		$cntl = \Aimeos\Controller\Common\Media\Factory::createController($this->getContext());
54
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'media');
55 55
 
56 56
 		$search = $manager->createSearch();
57 57
 		$expr = array(
58
-			$search->compare( '==', 'media.domain', 'product' ),
59
-			$search->compare( '=~', 'media.mimetype', 'image/' ),
58
+			$search->compare('==', 'media.domain', 'product'),
59
+			$search->compare('=~', 'media.mimetype', 'image/'),
60 60
 		);
61
-		$search->setConditions( $search->combine( '&&', $expr ) );
62
-		$search->setSortations( array( $search->sort( '+', 'media.id' ) ) );
61
+		$search->setConditions($search->combine('&&', $expr));
62
+		$search->setSortations(array($search->sort('+', 'media.id')));
63 63
 
64 64
 		$start = 0;
65 65
 
66 66
 		do
67 67
 		{
68
-			$search->setSlice( $start );
69
-			$items = $manager->searchItems( $search );
68
+			$search->setSlice($start);
69
+			$items = $manager->searchItems($search);
70 70
 
71
-			foreach( $items as $item )
71
+			foreach ($items as $item)
72 72
 			{
73
-				$cntl->scale( $item, 'fs-media' );
74
-				$manager->saveItem( $item );
73
+				$cntl->scale($item, 'fs-media');
74
+				$manager->saveItem($item);
75 75
 			}
76 76
 
77
-			$count = count( $items );
77
+			$count = count($items);
78 78
 			$start += $count;
79 79
 		}
80
-		while( $count === $search->getSliceSize() );
80
+		while ($count === $search->getSliceSize());
81 81
 	}
82 82
 }
Please login to merge, or discard this patch.
controller/jobs/tests/Controller/Jobs/Media/Scale/StandardTest.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 		$context = \TestHelperJobs::getContext();
20 20
 		$aimeos = \TestHelperJobs::getAimeos();
21 21
 
22
-		$this->object = new \Aimeos\Controller\Jobs\Media\Scale\Standard( $context, $aimeos );
22
+		$this->object = new \Aimeos\Controller\Jobs\Media\Scale\Standard($context, $aimeos);
23 23
 	}
24 24
 
25 25
 
@@ -31,14 +31,14 @@  discard block
 block discarded – undo
31 31
 
32 32
 	public function testGetName()
33 33
 	{
34
-		$this->assertEquals( 'Rescale product images', $this->object->getName() );
34
+		$this->assertEquals('Rescale product images', $this->object->getName());
35 35
 	}
36 36
 
37 37
 
38 38
 	public function testGetDescription()
39 39
 	{
40 40
 		$text = 'Rescales product images to the new sizes';
41
-		$this->assertEquals( $text, $this->object->getDescription() );
41
+		$this->assertEquals($text, $this->object->getDescription());
42 42
 	}
43 43
 
44 44
 
@@ -49,31 +49,31 @@  discard block
 block discarded – undo
49 49
 
50 50
 
51 51
 		$name = 'ControllerJobsMediaScaleStandardRun';
52
-		$context->getConfig()->set( 'mshop/media/manager/name', $name );
53
-		$context->getConfig()->set( 'controller/common/media/name', $name );
52
+		$context->getConfig()->set('mshop/media/manager/name', $name);
53
+		$context->getConfig()->set('controller/common/media/name', $name);
54 54
 
55 55
 
56
-		$managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Media\\Manager\\Standard' )
57
-			->setMethods( array( 'saveItem' ) )
58
-			->setConstructorArgs( array( $context ) )
56
+		$managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Media\\Manager\\Standard')
57
+			->setMethods(array('saveItem'))
58
+			->setConstructorArgs(array($context))
59 59
 			->getMock();
60 60
 
61
-		\Aimeos\MShop\Media\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Media\\Manager\\' . $name, $managerStub );
61
+		\Aimeos\MShop\Media\Manager\Factory::injectManager('\\Aimeos\\MShop\\Media\\Manager\\' . $name, $managerStub);
62 62
 
63
-		$managerStub->expects( $this->atLeast( 1 ) )->method( 'saveItem' );
63
+		$managerStub->expects($this->atLeast(1))->method('saveItem');
64 64
 
65 65
 
66
-		$cntlStub = $this->getMockBuilder( '\\Aimeos\\Controller\\Common\\Media\\Standard' )
67
-			->setMethods( array( 'scale' ) )
68
-			->setConstructorArgs( array( $context ) )
66
+		$cntlStub = $this->getMockBuilder('\\Aimeos\\Controller\\Common\\Media\\Standard')
67
+			->setMethods(array('scale'))
68
+			->setConstructorArgs(array($context))
69 69
 			->getMock();
70 70
 
71
-		\Aimeos\Controller\Common\Media\Factory::injectController( '\\Aimeos\\Controller\\Common\\Media\\' . $name, $cntlStub );
71
+		\Aimeos\Controller\Common\Media\Factory::injectController('\\Aimeos\\Controller\\Common\\Media\\' . $name, $cntlStub);
72 72
 
73
-		$cntlStub->expects( $this->atLeast( 1 ) )->method( 'scale' );
73
+		$cntlStub->expects($this->atLeast(1))->method('scale');
74 74
 
75 75
 
76
-		$object = new \Aimeos\Controller\Jobs\Media\Scale\Standard( $context, $aimeos );
76
+		$object = new \Aimeos\Controller\Jobs\Media\Scale\Standard($context, $aimeos);
77 77
 		$object->run();
78 78
 	}
79 79
 }
Please login to merge, or discard this patch.
tests/Controller/Common/Product/Import/Csv/Processor/Stock/StandardTest.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -17,16 +17,16 @@  discard block
 block discarded – undo
17 17
 
18 18
 	protected function setUp()
19 19
 	{
20
-		\Aimeos\MShop\Factory::setCache( true );
20
+		\Aimeos\MShop\Factory::setCache(true);
21 21
 
22 22
 		$this->context = \TestHelperCntl::getContext();
23
-		$this->endpoint = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done( $this->context, array() );
23
+		$this->endpoint = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done($this->context, array());
24 24
 	}
25 25
 
26 26
 
27 27
 	protected function tearDown()
28 28
 	{
29
-		\Aimeos\MShop\Factory::setCache( false );
29
+		\Aimeos\MShop\Factory::setCache(false);
30 30
 		\Aimeos\MShop\Factory::clear();
31 31
 	}
32 32
 
@@ -43,21 +43,21 @@  discard block
 block discarded – undo
43 43
 			1 => '2000-01-01 00:00:00',
44 44
 		);
45 45
 
46
-		$product = $this->create( 'job_csv_test' );
46
+		$product = $this->create('job_csv_test');
47 47
 
48
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard( $this->context, $mapping, $this->endpoint );
49
-		$object->process( $product, $data );
48
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard($this->context, $mapping, $this->endpoint);
49
+		$object->process($product, $data);
50 50
 
51
-		$items = $this->getStockItems( $product->getCode() );
52
-		$this->delete( $product );
51
+		$items = $this->getStockItems($product->getCode());
52
+		$this->delete($product);
53 53
 
54 54
 
55
-		$this->assertEquals( 1, count( $items ) );
55
+		$this->assertEquals(1, count($items));
56 56
 
57
-		foreach( $items as $item )
57
+		foreach ($items as $item)
58 58
 		{
59
-			$this->assertEquals( 100, $item->getStocklevel() );
60
-			$this->assertEquals( '2000-01-01 00:00:00', $item->getDateBack() );
59
+			$this->assertEquals(100, $item->getStocklevel());
60
+			$this->assertEquals('2000-01-01 00:00:00', $item->getDateBack());
61 61
 		}
62 62
 	}
63 63
 
@@ -78,19 +78,19 @@  discard block
 block discarded – undo
78 78
 			3 => '200',
79 79
 		);
80 80
 
81
-		$product = $this->create( 'job_csv_test' );
81
+		$product = $this->create('job_csv_test');
82 82
 
83
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard( $this->context, $mapping, $this->endpoint );
84
-		$object->process( $product, $data );
83
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard($this->context, $mapping, $this->endpoint);
84
+		$object->process($product, $data);
85 85
 
86
-		$items = $this->getStockItems( $product->getCode() );
87
-		$this->delete( $product );
86
+		$items = $this->getStockItems($product->getCode());
87
+		$this->delete($product);
88 88
 
89 89
 
90
-		$this->assertEquals( 2, count( $items ) );
90
+		$this->assertEquals(2, count($items));
91 91
 
92
-		foreach( $items as $item ) {
93
-			$this->assertEquals( 200, $item->getStocklevel() );
92
+		foreach ($items as $item) {
93
+			$this->assertEquals(200, $item->getStocklevel());
94 94
 		}
95 95
 	}
96 96
 
@@ -109,21 +109,21 @@  discard block
 block discarded – undo
109 109
 			0 => '20',
110 110
 		);
111 111
 
112
-		$product = $this->create( 'job_csv_test' );
112
+		$product = $this->create('job_csv_test');
113 113
 
114
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard( $this->context, $mapping, $this->endpoint );
114
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard($this->context, $mapping, $this->endpoint);
115 115
 
116
-		$object->process( $product, $data );
117
-		$object->process( $product, $dataUpdate );
116
+		$object->process($product, $data);
117
+		$object->process($product, $dataUpdate);
118 118
 
119
-		$items = $this->getStockItems( $product->getCode() );
120
-		$this->delete( $product );
119
+		$items = $this->getStockItems($product->getCode());
120
+		$this->delete($product);
121 121
 
122 122
 
123
-		$item = reset( $items );
123
+		$item = reset($items);
124 124
 
125
-		$this->assertEquals( 1, count( $items ) );
126
-		$this->assertEquals( 20, $item->getStocklevel() );
125
+		$this->assertEquals(1, count($items));
126
+		$this->assertEquals(20, $item->getStocklevel());
127 127
 	}
128 128
 
129 129
 
@@ -137,19 +137,19 @@  discard block
 block discarded – undo
137 137
 			0 => 50,
138 138
 		);
139 139
 
140
-		$product = $this->create( 'job_csv_test' );
140
+		$product = $this->create('job_csv_test');
141 141
 
142
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard( $this->context, $mapping, $this->endpoint );
143
-		$object->process( $product, $data );
142
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard($this->context, $mapping, $this->endpoint);
143
+		$object->process($product, $data);
144 144
 
145
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard( $this->context, array(), $this->endpoint );
146
-		$object->process( $product, array() );
145
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard($this->context, array(), $this->endpoint);
146
+		$object->process($product, array());
147 147
 
148
-		$items = $this->getStockItems( $product->getCode() );
149
-		$this->delete( $product );
148
+		$items = $this->getStockItems($product->getCode());
149
+		$this->delete($product);
150 150
 
151 151
 
152
-		$this->assertEquals( 0, count( $items ) );
152
+		$this->assertEquals(0, count($items));
153 153
 	}
154 154
 
155 155
 
@@ -167,20 +167,20 @@  discard block
 block discarded – undo
167 167
 			2 => '',
168 168
 		);
169 169
 
170
-		$product = $this->create( 'job_csv_test' );
170
+		$product = $this->create('job_csv_test');
171 171
 
172
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard( $this->context, $mapping, $this->endpoint );
173
-		$object->process( $product, $data );
172
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard($this->context, $mapping, $this->endpoint);
173
+		$object->process($product, $data);
174 174
 
175
-		$items = $this->getStockItems( $product->getCode() );
176
-		$this->delete( $product );
175
+		$items = $this->getStockItems($product->getCode());
176
+		$this->delete($product);
177 177
 
178
-		$this->assertEquals( 1, count( $items ) );
178
+		$this->assertEquals(1, count($items));
179 179
 
180
-		foreach( $items as $item )
180
+		foreach ($items as $item)
181 181
 		{
182
-			$this->assertEquals( null, $item->getStocklevel() );
183
-			$this->assertEquals( null, $item->getDateBack() );
182
+			$this->assertEquals(null, $item->getStocklevel());
183
+			$this->assertEquals(null, $item->getDateBack());
184 184
 		}
185 185
 	}
186 186
 
@@ -188,43 +188,43 @@  discard block
 block discarded – undo
188 188
 	/**
189 189
 	 * @param string $code
190 190
 	 */
191
-	protected function create( $code )
191
+	protected function create($code)
192 192
 	{
193
-		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context );
194
-		$typeManager = $manager->getSubManager( 'type' );
193
+		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context);
194
+		$typeManager = $manager->getSubManager('type');
195 195
 
196 196
 		$typeSearch = $typeManager->createSearch();
197
-		$typeSearch->setConditions( $typeSearch->compare( '==', 'product.type.code', 'default' ) );
198
-		$typeResult = $typeManager->searchItems( $typeSearch );
197
+		$typeSearch->setConditions($typeSearch->compare('==', 'product.type.code', 'default'));
198
+		$typeResult = $typeManager->searchItems($typeSearch);
199 199
 
200
-		if( ( $typeItem = reset( $typeResult ) ) === false ) {
201
-			throw new \RuntimeException( 'No product type "default" found' );
200
+		if (($typeItem = reset($typeResult)) === false) {
201
+			throw new \RuntimeException('No product type "default" found');
202 202
 		}
203 203
 
204 204
 		$item = $manager->createItem();
205
-		$item->setTypeid( $typeItem->getId() );
206
-		$item->setCode( $code );
205
+		$item->setTypeid($typeItem->getId());
206
+		$item->setCode($code);
207 207
 
208
-		$manager->saveItem( $item );
208
+		$manager->saveItem($item);
209 209
 
210 210
 		return $item;
211 211
 	}
212 212
 
213 213
 
214
-	protected function delete( \Aimeos\MShop\Product\Item\Iface $product )
214
+	protected function delete(\Aimeos\MShop\Product\Item\Iface $product)
215 215
 	{
216
-		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context );
217
-		$manager->deleteItem( $product->getId() );
216
+		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context);
217
+		$manager->deleteItem($product->getId());
218 218
 	}
219 219
 
220 220
 
221
-	protected function getStockItems( $code )
221
+	protected function getStockItems($code)
222 222
 	{
223
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'stock' );
223
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'stock');
224 224
 
225 225
 		$search = $manager->createSearch();
226
-		$search->setConditions( $search->compare( '==', 'stock.productcode', $code ) );
226
+		$search->setConditions($search->compare('==', 'stock.productcode', $code));
227 227
 
228
-		return $manager->searchItems( $search );
228
+		return $manager->searchItems($search);
229 229
 	}
230 230
 }
231 231
\ No newline at end of file
Please login to merge, or discard this patch.
common/src/Controller/Common/Product/Import/Csv/Processor/Base.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -133,7 +133,7 @@
 block discarded – undo
133 133
 	 *
134 134
 	 * @param array $list Associative list of key/value pairs
135 135
 	 * @param string $key Key for the value to retrieve
136
-	 * @param mixed $default Default value if key isn't found
136
+	 * @param string $default Default value if key isn't found
137 137
 	 * @param mixed Value for the key in the list of the default value
138 138
 	 */
139 139
 	protected function getValue( array $list, $key, $default )
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 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\Product\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\Product\Import\Csv\Processor\Iface $object = null )
35
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
36
+		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null)
37 37
 	{
38 38
 		$this->context = $context;
39 39
 		$this->mapping = $mapping;
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 	 * @param integer $pos Computed position of the list item in the associated list of items
49 49
 	 * @return array Given associative list enriched by default values if they were not already set
50 50
 	 */
51
-	protected function addListItemDefaults( array $list, $pos )
51
+	protected function addListItemDefaults(array $list, $pos)
52 52
 	{
53
-		if( !isset( $list['product.lists.position'] ) ) {
53
+		if (!isset($list['product.lists.position'])) {
54 54
 			$list['product.lists.position'] = $pos;
55 55
 		}
56 56
 
57
-		if( !isset( $list['product.lists.status'] ) ) {
57
+		if (!isset($list['product.lists.status'])) {
58 58
 			$list['product.lists.status'] = 1;
59 59
 		}
60 60
 
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
 	 */
93 93
 	protected function getObject()
94 94
 	{
95
-		if( $this->object === null ) {
96
-			throw new \Aimeos\Controller\Jobs\Exception( 'No processor object available' );
95
+		if ($this->object === null) {
96
+			throw new \Aimeos\Controller\Jobs\Exception('No processor object available');
97 97
 		}
98 98
 
99 99
 		return $this->object;
@@ -108,8 +108,8 @@  discard block
 block discarded – undo
108 108
 	 * @param mixed $default Default value if key isn't found
109 109
 	 * @param mixed Value for the key in the list of the default value
110 110
 	 */
111
-	protected function getValue( array $list, $key, $default )
111
+	protected function getValue(array $list, $key, $default)
112 112
 	{
113
-		return ( isset( $list[$key] ) ? $list[$key] : $default );
113
+		return (isset($list[$key]) ? $list[$key] : $default);
114 114
 	}
115 115
 }
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Processor/Media/Standard.php 2 patches
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -42,10 +42,10 @@  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 50
 		/** controller/common/product/import/csv/processor/media/listtypes
51 51
 		 * Names of the product list types for media that are updated or removed
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 		 * @see controller/common/product/import/csv/processor/price/listtypes
67 67
 		 * @see controller/common/product/import/csv/processor/text/listtypes
68 68
 		 */
69
-		$this->listTypes = $context->getConfig()->get( 'controller/common/product/import/csv/processor/media/listtypes' );
69
+		$this->listTypes = $context->getConfig()->get('controller/common/product/import/csv/processor/media/listtypes');
70 70
 	}
71 71
 
72 72
 
@@ -77,45 +77,45 @@  discard block
 block discarded – undo
77 77
 	 * @param array $data List of CSV fields with position as key and data as value
78 78
 	 * @return array List of data which hasn't been imported
79 79
 	 */
80
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
80
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
81 81
 	{
82 82
 		$context = $this->getContext();
83
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'media' );
84
-		$listManager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' );
85
-		$separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" );
83
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'media');
84
+		$listManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists');
85
+		$separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n");
86 86
 
87 87
 		$manager->begin();
88 88
 
89 89
 		try
90 90
 		{
91 91
 			$delete = $listMap = array();
92
-			$map = $this->getMappedChunk( $data, $this->getMapping() );
93
-			$listItems = $product->getListItems( 'media', $this->listTypes );
92
+			$map = $this->getMappedChunk($data, $this->getMapping());
93
+			$listItems = $product->getListItems('media', $this->listTypes);
94 94
 
95
-			foreach( $listItems as $listItem )
95
+			foreach ($listItems as $listItem)
96 96
 			{
97
-				if( ( $refItem = $listItem->getRefItem() ) !== null ) {
98
-					$listMap[ $refItem->getUrl() ][ $refItem->getType() ][ $listItem->getType() ] = $listItem;
97
+				if (($refItem = $listItem->getRefItem()) !== null) {
98
+					$listMap[$refItem->getUrl()][$refItem->getType()][$listItem->getType()] = $listItem;
99 99
 				}
100 100
 			}
101 101
 
102
-			foreach( $map as $pos => $list )
102
+			foreach ($map as $pos => $list)
103 103
 			{
104
-				if( $this->checkEntry( $list ) === false ) {
104
+				if ($this->checkEntry($list) === false) {
105 105
 					continue;
106 106
 				}
107 107
 
108
-				$urls = explode( $separator, $list['media.url'] );
109
-				$type = $this->getValue( $list, 'media.type', 'default' );
110
-				$typecode = $this->getValue( $list, 'product.lists.type', 'default' );
108
+				$urls = explode($separator, $list['media.url']);
109
+				$type = $this->getValue($list, 'media.type', 'default');
110
+				$typecode = $this->getValue($list, 'product.lists.type', 'default');
111 111
 
112
-				foreach( $urls as $url )
112
+				foreach ($urls as $url)
113 113
 				{
114
-					if( isset( $listMap[$url][$type][$typecode] ) )
114
+					if (isset($listMap[$url][$type][$typecode]))
115 115
 					{
116 116
 						$listItem = $listMap[$url][$type][$typecode];
117 117
 						$refItem = $listItem->getRefItem();
118
-						unset( $listItems[ $listItem->getId() ] );
118
+						unset($listItems[$listItem->getId()]);
119 119
 					}
120 120
 					else
121 121
 					{
@@ -123,35 +123,35 @@  discard block
 block discarded – undo
123 123
 						$refItem = $manager->createItem();
124 124
 					}
125 125
 
126
-					$list['media.typeid'] = $this->getTypeId( 'media/type', 'product', $type );
126
+					$list['media.typeid'] = $this->getTypeId('media/type', 'product', $type);
127 127
 					$list['media.domain'] = 'product';
128 128
 					$list['media.url'] = $url;
129 129
 
130
-					$refItem->fromArray( $this->addItemDefaults( $list ) );
131
-					$manager->saveItem( $refItem );
130
+					$refItem->fromArray($this->addItemDefaults($list));
131
+					$manager->saveItem($refItem);
132 132
 
133
-					$list['product.lists.typeid'] = $this->getTypeId( 'product/lists/type', 'media', $typecode );
133
+					$list['product.lists.typeid'] = $this->getTypeId('product/lists/type', 'media', $typecode);
134 134
 					$list['product.lists.parentid'] = $product->getId();
135 135
 					$list['product.lists.refid'] = $refItem->getId();
136 136
 					$list['product.lists.domain'] = 'media';
137 137
 
138
-					$listItem->fromArray( $this->addListItemDefaults( $list, $pos++ ) );
139
-					$listManager->saveItem( $listItem );
138
+					$listItem->fromArray($this->addListItemDefaults($list, $pos++));
139
+					$listManager->saveItem($listItem);
140 140
 				}
141 141
 			}
142 142
 
143
-			foreach( $listItems as $listItem ) {
143
+			foreach ($listItems as $listItem) {
144 144
 				$delete[] = $listItem->getRefId();
145 145
 			}
146 146
 
147
-			$manager->deleteItems( $delete );
148
-			$listManager->deleteItems( array_keys( $listItems ) );
147
+			$manager->deleteItems($delete);
148
+			$listManager->deleteItems(array_keys($listItems));
149 149
 
150
-			$data = $this->getObject()->process( $product, $data );
150
+			$data = $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;
@@ -167,17 +167,17 @@  discard block
 block discarded – undo
167 167
 	 * @param array $list Associative list of domain item keys and their values, e.g. "media.status" => 1
168 168
 	 * @return array Given associative list enriched by default values if they were not already set
169 169
 	 */
170
-	protected function addItemDefaults( array $list )
170
+	protected function addItemDefaults(array $list)
171 171
 	{
172
-		if( !isset( $list['media.label'] ) ) {
172
+		if (!isset($list['media.label'])) {
173 173
 			$list['media.label'] = $list['media.url'];
174 174
 		}
175 175
 
176
-		if( !isset( $list['media.preview'] ) ) {
176
+		if (!isset($list['media.preview'])) {
177 177
 			$list['media.preview'] = $list['media.url'];
178 178
 		}
179 179
 
180
-		if( !isset( $list['media.status'] ) ) {
180
+		if (!isset($list['media.status'])) {
181 181
 			$list['media.status'] = 1;
182 182
 		}
183 183
 
@@ -191,10 +191,10 @@  discard block
 block discarded – undo
191 191
 	 * @param array $list Associative list of key/value pairs from the mapping
192 192
 	 * @return boolean True if valid, false if not
193 193
 	 */
194
-	protected function checkEntry( array $list )
194
+	protected function checkEntry(array $list)
195 195
 	{
196
-		if( !isset( $list['media.url'] ) || $list['media.url'] === '' || isset( $list['product.lists.type'] )
197
-				&& $this->listTypes !== null && !in_array( $list['product.lists.type'], (array) $this->listTypes )
196
+		if (!isset($list['media.url']) || $list['media.url'] === '' || isset($list['product.lists.type'])
197
+				&& $this->listTypes !== null && !in_array($list['product.lists.type'], (array) $this->listTypes)
198 198
 		) {
199 199
 			return false;
200 200
 		}
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -116,8 +116,7 @@  discard block
 block discarded – undo
116 116
 						$listItem = $listMap[$url][$type][$typecode];
117 117
 						$refItem = $listItem->getRefItem();
118 118
 						unset( $listItems[ $listItem->getId() ] );
119
-					}
120
-					else
119
+					} else
121 120
 					{
122 121
 						$listItem = $listManager->createItem();
123 122
 						$refItem = $manager->createItem();
@@ -150,8 +149,7 @@  discard block
 block discarded – undo
150 149
 			$data = $this->getObject()->process( $product, $data );
151 150
 
152 151
 			$manager->commit();
153
-		}
154
-		catch( \Exception $e )
152
+		} catch( \Exception $e )
155 153
 		{
156 154
 			$manager->rollback();
157 155
 			throw $e;
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Processor/Catalog/Standard.php 2 patches
Spacing   +44 added lines, -44 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,7 +104,7 @@  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
 
@@ -112,56 +112,56 @@  discard block
 block discarded – undo
112 112
 		{
113 113
 			$listMap = array();
114 114
 			$prodid = $product->getId();
115
-			$map = $this->getMappedChunk( $data, $this->getMapping() );
116
-			$listItems = $this->getListItems( $prodid, $this->listTypes );
115
+			$map = $this->getMappedChunk($data, $this->getMapping());
116
+			$listItems = $this->getListItems($prodid, $this->listTypes);
117 117
 
118
-			foreach( $listItems as $listItem ) {
119
-				$listMap[ $listItem->getParentId() ][ $listItem->getType() ] = $listItem;
118
+			foreach ($listItems as $listItem) {
119
+				$listMap[$listItem->getParentId()][$listItem->getType()] = $listItem;
120 120
 			}
121 121
 
122
-			foreach( $map as $pos => $list )
122
+			foreach ($map as $pos => $list)
123 123
 			{
124
-				if( $this->checkEntry( $list ) === false ) {
124
+				if ($this->checkEntry($list) === false) {
125 125
 					continue;
126 126
 				}
127 127
 
128
-				$codes = explode( $separator, $list['catalog.code'] );
129
-				$type = ( isset( $list['catalog.lists.type'] ) ? $list['catalog.lists.type'] : 'default' );
128
+				$codes = explode($separator, $list['catalog.code']);
129
+				$type = (isset($list['catalog.lists.type']) ? $list['catalog.lists.type'] : 'default');
130 130
 
131
-				foreach( $codes as $code )
131
+				foreach ($codes as $code)
132 132
 				{
133
-					if( ( $catid = $this->cache->get( $code ) ) === null )
133
+					if (($catid = $this->cache->get($code)) === null)
134 134
 					{
135 135
 						$msg = 'No category for code "%1$s" available when importing product with code "%2$s"';
136
-						throw new \Aimeos\Controller\Jobs\Exception( sprintf( $msg, $code, $product->getCode() ) );
136
+						throw new \Aimeos\Controller\Jobs\Exception(sprintf($msg, $code, $product->getCode()));
137 137
 					}
138 138
 
139
-					$list['catalog.lists.typeid'] = $this->getTypeId( 'catalog/lists/type', 'product', $type );
139
+					$list['catalog.lists.typeid'] = $this->getTypeId('catalog/lists/type', 'product', $type);
140 140
 					$list['catalog.lists.parentid'] = $catid;
141 141
 					$list['catalog.lists.refid'] = $prodid;
142 142
 					$list['catalog.lists.domain'] = 'product';
143 143
 
144
-					if( isset( $listMap[$catid][$type] ) )
144
+					if (isset($listMap[$catid][$type]))
145 145
 					{
146 146
 						$listItem = $listMap[$catid][$type];
147
-						unset( $listItems[ $listItem->getId() ] );
147
+						unset($listItems[$listItem->getId()]);
148 148
 					}
149 149
 					else
150 150
 					{
151 151
 						$listItem = $listManager->createItem();
152 152
 					}
153 153
 
154
-					$listItem->fromArray( $this->addListItemDefaults( $list, $pos++ ) );
155
-					$listManager->saveItem( $listItem );
154
+					$listItem->fromArray($this->addListItemDefaults($list, $pos++));
155
+					$listManager->saveItem($listItem);
156 156
 				}
157 157
 			}
158 158
 
159
-			$listManager->deleteItems( array_keys( $listItems ) );
160
-			$data = $this->getObject()->process( $product, $data );
159
+			$listManager->deleteItems(array_keys($listItems));
160
+			$data = $this->getObject()->process($product, $data);
161 161
 
162 162
 			$manager->commit();
163 163
 		}
164
-		catch( \Exception $e )
164
+		catch (\Exception $e)
165 165
 		{
166 166
 			$manager->rollback();
167 167
 			throw $e;
@@ -178,13 +178,13 @@  discard block
 block discarded – undo
178 178
 	 * @param integer $pos Computed position of the list item in the associated list of items
179 179
 	 * @return array Given associative list enriched by default values if they were not already set
180 180
 	 */
181
-	protected function addListItemDefaults( array $list, $pos )
181
+	protected function addListItemDefaults(array $list, $pos)
182 182
 	{
183
-		if( !isset( $list['catalog.lists.position'] ) ) {
183
+		if (!isset($list['catalog.lists.position'])) {
184 184
 			$list['catalog.lists.position'] = $pos;
185 185
 		}
186 186
 
187
-		if( !isset( $list['catalog.lists.status'] ) ) {
187
+		if (!isset($list['catalog.lists.status'])) {
188 188
 			$list['catalog.lists.status'] = 1;
189 189
 		}
190 190
 
@@ -198,10 +198,10 @@  discard block
 block discarded – undo
198 198
 	 * @param array $list Associative list of key/value pairs from the mapped data
199 199
 	 * @return boolean True if the entry is valid, false if not
200 200
 	 */
201
-	protected function checkEntry( array $list )
201
+	protected function checkEntry(array $list)
202 202
 	{
203
-		if( !isset( $list['catalog.code'] ) || $list['catalog.code'] === '' || isset( $list['catalog.lists.type'] )
204
-			&& $this->listTypes !== null && !in_array( $list['catalog.lists.type'], (array) $this->listTypes )
203
+		if (!isset($list['catalog.code']) || $list['catalog.code'] === '' || isset($list['catalog.lists.type'])
204
+			&& $this->listTypes !== null && !in_array($list['catalog.lists.type'], (array) $this->listTypes)
205 205
 		) {
206 206
 			return false;
207 207
 		}
@@ -217,24 +217,24 @@  discard block
 block discarded – undo
217 217
 	 * @param array|null $types List of catalog list types
218 218
 	 * @return array List of catalog list items
219 219
 	 */
220
-	protected function getListItems( $prodid, $types )
220
+	protected function getListItems($prodid, $types)
221 221
 	{
222
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' );
222
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists');
223 223
 		$search = $manager->createSearch();
224 224
 
225 225
 		$expr = array(
226
-			$search->compare( '==', 'catalog.lists.domain', 'product' ),
227
-			$search->compare( '==', 'catalog.lists.refid', $prodid ),
226
+			$search->compare('==', 'catalog.lists.domain', 'product'),
227
+			$search->compare('==', 'catalog.lists.refid', $prodid),
228 228
 		);
229 229
 
230
-		if( $types !== null ) {
231
-			$expr[] = $search->compare( '==', 'catalog.lists.type.code', $types );
230
+		if ($types !== null) {
231
+			$expr[] = $search->compare('==', 'catalog.lists.type.code', $types);
232 232
 		}
233 233
 
234
-		$search->setConditions( $search->combine( '&&', $expr ) );
235
-		$search->setSortations( array( $search->sort( '+', 'catalog.lists.position' ) ) );
236
-		$search->setSlice( 0, 0x7FFFFFFF );
234
+		$search->setConditions($search->combine('&&', $expr));
235
+		$search->setSortations(array($search->sort('+', 'catalog.lists.position')));
236
+		$search->setSlice(0, 0x7FFFFFFF);
237 237
 
238
-		return $manager->searchItems( $search );
238
+		return $manager->searchItems($search);
239 239
 	}
240 240
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -145,8 +145,7 @@  discard block
 block discarded – undo
145 145
 					{
146 146
 						$listItem = $listMap[$catid][$type];
147 147
 						unset( $listItems[ $listItem->getId() ] );
148
-					}
149
-					else
148
+					} else
150 149
 					{
151 150
 						$listItem = $listManager->createItem();
152 151
 					}
@@ -160,8 +159,7 @@  discard block
 block discarded – undo
160 159
 			$data = $this->getObject()->process( $product, $data );
161 160
 
162 161
 			$manager->commit();
163
-		}
164
-		catch( \Exception $e )
162
+		} catch( \Exception $e )
165 163
 		{
166 164
 			$manager->rollback();
167 165
 			throw $e;
Please login to merge, or discard this patch.
common/src/Controller/Common/Product/Import/Csv/Processor/Text/Standard.php 2 patches
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -42,10 +42,10 @@  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 50
 		/** controller/common/product/import/csv/processor/text/listtypes
51 51
 		 * Names of the product list types for texts that are updated or removed
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 		 * @see controller/common/product/import/csv/processor/price/listtypes
67 67
 		 * @see controller/common/product/import/csv/processor/product/listtypes
68 68
 		 */
69
-		$this->listTypes = $context->getConfig()->get( 'controller/common/product/import/csv/processor/text/listtypes' );
69
+		$this->listTypes = $context->getConfig()->get('controller/common/product/import/csv/processor/text/listtypes');
70 70
 	}
71 71
 
72 72
 
@@ -77,39 +77,39 @@  discard block
 block discarded – undo
77 77
 	 * @param array $data List of CSV fields with position as key and data as value
78 78
 	 * @return array List of data which hasn't been imported
79 79
 	 */
80
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
80
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
81 81
 	{
82
-		$listManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists' );
83
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'text' );
82
+		$listManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists');
83
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'text');
84 84
 		$manager->begin();
85 85
 
86 86
 		try
87 87
 		{
88 88
 			$delete = $listMap = array();
89
-			$map = $this->getMappedChunk( $data, $this->getMapping() );
90
-			$listItems = $product->getListItems( 'text', $this->listTypes );
89
+			$map = $this->getMappedChunk($data, $this->getMapping());
90
+			$listItems = $product->getListItems('text', $this->listTypes);
91 91
 
92
-			foreach( $listItems as $listItem )
92
+			foreach ($listItems as $listItem)
93 93
 			{
94
-				if( ( $refItem = $listItem->getRefItem() ) !== null ) {
95
-					$listMap[ $refItem->getContent() ][ $refItem->getType() ][ $listItem->getType() ] = $listItem;
94
+				if (($refItem = $listItem->getRefItem()) !== null) {
95
+					$listMap[$refItem->getContent()][$refItem->getType()][$listItem->getType()] = $listItem;
96 96
 				}
97 97
 			}
98 98
 
99
-			foreach( $map as $pos => $list )
99
+			foreach ($map as $pos => $list)
100 100
 			{
101
-				if( $this->checkEntry( $list ) === false ) {
101
+				if ($this->checkEntry($list) === false) {
102 102
 					continue;
103 103
 				}
104 104
 
105
-				$type = ( isset( $list['text.type'] ) ? $list['text.type'] : 'name' );
106
-				$typecode = ( isset( $list['product.lists.type'] ) ? $list['product.lists.type'] : 'default' );
105
+				$type = (isset($list['text.type']) ? $list['text.type'] : 'name');
106
+				$typecode = (isset($list['product.lists.type']) ? $list['product.lists.type'] : 'default');
107 107
 
108
-				if( isset( $listMap[ $list['text.content'] ][$type][$typecode] ) )
108
+				if (isset($listMap[$list['text.content']][$type][$typecode]))
109 109
 				{
110
-					$listItem = $listMap[ $list['text.content'] ][$type][$typecode];
110
+					$listItem = $listMap[$list['text.content']][$type][$typecode];
111 111
 					$refItem = $listItem->getRefItem();
112
-					unset( $listItems[ $listItem->getId() ] );
112
+					unset($listItems[$listItem->getId()]);
113 113
 				}
114 114
 				else
115 115
 				{
@@ -117,33 +117,33 @@  discard block
 block discarded – undo
117 117
 					$refItem = $manager->createItem();
118 118
 				}
119 119
 
120
-				$list['text.typeid'] = $this->getTypeId( 'text/type', 'product', $type );
120
+				$list['text.typeid'] = $this->getTypeId('text/type', 'product', $type);
121 121
 				$list['text.domain'] = 'product';
122 122
 
123
-				$refItem->fromArray( $this->addItemDefaults( $list ) );
124
-				$manager->saveItem( $refItem );
123
+				$refItem->fromArray($this->addItemDefaults($list));
124
+				$manager->saveItem($refItem);
125 125
 
126
-				$list['product.lists.typeid'] = $this->getTypeId( 'product/lists/type', 'text', $typecode );
126
+				$list['product.lists.typeid'] = $this->getTypeId('product/lists/type', 'text', $typecode);
127 127
 				$list['product.lists.parentid'] = $product->getId();
128 128
 				$list['product.lists.refid'] = $refItem->getId();
129 129
 				$list['product.lists.domain'] = 'text';
130 130
 
131
-				$listItem->fromArray( $this->addListItemDefaults( $list, $pos ) );
132
-				$listManager->saveItem( $listItem );
131
+				$listItem->fromArray($this->addListItemDefaults($list, $pos));
132
+				$listManager->saveItem($listItem);
133 133
 			}
134 134
 
135
-			foreach( $listItems as $listItem ) {
135
+			foreach ($listItems as $listItem) {
136 136
 				$delete[] = $listItem->getRefId();
137 137
 			}
138 138
 
139
-			$manager->deleteItems( $delete );
140
-			$listManager->deleteItems( array_keys( $listItems ) );
139
+			$manager->deleteItems($delete);
140
+			$listManager->deleteItems(array_keys($listItems));
141 141
 
142
-			$data = $this->getObject()->process( $product, $data );
142
+			$data = $this->getObject()->process($product, $data);
143 143
 
144 144
 			$manager->commit();
145 145
 		}
146
-		catch( \Exception $e )
146
+		catch (\Exception $e)
147 147
 		{
148 148
 			$manager->rollback();
149 149
 			throw $e;
@@ -159,17 +159,17 @@  discard block
 block discarded – undo
159 159
 	 * @param array $list Associative list of domain item keys and their values, e.g. "text.status" => 1
160 160
 	 * @return array Given associative list enriched by default values if they were not already set
161 161
 	 */
162
-	protected function addItemDefaults( array $list )
162
+	protected function addItemDefaults(array $list)
163 163
 	{
164
-		if( !isset( $list['text.label'] ) ) {
165
-			$list['text.label'] = mb_strcut( $list['text.content'], 0, 255 );
164
+		if (!isset($list['text.label'])) {
165
+			$list['text.label'] = mb_strcut($list['text.content'], 0, 255);
166 166
 		}
167 167
 
168
-		if( !isset( $list['text.languageid'] ) ) {
168
+		if (!isset($list['text.languageid'])) {
169 169
 			$list['text.languageid'] = $this->getContext()->getLocale()->getLanguageId();
170 170
 		}
171 171
 
172
-		if( !isset( $list['text.status'] ) ) {
172
+		if (!isset($list['text.status'])) {
173 173
 			$list['text.status'] = 1;
174 174
 		}
175 175
 
@@ -183,10 +183,10 @@  discard block
 block discarded – undo
183 183
 	 * @param array $list Associative list of key/value pairs from the mapping
184 184
 	 * @return boolean True if valid, false if not
185 185
 	 */
186
-	protected function checkEntry( array $list )
186
+	protected function checkEntry(array $list)
187 187
 	{
188
-		if( !isset( $list['text.content'] ) || $list['text.content'] === '' || isset( $list['product.lists.type'] )
189
-			&& $this->listTypes !== null && !in_array( $list['product.lists.type'], (array) $this->listTypes )
188
+		if (!isset($list['text.content']) || $list['text.content'] === '' || isset($list['product.lists.type'])
189
+			&& $this->listTypes !== null && !in_array($list['product.lists.type'], (array) $this->listTypes)
190 190
 		) {
191 191
 			return false;
192 192
 		}
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -110,8 +110,7 @@  discard block
 block discarded – undo
110 110
 					$listItem = $listMap[ $list['text.content'] ][$type][$typecode];
111 111
 					$refItem = $listItem->getRefItem();
112 112
 					unset( $listItems[ $listItem->getId() ] );
113
-				}
114
-				else
113
+				} else
115 114
 				{
116 115
 					$listItem = $listManager->createItem();
117 116
 					$refItem = $manager->createItem();
@@ -142,8 +141,7 @@  discard block
 block discarded – undo
142 141
 			$data = $this->getObject()->process( $product, $data );
143 142
 
144 143
 			$manager->commit();
145
-		}
146
-		catch( \Exception $e )
144
+		} catch( \Exception $e )
147 145
 		{
148 146
 			$manager->rollback();
149 147
 			throw $e;
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Processor/Price/Standard.php 2 patches
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -42,10 +42,10 @@  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 50
 		/** controller/common/product/import/csv/processor/price/listtypes
51 51
 		 * Names of the product list types for prices that are updated or removed
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 		 * @see controller/common/product/import/csv/processor/product/listtypes
67 67
 		 * @see controller/common/product/import/csv/processor/text/listtypes
68 68
 		 */
69
-		$this->listTypes = $context->getConfig()->get( 'controller/common/product/import/csv/processor/price/listtypes' );
69
+		$this->listTypes = $context->getConfig()->get('controller/common/product/import/csv/processor/price/listtypes');
70 70
 	}
71 71
 
72 72
 
@@ -77,40 +77,40 @@  discard block
 block discarded – undo
77 77
 	 * @param array $data List of CSV fields with position as key and data as value
78 78
 	 * @return array List of data which hasn't been imported
79 79
 	 */
80
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
80
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
81 81
 	{
82
-		$listManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists' );
83
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'price' );
82
+		$listManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists');
83
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'price');
84 84
 		$manager->begin();
85 85
 
86 86
 		try
87 87
 		{
88 88
 			$delete = $listMap = array();
89
-			$map = $this->getMappedChunk( $data, $this->getMapping() );
90
-			$listItems = $product->getListItems( 'price', $this->listTypes );
89
+			$map = $this->getMappedChunk($data, $this->getMapping());
90
+			$listItems = $product->getListItems('price', $this->listTypes);
91 91
 
92
-			foreach( $listItems as $listItem )
92
+			foreach ($listItems as $listItem)
93 93
 			{
94
-				if( ( $refItem = $listItem->getRefItem() ) !== null ) {
95
-					$listMap[ $refItem->getValue() ][ $refItem->getType() ][ $listItem->getType() ] = $listItem;
94
+				if (($refItem = $listItem->getRefItem()) !== null) {
95
+					$listMap[$refItem->getValue()][$refItem->getType()][$listItem->getType()] = $listItem;
96 96
 				}
97 97
 			}
98 98
 
99
-			foreach( $map as $pos => $list )
99
+			foreach ($map as $pos => $list)
100 100
 			{
101
-				if( $this->checkEntry( $list ) === false ) {
101
+				if ($this->checkEntry($list) === false) {
102 102
 					continue;
103 103
 				}
104 104
 
105
-				$value = ( isset( $list['price.value'] ) ? $list['price.value'] : '0.00' );
106
-				$type = ( isset( $list['price.type'] ) ? $list['price.type'] : 'default' );
107
-				$typecode = ( isset( $list['product.lists.type'] ) ? $list['product.lists.type'] : 'default' );
105
+				$value = (isset($list['price.value']) ? $list['price.value'] : '0.00');
106
+				$type = (isset($list['price.type']) ? $list['price.type'] : 'default');
107
+				$typecode = (isset($list['product.lists.type']) ? $list['product.lists.type'] : 'default');
108 108
 
109
-				if( isset( $listMap[$value][$type][$typecode] ) )
109
+				if (isset($listMap[$value][$type][$typecode]))
110 110
 				{
111 111
 					$listItem = $listMap[$value][$type][$typecode];
112 112
 					$refItem = $listItem->getRefItem();
113
-					unset( $listItems[ $listItem->getId() ] );
113
+					unset($listItems[$listItem->getId()]);
114 114
 				}
115 115
 				else
116 116
 				{
@@ -118,33 +118,33 @@  discard block
 block discarded – undo
118 118
 					$refItem = $manager->createItem();
119 119
 				}
120 120
 
121
-				$list['price.typeid'] = $this->getTypeId( 'price/type', 'product', $type );
121
+				$list['price.typeid'] = $this->getTypeId('price/type', 'product', $type);
122 122
 				$list['price.domain'] = 'product';
123 123
 
124
-				$refItem->fromArray( $this->addItemDefaults( $list ) );
125
-				$manager->saveItem( $refItem );
124
+				$refItem->fromArray($this->addItemDefaults($list));
125
+				$manager->saveItem($refItem);
126 126
 
127
-				$list['product.lists.typeid'] = $this->getTypeId( 'product/lists/type', 'price', $typecode );
127
+				$list['product.lists.typeid'] = $this->getTypeId('product/lists/type', 'price', $typecode);
128 128
 				$list['product.lists.parentid'] = $product->getId();
129 129
 				$list['product.lists.refid'] = $refItem->getId();
130 130
 				$list['product.lists.domain'] = 'price';
131 131
 
132
-				$listItem->fromArray( $this->addListItemDefaults( $list, $pos ) );
133
-				$listManager->saveItem( $listItem );
132
+				$listItem->fromArray($this->addListItemDefaults($list, $pos));
133
+				$listManager->saveItem($listItem);
134 134
 			}
135 135
 
136
-			foreach( $listItems as $listItem ) {
136
+			foreach ($listItems as $listItem) {
137 137
 				$delete[] = $listItem->getRefId();
138 138
 			}
139 139
 
140
-			$manager->deleteItems( $delete );
141
-			$listManager->deleteItems( array_keys( $listItems ) );
140
+			$manager->deleteItems($delete);
141
+			$listManager->deleteItems(array_keys($listItems));
142 142
 
143
-			$data = $this->getObject()->process( $product, $data );
143
+			$data = $this->getObject()->process($product, $data);
144 144
 
145 145
 			$manager->commit();
146 146
 		}
147
-		catch( \Exception $e )
147
+		catch (\Exception $e)
148 148
 		{
149 149
 			$manager->rollback();
150 150
 			throw $e;
@@ -160,17 +160,17 @@  discard block
 block discarded – undo
160 160
 	 * @param array $list Associative list of domain item keys and their values, e.g. "price.status" => 1
161 161
 	 * @return array Given associative list enriched by default values if they were not already set
162 162
 	 */
163
-	protected function addItemDefaults( array $list )
163
+	protected function addItemDefaults(array $list)
164 164
 	{
165
-		if( !isset( $list['price.currencyid'] ) ) {
165
+		if (!isset($list['price.currencyid'])) {
166 166
 			$list['price.currencyid'] = $this->getContext()->getLocale()->getCurrencyId();
167 167
 		}
168 168
 
169
-		if( !isset( $list['price.label'] ) ) {
169
+		if (!isset($list['price.label'])) {
170 170
 			$list['price.label'] = $list['price.currencyid'] . ' ' . $list['price.value'];
171 171
 		}
172 172
 
173
-		if( !isset( $list['price.status'] ) ) {
173
+		if (!isset($list['price.status'])) {
174 174
 			$list['price.status'] = 1;
175 175
 		}
176 176
 
@@ -184,10 +184,10 @@  discard block
 block discarded – undo
184 184
 	 * @param array $list Associative list of key/value pairs from the mapping
185 185
 	 * @return boolean True if valid, false if not
186 186
 	 */
187
-	protected function checkEntry( array $list )
187
+	protected function checkEntry(array $list)
188 188
 	{
189
-		if( !isset( $list['price.value'] ) || $list['price.value'] === '' || isset( $list['product.lists.type'] )
190
-			&& $this->listTypes !== null && !in_array( $list['product.lists.type'], (array) $this->listTypes )
189
+		if (!isset($list['price.value']) || $list['price.value'] === '' || isset($list['product.lists.type'])
190
+			&& $this->listTypes !== null && !in_array($list['product.lists.type'], (array) $this->listTypes)
191 191
 		) {
192 192
 			return false;
193 193
 		}
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -111,8 +111,7 @@  discard block
 block discarded – undo
111 111
 					$listItem = $listMap[$value][$type][$typecode];
112 112
 					$refItem = $listItem->getRefItem();
113 113
 					unset( $listItems[ $listItem->getId() ] );
114
-				}
115
-				else
114
+				} else
116 115
 				{
117 116
 					$listItem = $listManager->createItem();
118 117
 					$refItem = $manager->createItem();
@@ -143,8 +142,7 @@  discard block
 block discarded – undo
143 142
 			$data = $this->getObject()->process( $product, $data );
144 143
 
145 144
 			$manager->commit();
146
-		}
147
-		catch( \Exception $e )
145
+		} catch( \Exception $e )
148 146
 		{
149 147
 			$manager->rollback();
150 148
 			throw $e;
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,71 +80,71 @@  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
 
92 92
 		try
93 93
 		{
94 94
 			$listMap = array();
95
-			$map = $this->getMappedChunk( $data, $this->getMapping() );
96
-			$listItems = $product->getListItems( 'attribute', $this->listTypes );
95
+			$map = $this->getMappedChunk($data, $this->getMapping());
96
+			$listItems = $product->getListItems('attribute', $this->listTypes);
97 97
 
98
-			foreach( $listItems as $listItem )
98
+			foreach ($listItems as $listItem)
99 99
 			{
100
-				if( ( $refItem = $listItem->getRefItem() ) !== null ) {
101
-					$listMap[ $refItem->getCode() ][ $listItem->getType() ] = $listItem;
100
+				if (($refItem = $listItem->getRefItem()) !== null) {
101
+					$listMap[$refItem->getCode()][$listItem->getType()] = $listItem;
102 102
 				}
103 103
 			}
104 104
 
105
-			foreach( $map as $pos => $list )
105
+			foreach ($map as $pos => $list)
106 106
 			{
107
-				if( $this->checkEntry( $list ) === false ) {
107
+				if ($this->checkEntry($list) === false) {
108 108
 					continue;
109 109
 				}
110 110
 
111
-				$codes = explode( $separator, $list['attribute.code'] );
111
+				$codes = explode($separator, $list['attribute.code']);
112 112
 
113
-				foreach( $codes as $code )
113
+				foreach ($codes as $code)
114 114
 				{
115
-					$attrItem = $this->getAttributeItem( $code, $list['attribute.type'] );
116
-					$attrItem->fromArray( $list );
117
-					$attrItem->setCode( $code );
118
-					$manager->saveItem( $attrItem );
115
+					$attrItem = $this->getAttributeItem($code, $list['attribute.type']);
116
+					$attrItem->fromArray($list);
117
+					$attrItem->setCode($code);
118
+					$manager->saveItem($attrItem);
119 119
 
120
-					$typecode = $this->getValue( $list, 'product.lists.type', 'default' );
121
-					$list['product.lists.typeid'] = $this->getTypeId( 'product/lists/type', 'attribute', $typecode );
120
+					$typecode = $this->getValue($list, 'product.lists.type', 'default');
121
+					$list['product.lists.typeid'] = $this->getTypeId('product/lists/type', 'attribute', $typecode);
122 122
 					$list['product.lists.refid'] = $attrItem->getId();
123 123
 					$list['product.lists.parentid'] = $product->getId();
124 124
 					$list['product.lists.domain'] = 'attribute';
125 125
 
126
-					if( isset( $listMap[$code][$typecode] ) )
126
+					if (isset($listMap[$code][$typecode]))
127 127
 					{
128 128
 						$listItem = $listMap[$code][$typecode];
129
-						unset( $listItems[ $listItem->getId() ] );
129
+						unset($listItems[$listItem->getId()]);
130 130
 					}
131 131
 					else
132 132
 					{
133 133
 						$listItem = $listManager->createItem();
134 134
 					}
135 135
 
136
-					$listItem->fromArray( $this->addListItemDefaults( $list, $pos ) );
137
-					$listManager->saveItem( $listItem );
136
+					$listItem->fromArray($this->addListItemDefaults($list, $pos));
137
+					$listManager->saveItem($listItem);
138 138
 				}
139 139
 			}
140 140
 
141
-			$listManager->deleteItems( array_keys( $listItems ) );
141
+			$listManager->deleteItems(array_keys($listItems));
142 142
 
143
-			$data = $this->getObject()->process( $product, $data );
143
+			$data = $this->getObject()->process($product, $data);
144 144
 
145 145
 			$manager->commit();
146 146
 		}
147
-		catch( \Exception $e )
147
+		catch (\Exception $e)
148 148
 		{
149 149
 			$manager->rollback();
150 150
 			throw $e;
@@ -160,11 +160,11 @@  discard block
 block discarded – undo
160 160
 	 * @param array $list Associative list of key/value pairs from the mapped data
161 161
 	 * @return boolean True if the entry is valid, false if not
162 162
 	 */
163
-	protected function checkEntry( array $list )
163
+	protected function checkEntry(array $list)
164 164
 	{
165
-		if( !isset( $list['attribute.code'] ) || $list['attribute.code'] === '' || $list['attribute.type'] === ''
166
-			|| isset( $list['product.lists.type'] ) && $this->listTypes !== null
167
-			&& !in_array( $list['product.lists.type'], (array) $this->listTypes )
165
+		if (!isset($list['attribute.code']) || $list['attribute.code'] === '' || $list['attribute.type'] === ''
166
+			|| isset($list['product.lists.type']) && $this->listTypes !== null
167
+			&& !in_array($list['product.lists.type'], (array) $this->listTypes)
168 168
 		) {
169 169
 			return false;
170 170
 		}
@@ -180,22 +180,22 @@  discard block
 block discarded – undo
180 180
 	 * @param string $type Attribute type
181 181
 	 * @return \Aimeos\MShop\Attribute\Item\Iface Attribute item object
182 182
 	 */
183
-	protected function getAttributeItem( $code, $type )
183
+	protected function getAttributeItem($code, $type)
184 184
 	{
185
-		if( ( $item = $this->cache->get( $code, $type ) ) === null )
185
+		if (($item = $this->cache->get($code, $type)) === null)
186 186
 		{
187
-			$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' );
187
+			$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute');
188 188
 
189 189
 			$item = $manager->createItem();
190
-			$item->setTypeId( $this->getTypeId( 'attribute/type', 'product', $type ) );
191
-			$item->setDomain( 'product' );
192
-			$item->setLabel( $type . ' ' . $code );
193
-			$item->setCode( $code );
194
-			$item->setStatus( 1 );
190
+			$item->setTypeId($this->getTypeId('attribute/type', 'product', $type));
191
+			$item->setDomain('product');
192
+			$item->setLabel($type . ' ' . $code);
193
+			$item->setCode($code);
194
+			$item->setStatus(1);
195 195
 
196
-			$manager->saveItem( $item );
196
+			$manager->saveItem($item);
197 197
 
198
-			$this->cache->set( $item );
198
+			$this->cache->set($item);
199 199
 		}
200 200
 
201 201
 		return $item;
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -127,8 +127,7 @@  discard block
 block discarded – undo
127 127
 					{
128 128
 						$listItem = $listMap[$code][$typecode];
129 129
 						unset( $listItems[ $listItem->getId() ] );
130
-					}
131
-					else
130
+					} else
132 131
 					{
133 132
 						$listItem = $listManager->createItem();
134 133
 					}
@@ -143,8 +142,7 @@  discard block
 block discarded – undo
143 142
 			$data = $this->getObject()->process( $product, $data );
144 143
 
145 144
 			$manager->commit();
146
-		}
147
-		catch( \Exception $e )
145
+		} catch( \Exception $e )
148 146
 		{
149 147
 			$manager->rollback();
150 148
 			throw $e;
Please login to merge, or discard this patch.