Completed
Push — master ( cbc921...0b1729 )
by Aimeos
02:05
created
src/Controller/Common/Product/Import/Csv/Processor/Price/Standard.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
44 44
 	 * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor
45 45
 	 */
46
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping,
47
-			\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null )
46
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
47
+			\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null)
48 48
 	{
49
-		parent::__construct( $context, $mapping, $object );
49
+		parent::__construct($context, $mapping, $object);
50 50
 
51 51
 		/** controller/common/product/import/csv/processor/price/listtypes
52 52
 		 * Names of the product list types for prices that are updated or removed
@@ -68,32 +68,32 @@  discard block
 block discarded – undo
68 68
 		 * @see controller/common/product/import/csv/processor/text/listtypes
69 69
 		 */
70 70
 		$key = 'controller/common/product/import/csv/processor/price/listtypes';
71
-		$this->listTypes = $context->getConfig()->get( $key );
71
+		$this->listTypes = $context->getConfig()->get($key);
72 72
 
73
-		if( $this->listTypes === null )
73
+		if ($this->listTypes === null)
74 74
 		{
75 75
 			$this->listTypes = [];
76
-			$manager = \Aimeos\MShop::create( $context, 'product/lists/type' );
76
+			$manager = \Aimeos\MShop::create($context, 'product/lists/type');
77 77
 
78
-			$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
79
-			$search->setConditions( $search->compare( '==', 'product.lists.type.domain', 'price' ) );
78
+			$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
79
+			$search->setConditions($search->compare('==', 'product.lists.type.domain', 'price'));
80 80
 
81
-			foreach( $manager->searchItems( $search ) as $item ) {
81
+			foreach ($manager->searchItems($search) as $item) {
82 82
 				$this->listTypes[$item->getCode()] = $item->getCode();
83 83
 			}
84 84
 		}
85 85
 		else
86 86
 		{
87
-			$this->listTypes = array_flip( $this->listTypes );
87
+			$this->listTypes = array_flip($this->listTypes);
88 88
 		}
89 89
 
90 90
 
91
-		$manager = \Aimeos\MShop::create( $context, 'price/type' );
91
+		$manager = \Aimeos\MShop::create($context, 'price/type');
92 92
 
93
-		$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
94
-		$search->setConditions( $search->compare( '==', 'price.type.domain', 'product' ) );
93
+		$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
94
+		$search->setConditions($search->compare('==', 'price.type.domain', 'product'));
95 95
 
96
-		foreach( $manager->searchItems( $search ) as $item ) {
96
+		foreach ($manager->searchItems($search) as $item) {
97 97
 			$this->types[$item->getCode()] = $item->getCode();
98 98
 		}
99 99
 	}
@@ -106,55 +106,55 @@  discard block
 block discarded – undo
106 106
 	 * @param array $data List of CSV fields with position as key and data as value
107 107
 	 * @return array List of data which hasn't been imported
108 108
 	 */
109
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
109
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
110 110
 	{
111
-		$listManager = \Aimeos\MShop::create( $this->getContext(), 'product/lists' );
112
-		$manager = \Aimeos\MShop::create( $this->getContext(), 'price' );
111
+		$listManager = \Aimeos\MShop::create($this->getContext(), 'product/lists');
112
+		$manager = \Aimeos\MShop::create($this->getContext(), 'price');
113 113
 
114 114
 		$listMap = [];
115
-		$map = $this->getMappedChunk( $data, $this->getMapping() );
116
-		$listItems = $product->getListItems( 'price', $this->listTypes );
115
+		$map = $this->getMappedChunk($data, $this->getMapping());
116
+		$listItems = $product->getListItems('price', $this->listTypes);
117 117
 
118
-		foreach( $listItems as $listItem )
118
+		foreach ($listItems as $listItem)
119 119
 		{
120
-			if( ( $refItem = $listItem->getRefItem() ) !== null ) {
121
-				$listMap[ $refItem->getValue() ][ $refItem->getType() ][ $listItem->getType() ] = $listItem;
120
+			if (($refItem = $listItem->getRefItem()) !== null) {
121
+				$listMap[$refItem->getValue()][$refItem->getType()][$listItem->getType()] = $listItem;
122 122
 			}
123 123
 		}
124 124
 
125
-		foreach( $map as $pos => $list )
125
+		foreach ($map as $pos => $list)
126 126
 		{
127
-			if( $this->checkEntry( $list ) === false ) {
127
+			if ($this->checkEntry($list) === false) {
128 128
 				continue;
129 129
 			}
130 130
 
131
-			$value = $this->getValue( $list, 'price.value', '0.00' );
132
-			$type = $this->getValue( $list, 'price.type', 'default' );
133
-			$listtype = $this->getValue( $list, 'product.lists.type', 'default' );
131
+			$value = $this->getValue($list, 'price.value', '0.00');
132
+			$type = $this->getValue($list, 'price.type', 'default');
133
+			$listtype = $this->getValue($list, 'product.lists.type', 'default');
134 134
 
135
-			if( isset( $listMap[$value][$type][$listtype] ) )
135
+			if (isset($listMap[$value][$type][$listtype]))
136 136
 			{
137 137
 				$listItem = $listMap[$value][$type][$listtype];
138 138
 				$refItem = $listItem->getRefItem();
139
-				unset( $listItems[ $listItem->getId() ] );
139
+				unset($listItems[$listItem->getId()]);
140 140
 			}
141 141
 			else
142 142
 			{
143
-				$listItem = $listManager->createItem()->setType( $listtype );
144
-				$refItem = $manager->createItem()->setType( $type );
143
+				$listItem = $listManager->createItem()->setType($listtype);
144
+				$refItem = $manager->createItem()->setType($type);
145 145
 			}
146 146
 
147
-			$listItem = $listItem->setPosition( $pos )->fromArray( $list );
147
+			$listItem = $listItem->setPosition($pos)->fromArray($list);
148 148
 
149
-			$label = $this->getValue( $list, 'price.currencyid', '' ) . ' ' . $this->getValue( $list, 'price.value', '' );
150
-			$refItem = $refItem->setLabel( $label )->fromArray( $list );
149
+			$label = $this->getValue($list, 'price.currencyid', '') . ' ' . $this->getValue($list, 'price.value', '');
150
+			$refItem = $refItem->setLabel($label)->fromArray($list);
151 151
 
152
-			$product->addListItem( 'price', $listItem, $refItem );
152
+			$product->addListItem('price', $listItem, $refItem);
153 153
 		}
154 154
 
155
-		$product->deleteListItems( $listItems, true );
155
+		$product->deleteListItems($listItems, true);
156 156
 
157
-		return $this->getObject()->process( $product, $data );
157
+		return $this->getObject()->process($product, $data);
158 158
 	}
159 159
 
160 160
 
@@ -164,22 +164,22 @@  discard block
 block discarded – undo
164 164
 	 * @param array $list Associative list of key/value pairs from the mapping
165 165
 	 * @return boolean True if valid, false if not
166 166
 	 */
167
-	protected function checkEntry( array $list )
167
+	protected function checkEntry(array $list)
168 168
 	{
169
-		if( $this->getValue( $list, 'price.value' ) === null ) {
169
+		if ($this->getValue($list, 'price.value') === null) {
170 170
 			return false;
171 171
 		}
172 172
 
173
-		if( ( $type = $this->getValue( $list, 'product.lists.type' ) ) && !isset( $this->listTypes[$type] ) )
173
+		if (($type = $this->getValue($list, 'product.lists.type')) && !isset($this->listTypes[$type]))
174 174
 		{
175
-			$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'product list' );
176
-			throw new \Aimeos\Controller\Common\Exception( $msg );
175
+			$msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'product list');
176
+			throw new \Aimeos\Controller\Common\Exception($msg);
177 177
 		}
178 178
 
179
-		if( ( $type = $this->getValue( $list, 'price.type' ) ) && !isset( $this->types[$type] ) )
179
+		if (($type = $this->getValue($list, 'price.type')) && !isset($this->types[$type]))
180 180
 		{
181
-			$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'price' );
182
-			throw new \Aimeos\Controller\Common\Exception( $msg );
181
+			$msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'price');
182
+			throw new \Aimeos\Controller\Common\Exception($msg);
183 183
 		}
184 184
 
185 185
 		return true;
Please login to merge, or discard this patch.
common/src/Controller/Common/Product/Import/Csv/Processor/Text/Standard.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
44 44
 	 * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor
45 45
 	 */
46
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping,
47
-			\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null )
46
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
47
+			\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null)
48 48
 	{
49
-		parent::__construct( $context, $mapping, $object );
49
+		parent::__construct($context, $mapping, $object);
50 50
 
51 51
 		/** controller/common/product/import/csv/processor/text/listtypes
52 52
 		 * Names of the product list types for texts that are updated or removed
@@ -68,32 +68,32 @@  discard block
 block discarded – undo
68 68
 		 * @see controller/common/product/import/csv/processor/product/listtypes
69 69
 		 */
70 70
 		$key = 'controller/common/product/import/csv/processor/text/listtypes';
71
-		$this->listTypes = $context->getConfig()->get( $key );
71
+		$this->listTypes = $context->getConfig()->get($key);
72 72
 
73
-		if( $this->listTypes === null )
73
+		if ($this->listTypes === null)
74 74
 		{
75 75
 			$this->listTypes = [];
76
-			$manager = \Aimeos\MShop::create( $context, 'product/lists/type' );
76
+			$manager = \Aimeos\MShop::create($context, 'product/lists/type');
77 77
 
78
-			$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
79
-			$search->setConditions( $search->compare( '==', 'product.lists.type.domain', 'text' ) );
78
+			$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
79
+			$search->setConditions($search->compare('==', 'product.lists.type.domain', 'text'));
80 80
 
81
-			foreach( $manager->searchItems( $search ) as $item ) {
81
+			foreach ($manager->searchItems($search) as $item) {
82 82
 				$this->listTypes[$item->getCode()] = $item->getCode();
83 83
 			}
84 84
 		}
85 85
 		else
86 86
 		{
87
-			$this->listTypes = array_flip( $this->listTypes );
87
+			$this->listTypes = array_flip($this->listTypes);
88 88
 		}
89 89
 
90 90
 
91
-		$manager = \Aimeos\MShop::create( $context, 'text/type' );
91
+		$manager = \Aimeos\MShop::create($context, 'text/type');
92 92
 
93
-		$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
94
-		$search->setConditions( $search->compare( '==', 'text.type.domain', 'product' ) );
93
+		$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
94
+		$search->setConditions($search->compare('==', 'text.type.domain', 'product'));
95 95
 
96
-		foreach( $manager->searchItems( $search ) as $item ) {
96
+		foreach ($manager->searchItems($search) as $item) {
97 97
 			$this->types[$item->getCode()] = $item->getCode();
98 98
 		}
99 99
 	}
@@ -106,55 +106,55 @@  discard block
 block discarded – undo
106 106
 	 * @param array $data List of CSV fields with position as key and data as value
107 107
 	 * @return array List of data which hasn't been imported
108 108
 	 */
109
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
109
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
110 110
 	{
111
-		$listManager = \Aimeos\MShop::create( $this->getContext(), 'product/lists' );
112
-		$manager = \Aimeos\MShop::create( $this->getContext(), 'text' );
111
+		$listManager = \Aimeos\MShop::create($this->getContext(), 'product/lists');
112
+		$manager = \Aimeos\MShop::create($this->getContext(), 'text');
113 113
 
114 114
 		$listMap = [];
115
-		$map = $this->getMappedChunk( $data, $this->getMapping() );
116
-		$listItems = $product->getListItems( 'text', $this->listTypes );
115
+		$map = $this->getMappedChunk($data, $this->getMapping());
116
+		$listItems = $product->getListItems('text', $this->listTypes);
117 117
 
118
-		foreach( $listItems as $listItem )
118
+		foreach ($listItems as $listItem)
119 119
 		{
120
-			if( ( $refItem = $listItem->getRefItem() ) !== null ) {
121
-				$listMap[ $refItem->getContent() ][ $refItem->getType() ][ $listItem->getType() ] = $listItem;
120
+			if (($refItem = $listItem->getRefItem()) !== null) {
121
+				$listMap[$refItem->getContent()][$refItem->getType()][$listItem->getType()] = $listItem;
122 122
 			}
123 123
 		}
124 124
 
125
-		foreach( $map as $pos => $list )
125
+		foreach ($map as $pos => $list)
126 126
 		{
127
-			if( $this->checkEntry( $list ) === false ) {
127
+			if ($this->checkEntry($list) === false) {
128 128
 				continue;
129 129
 			}
130 130
 
131
-			$type = $this->getValue( $list, 'text.type', 'name' );
132
-			$listtype = $this->getValue( $list, 'product.lists.type', 'default' );
133
-			$content = $this->getValue( $list, 'text.content', '' );
131
+			$type = $this->getValue($list, 'text.type', 'name');
132
+			$listtype = $this->getValue($list, 'product.lists.type', 'default');
133
+			$content = $this->getValue($list, 'text.content', '');
134 134
 
135
-			if( isset( $listMap[$content][$type][$listtype] ) )
135
+			if (isset($listMap[$content][$type][$listtype]))
136 136
 			{
137 137
 				$listItem = $listMap[$content][$type][$listtype];
138 138
 				$refItem = $listItem->getRefItem();
139
-				unset( $listItems[ $listItem->getId() ] );
139
+				unset($listItems[$listItem->getId()]);
140 140
 			}
141 141
 			else
142 142
 			{
143
-				$listItem = $listManager->createItem()->setType( $listtype );
144
-				$refItem = $manager->createItem()->setType( $type );
143
+				$listItem = $listManager->createItem()->setType($listtype);
144
+				$refItem = $manager->createItem()->setType($type);
145 145
 			}
146 146
 
147
-			$listItem = $listItem->setPosition( $pos )->fromArray( $list );
147
+			$listItem = $listItem->setPosition($pos)->fromArray($list);
148 148
 
149
-			$label = mb_strcut( $this->getValue( $list, 'text.content', '' ), 0, 255 );
150
-			$refItem = $refItem->setLabel( $label )->fromArray( $list );
149
+			$label = mb_strcut($this->getValue($list, 'text.content', ''), 0, 255);
150
+			$refItem = $refItem->setLabel($label)->fromArray($list);
151 151
 
152
-			$product->addListItem( 'text', $listItem, $refItem );
152
+			$product->addListItem('text', $listItem, $refItem);
153 153
 		}
154 154
 
155
-		$product->deleteListItems( $listItems, true );
155
+		$product->deleteListItems($listItems, true);
156 156
 
157
-		return $this->getObject()->process( $product, $data );
157
+		return $this->getObject()->process($product, $data);
158 158
 	}
159 159
 
160 160
 
@@ -164,22 +164,22 @@  discard block
 block discarded – undo
164 164
 	 * @param array $list Associative list of key/value pairs from the mapping
165 165
 	 * @return boolean True if valid, false if not
166 166
 	 */
167
-	protected function checkEntry( array $list )
167
+	protected function checkEntry(array $list)
168 168
 	{
169
-		if( $this->getValue( $list, 'text.content' ) === null ) {
169
+		if ($this->getValue($list, 'text.content') === null) {
170 170
 			return false;
171 171
 		}
172 172
 
173
-		if( ( $type = $this->getValue( $list, 'product.lists.type' ) ) && !isset( $this->listTypes[$type] ) )
173
+		if (($type = $this->getValue($list, 'product.lists.type')) && !isset($this->listTypes[$type]))
174 174
 		{
175
-			$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'product list' );
176
-			throw new \Aimeos\Controller\Common\Exception( $msg );
175
+			$msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'product list');
176
+			throw new \Aimeos\Controller\Common\Exception($msg);
177 177
 		}
178 178
 
179
-		if( ( $type = $this->getValue( $list, 'text.type' ) ) && !isset( $this->types[$type] ) )
179
+		if (($type = $this->getValue($list, 'text.type')) && !isset($this->types[$type]))
180 180
 		{
181
-			$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'text' );
182
-			throw new \Aimeos\Controller\Common\Exception( $msg );
181
+			$msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'text');
182
+			throw new \Aimeos\Controller\Common\Exception($msg);
183 183
 		}
184 184
 
185 185
 		return true;
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Processor/Stock/Standard.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -42,15 +42,15 @@  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
-		$manager = \Aimeos\MShop::create( $context, 'stock/type' );
51
-		$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
50
+		$manager = \Aimeos\MShop::create($context, 'stock/type');
51
+		$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
52 52
 
53
-		foreach( $manager->searchItems( $search ) as $item ) {
53
+		foreach ($manager->searchItems($search) as $item) {
54 54
 			$this->types[$item->getCode()] = $item->getCode();
55 55
 		}
56 56
 	}
@@ -63,47 +63,47 @@  discard block
 block discarded – undo
63 63
 	 * @param array $data List of CSV fields with position as key and data as value
64 64
 	 * @return array List of data which hasn't been imported
65 65
 	 */
66
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
66
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
67 67
 	{
68
-		$manager = \Aimeos\MShop::create( $this->getContext(), 'stock' );
68
+		$manager = \Aimeos\MShop::create($this->getContext(), 'stock');
69 69
 		$manager->begin();
70 70
 
71 71
 		try
72 72
 		{
73
-			$map = $this->getMappedChunk( $data, $this->getMapping() );
74
-			$items = $this->getStockItems( $product->getCode() );
73
+			$map = $this->getMappedChunk($data, $this->getMapping());
74
+			$items = $this->getStockItems($product->getCode());
75 75
 
76
-			foreach( $map as $pos => $list )
76
+			foreach ($map as $pos => $list)
77 77
 			{
78
-				if( !array_key_exists( 'stock.stocklevel', $list ) ) {
78
+				if (!array_key_exists('stock.stocklevel', $list)) {
79 79
 					continue;
80 80
 				}
81 81
 
82 82
 				$list['stock.productcode'] = $product->getCode();
83
-				$list['stock.dateback'] = $this->getValue( $list, 'stock.dateback' );
84
-				$list['stock.stocklevel'] = $this->getValue( $list, 'stock.stocklevel' );
85
-				$list['stock.type'] = $this->getValue( $list, 'stock.type', 'default' );
83
+				$list['stock.dateback'] = $this->getValue($list, 'stock.dateback');
84
+				$list['stock.stocklevel'] = $this->getValue($list, 'stock.stocklevel');
85
+				$list['stock.type'] = $this->getValue($list, 'stock.type', 'default');
86 86
 
87
-				if( !in_array( $list['stock.type'], $this->types ) )
87
+				if (!in_array($list['stock.type'], $this->types))
88 88
 				{
89
-					$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $list['stock.type'], 'stock' );
90
-					throw new \Aimeos\Controller\Common\Exception( $msg );
89
+					$msg = sprintf('Invalid type "%1$s" (%2$s)', $list['stock.type'], 'stock');
90
+					throw new \Aimeos\Controller\Common\Exception($msg);
91 91
 				}
92 92
 
93
-				if( ( $item = array_pop( $items ) ) === null ) {
93
+				if (($item = array_pop($items)) === null) {
94 94
 					$item = $manager->createItem();
95 95
 				}
96 96
 
97
-				$manager->saveItem( $item->fromArray( $list ), false );
97
+				$manager->saveItem($item->fromArray($list), false);
98 98
 			}
99 99
 
100
-			$manager->deleteItems( array_keys( $items ) );
100
+			$manager->deleteItems(array_keys($items));
101 101
 
102
-			$data = $this->getObject()->process( $product, $data );
102
+			$data = $this->getObject()->process($product, $data);
103 103
 
104 104
 			$manager->commit();
105 105
 		}
106
-		catch( \Exception $e )
106
+		catch (\Exception $e)
107 107
 		{
108 108
 			$manager->rollback();
109 109
 			throw $e;
@@ -119,13 +119,13 @@  discard block
 block discarded – undo
119 119
 	 * @param string $code Unique product code
120 120
 	 * @return \Aimeos\MShop\Stock\Item\Iface[] Associative list of stock items
121 121
 	 */
122
-	protected function getStockItems( $code )
122
+	protected function getStockItems($code)
123 123
 	{
124
-		$manager = \Aimeos\MShop::create( $this->getContext(), 'stock' );
124
+		$manager = \Aimeos\MShop::create($this->getContext(), 'stock');
125 125
 
126 126
 		$search = $manager->createSearch();
127
-		$search->setConditions( $search->compare( '==', 'stock.productcode', $code ) );
127
+		$search->setConditions($search->compare('==', 'stock.productcode', $code));
128 128
 
129
-		return $manager->searchItems( $search );
129
+		return $manager->searchItems($search);
130 130
 	}
131 131
 }
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Processor/Attribute/Standard.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -44,10 +44,10 @@  discard block
 block discarded – undo
44 44
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
45 45
 	 * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor
46 46
 	 */
47
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping,
48
-		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null )
47
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
48
+		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null)
49 49
 	{
50
-		parent::__construct( $context, $mapping, $object );
50
+		parent::__construct($context, $mapping, $object);
51 51
 
52 52
 		/** controller/common/product/import/csv/processor/attribute/listtypes
53 53
 		 * Names of the product list types for attributes that are updated or removed
@@ -69,37 +69,37 @@  discard block
 block discarded – undo
69 69
 		 * @see controller/common/product/import/csv/processor/text/listtypes
70 70
 		 */
71 71
 		$key = 'controller/common/product/import/csv/processor/attribute/listtypes';
72
-		$this->listTypes = $context->getConfig()->get( $key );
72
+		$this->listTypes = $context->getConfig()->get($key);
73 73
 
74
-		if( $this->listTypes === null )
74
+		if ($this->listTypes === null)
75 75
 		{
76 76
 			$this->listTypes = [];
77
-			$manager = \Aimeos\MShop::create( $context, 'product/lists/type' );
77
+			$manager = \Aimeos\MShop::create($context, 'product/lists/type');
78 78
 
79
-			$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
80
-			$search->setConditions( $search->compare( '==', 'product.lists.type.domain', 'attribute' ) );
79
+			$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
80
+			$search->setConditions($search->compare('==', 'product.lists.type.domain', 'attribute'));
81 81
 
82
-			foreach( $manager->searchItems( $search ) as $item ) {
82
+			foreach ($manager->searchItems($search) as $item) {
83 83
 				$this->listTypes[$item->getCode()] = $item->getCode();
84 84
 			}
85 85
 		}
86 86
 		else
87 87
 		{
88
-			$this->listTypes = array_flip( $this->listTypes );
88
+			$this->listTypes = array_flip($this->listTypes);
89 89
 		}
90 90
 
91 91
 
92
-		$manager = \Aimeos\MShop::create( $context, 'attribute/type' );
92
+		$manager = \Aimeos\MShop::create($context, 'attribute/type');
93 93
 
94
-		$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
95
-		$search->setConditions( $search->compare( '==', 'attribute.type.domain', 'product' ) );
94
+		$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
95
+		$search->setConditions($search->compare('==', 'attribute.type.domain', 'product'));
96 96
 
97
-		foreach( $manager->searchItems( $search ) as $item ) {
97
+		foreach ($manager->searchItems($search) as $item) {
98 98
 			$this->types[$item->getCode()] = $item->getCode();
99 99
 		}
100 100
 
101 101
 
102
-		$this->cache = $this->getCache( 'attribute' );
102
+		$this->cache = $this->getCache('attribute');
103 103
 	}
104 104
 
105 105
 
@@ -110,58 +110,58 @@  discard block
 block discarded – undo
110 110
 	 * @param array $data List of CSV fields with position as key and data as value
111 111
 	 * @return array List of data which hasn't been imported
112 112
 	 */
113
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
113
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
114 114
 	{
115 115
 		$context = $this->getContext();
116
-		$listManager = \Aimeos\MShop::create( $context, 'product/lists' );
117
-		$separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" );
116
+		$listManager = \Aimeos\MShop::create($context, 'product/lists');
117
+		$separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n");
118 118
 
119 119
 		$listMap = [];
120
-		$map = $this->getMappedChunk( $data, $this->getMapping() );
121
-		$listItems = $product->getListItems( 'attribute', $this->listTypes );
120
+		$map = $this->getMappedChunk($data, $this->getMapping());
121
+		$listItems = $product->getListItems('attribute', $this->listTypes);
122 122
 
123
-		foreach( $listItems as $listItem )
123
+		foreach ($listItems as $listItem)
124 124
 		{
125
-			if( ( $refItem = $listItem->getRefItem() ) !== null ) {
126
-				$listMap[ $refItem->getCode() ][ $listItem->getType() ] = $listItem;
125
+			if (($refItem = $listItem->getRefItem()) !== null) {
126
+				$listMap[$refItem->getCode()][$listItem->getType()] = $listItem;
127 127
 			}
128 128
 		}
129 129
 
130
-		foreach( $map as $pos => $list )
130
+		foreach ($map as $pos => $list)
131 131
 		{
132
-			if( $this->checkEntry( $list ) === false ) {
132
+			if ($this->checkEntry($list) === false) {
133 133
 				continue;
134 134
 			}
135 135
 
136
-			$codes = explode( $separator, $this->getValue( $list, 'attribute.code', '' ) );
136
+			$codes = explode($separator, $this->getValue($list, 'attribute.code', ''));
137 137
 
138
-			foreach( $codes as $code )
138
+			foreach ($codes as $code)
139 139
 			{
140
-				$code = trim( $code );
141
-				$listtype = $this->getValue( $list, 'product.lists.type', 'default' );
140
+				$code = trim($code);
141
+				$listtype = $this->getValue($list, 'product.lists.type', 'default');
142 142
 
143
-				if( isset( $listMap[$code][$listtype] ) )
143
+				if (isset($listMap[$code][$listtype]))
144 144
 				{
145 145
 					$listItem = $listMap[$code][$listtype];
146
-					unset( $listItems[ $listItem->getId() ] );
146
+					unset($listItems[$listItem->getId()]);
147 147
 				}
148 148
 				else
149 149
 				{
150
-					$listItem = $listManager->createItem()->setType( $listtype );
150
+					$listItem = $listManager->createItem()->setType($listtype);
151 151
 				}
152 152
 
153
-				$listItem = $listItem->setPosition( $pos )->fromArray( $list );
153
+				$listItem = $listItem->setPosition($pos)->fromArray($list);
154 154
 
155
-				$attrItem = $this->getAttributeItem( $code, $this->getValue( $list, 'attribute.type' ) );
156
-				$attrItem = $attrItem->setCode( $code )->fromArray( $list );
155
+				$attrItem = $this->getAttributeItem($code, $this->getValue($list, 'attribute.type'));
156
+				$attrItem = $attrItem->setCode($code)->fromArray($list);
157 157
 
158
-				$product->addListItem( 'attribute', $listItem, $attrItem );
158
+				$product->addListItem('attribute', $listItem, $attrItem);
159 159
 			}
160 160
 		}
161 161
 
162
-		$product->deleteListItems( $listItems );
162
+		$product->deleteListItems($listItems);
163 163
 
164
-		return $this->getObject()->process( $product, $data );
164
+		return $this->getObject()->process($product, $data);
165 165
 	}
166 166
 
167 167
 
@@ -171,22 +171,22 @@  discard block
 block discarded – undo
171 171
 	 * @param array $list Associative list of key/value pairs from the mapped data
172 172
 	 * @return boolean True if the entry is valid, false if not
173 173
 	 */
174
-	protected function checkEntry( array $list )
174
+	protected function checkEntry(array $list)
175 175
 	{
176
-		if( $this->getValue( $list, 'attribute.code' ) === null ) {
176
+		if ($this->getValue($list, 'attribute.code') === null) {
177 177
 			return false;
178 178
 		}
179 179
 
180
-		if( ( $type = $this->getValue( $list, 'product.lists.type' ) ) && !isset( $this->listTypes[$type] ) )
180
+		if (($type = $this->getValue($list, 'product.lists.type')) && !isset($this->listTypes[$type]))
181 181
 		{
182
-			$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'product list' );
183
-			throw new \Aimeos\Controller\Common\Exception( $msg );
182
+			$msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'product list');
183
+			throw new \Aimeos\Controller\Common\Exception($msg);
184 184
 		}
185 185
 
186
-		if( ( $type = $this->getValue( $list, 'attribute.type' ) ) && !isset( $this->types[$type] ) )
186
+		if (($type = $this->getValue($list, 'attribute.type')) && !isset($this->types[$type]))
187 187
 		{
188
-			$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'attribute' );
189
-			throw new \Aimeos\Controller\Common\Exception( $msg );
188
+			$msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'attribute');
189
+			throw new \Aimeos\Controller\Common\Exception($msg);
190 190
 		}
191 191
 
192 192
 		return true;
@@ -200,22 +200,22 @@  discard block
 block discarded – undo
200 200
 	 * @param string $type Attribute type
201 201
 	 * @return \Aimeos\MShop\Attribute\Item\Iface Attribute item object
202 202
 	 */
203
-	protected function getAttributeItem( $code, $type )
203
+	protected function getAttributeItem($code, $type)
204 204
 	{
205
-		if( ( $item = $this->cache->get( $code, $type ) ) === null )
205
+		if (($item = $this->cache->get($code, $type)) === null)
206 206
 		{
207
-			$manager = \Aimeos\MShop::create( $this->getContext(), 'attribute' );
207
+			$manager = \Aimeos\MShop::create($this->getContext(), 'attribute');
208 208
 
209 209
 			$item = $manager->createItem();
210
-			$item->setType( $type );
211
-			$item->setDomain( 'product' );
212
-			$item->setLabel( $code );
213
-			$item->setCode( $code );
214
-			$item->setStatus( 1 );
210
+			$item->setType($type);
211
+			$item->setDomain('product');
212
+			$item->setLabel($code);
213
+			$item->setCode($code);
214
+			$item->setStatus(1);
215 215
 
216
-			$item = $manager->saveItem( $item );
216
+			$item = $manager->saveItem($item);
217 217
 
218
-			$this->cache->set( $item );
218
+			$this->cache->set($item);
219 219
 		}
220 220
 
221 221
 		return $item;
Please login to merge, or discard this patch.
controller/common/src/Controller/Common/Product/Import/Csv/Base.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -27,14 +27,14 @@  discard block
 block discarded – undo
27 27
 	 * @param array $data Associative list of product codes and lists of CSV field indexes and their data
28 28
 	 * @return array Associative list of CSV field indexes and their converted data
29 29
 	 */
30
-	protected function convertData( array $convlist, array $data )
30
+	protected function convertData(array $convlist, array $data)
31 31
 	{
32
-		foreach( $convlist as $idx => $converter )
32
+		foreach ($convlist as $idx => $converter)
33 33
 		{
34
-			foreach( $data as $code => $list )
34
+			foreach ($data as $code => $list)
35 35
 			{
36
-				if( isset( $list[$idx] ) ) {
37
-					$data[$code][$idx] = $converter->translate( $list[$idx] );
36
+				if (isset($list[$idx])) {
37
+					$data[$code][$idx] = $converter->translate($list[$idx]);
38 38
 				}
39 39
 			}
40 40
 		}
@@ -50,36 +50,36 @@  discard block
 block discarded – undo
50 50
 	 * @param string|null Name of the cache implementation
51 51
 	 * @return \Aimeos\Controller\Common\Product\Import\Csv\Cache\Iface Cache object
52 52
 	 */
53
-	protected function getCache( $type, $name = null )
53
+	protected function getCache($type, $name = null)
54 54
 	{
55 55
 		$context = $this->getContext();
56 56
 		$config = $context->getConfig();
57 57
 
58
-		if( ctype_alnum( $type ) === false )
58
+		if (ctype_alnum($type) === false)
59 59
 		{
60 60
 			$classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\' . $type : '<not a string>';
61
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
61
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
62 62
 		}
63 63
 
64
-		if( $name === null ) {
65
-			$name = $config->get( 'controller/common/product/import/csv/cache/' . $type . '/name', 'Standard' );
64
+		if ($name === null) {
65
+			$name = $config->get('controller/common/product/import/csv/cache/' . $type . '/name', 'Standard');
66 66
 		}
67 67
 
68
-		if( ctype_alnum( $name ) === false )
68
+		if (ctype_alnum($name) === false)
69 69
 		{
70 70
 			$classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\' . $type . '\\' . $name : '<not a string>';
71
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
71
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
72 72
 		}
73 73
 
74
-		$classname = '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\' . ucfirst( $type ) . '\\' . $name;
74
+		$classname = '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\' . ucfirst($type) . '\\' . $name;
75 75
 
76
-		if( class_exists( $classname ) === false ) {
77
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) );
76
+		if (class_exists($classname) === false) {
77
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname));
78 78
 		}
79 79
 
80
-		$object = new $classname( $context );
80
+		$object = new $classname($context);
81 81
 
82
-		\Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\Iface', $object );
82
+		\Aimeos\MW\Common\Base::checkClass('\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\Iface', $object);
83 83
 
84 84
 		return $object;
85 85
 	}
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
 	 * @param array $convmap List of converter names for the values at the position in the CSV file
92 92
 	 * @return array Associative list of positions and converter objects
93 93
 	 */
94
-	protected function getConverterList( array $convmap )
94
+	protected function getConverterList(array $convmap)
95 95
 	{
96 96
 		$convlist = [];
97 97
 
98
-		foreach( $convmap as $idx => $name ) {
99
-			$convlist[$idx] = \Aimeos\MW\Convert\Factory::createConverter( $name );
98
+		foreach ($convmap as $idx => $name) {
99
+			$convlist[$idx] = \Aimeos\MW\Convert\Factory::createConverter($name);
100 100
 		}
101 101
 
102 102
 		return $convlist;
@@ -111,15 +111,15 @@  discard block
 block discarded – undo
111 111
 	 * @param integer $codePos Column position which contains the unique product code (starting from 0)
112 112
 	 * @return array List of arrays with product codes as keys and list of values from the CSV file
113 113
 	 */
114
-	protected function getData( \Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos )
114
+	protected function getData(\Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos)
115 115
 	{
116 116
 		$count = 0;
117 117
 		$data = [];
118 118
 
119
-		while( $content->valid() && $count++ < $maxcnt )
119
+		while ($content->valid() && $count++ < $maxcnt)
120 120
 		{
121 121
 			$row = $content->current();
122
-			$data[ $row[$codePos] ] = $row;
122
+			$data[$row[$codePos]] = $row;
123 123
 			$content->next();
124 124
 		}
125 125
 
@@ -218,21 +218,21 @@  discard block
 block discarded – undo
218 218
 	 * @param array $mapping List of domain item keys with the CSV field position as key
219 219
 	 * @return array List of associative arrays containing the chunked properties
220 220
 	 */
221
-	protected function getMappedChunk( array &$data, array $mapping )
221
+	protected function getMappedChunk(array &$data, array $mapping)
222 222
 	{
223 223
 		$idx = 0;
224 224
 		$map = [];
225 225
 
226
-		foreach( $mapping as $pos => $key )
226
+		foreach ($mapping as $pos => $key)
227 227
 		{
228
-			if( isset( $map[$idx][$key] ) ) {
228
+			if (isset($map[$idx][$key])) {
229 229
 				$idx++;
230 230
 			}
231 231
 
232
-			if( isset( $data[$pos] ) )
232
+			if (isset($data[$pos]))
233 233
 			{
234 234
 				$map[$idx][$key] = $data[$pos];
235
-				unset( $data[$pos] );
235
+				unset($data[$pos]);
236 236
 			}
237 237
 		}
238 238
 
@@ -246,37 +246,37 @@  discard block
 block discarded – undo
246 246
 	 * @param array $mappings Associative list of processor types as keys and index/data mappings as values
247 247
 	 * @return \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface Processor object
248 248
 	 */
249
-	protected function getProcessors( array $mappings )
249
+	protected function getProcessors(array $mappings)
250 250
 	{
251 251
 		$context = $this->getContext();
252 252
 		$config = $context->getConfig();
253
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done( $context, [] );
253
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done($context, []);
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
-			\Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\Iface', $object );
279
+			\Aimeos\MW\Common\Base::checkClass('\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\Iface', $object);
280 280
 		}
281 281
 
282 282
 		return $object;
@@ -290,17 +290,17 @@  discard block
 block discarded – undo
290 290
 	 * @param array $domains List of domains whose items should be fetched too
291 291
 	 * @return array Associative list of product codes as key and product items as value
292 292
 	 */
293
-	protected function getProducts( array $codes, array $domains )
293
+	protected function getProducts(array $codes, array $domains)
294 294
 	{
295 295
 		$result = [];
296
-		$manager = \Aimeos\MShop::create( $this->getContext(), 'product' );
296
+		$manager = \Aimeos\MShop::create($this->getContext(), 'product');
297 297
 
298 298
 		$search = $manager->createSearch();
299
-		$search->setConditions( $search->compare( '==', 'product.code', $codes ) );
300
-		$search->setSlice( 0, count( $codes ) );
299
+		$search->setConditions($search->compare('==', 'product.code', $codes));
300
+		$search->setSlice(0, count($codes));
301 301
 
302
-		foreach( $manager->searchItems( $search, $domains ) as $item ) {
303
-			$result[ $item->getCode() ] = $item;
302
+		foreach ($manager->searchItems($search, $domains) as $item) {
303
+			$result[$item->getCode()] = $item;
304 304
 		}
305 305
 
306 306
 		return $result;
Please login to merge, or discard this patch.
src/Controller/Common/Subscription/Process/Processor/Cgroup/Standard.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object
42 42
 	 */
43
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context )
43
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context)
44 44
 	{
45
-		parent::__construct( $context );
45
+		parent::__construct($context);
46 46
 
47 47
 		$config = $context->getConfig();
48 48
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		 * @since 2018.04
58 58
 		 * @category Developer
59 59
 		 */
60
-		$this->groupIds = (array) $config->get( 'controller/common/subscription/process/processor/cgroup/groupids', [] );
60
+		$this->groupIds = (array) $config->get('controller/common/subscription/process/processor/cgroup/groupids', []);
61 61
 	}
62 62
 
63 63
 
@@ -66,22 +66,22 @@  discard block
 block discarded – undo
66 66
 	 *
67 67
 	 * @param \Aimeos\MShop\Subscription\Item\Iface $subscription Subscription item
68 68
 	 */
69
-	public function begin( \Aimeos\MShop\Subscription\Item\Iface $subscription )
69
+	public function begin(\Aimeos\MShop\Subscription\Item\Iface $subscription)
70 70
 	{
71
-		if( empty( $this->groupIds ) ) {
71
+		if (empty($this->groupIds)) {
72 72
 			return;
73 73
 		}
74 74
 
75 75
 		$context = $this->getContext();
76 76
 
77
-		$manager = \Aimeos\MShop::create( $context, 'customer' );
78
-		$baseManager = \Aimeos\MShop::create( $context, 'order/base' );
77
+		$manager = \Aimeos\MShop::create($context, 'customer');
78
+		$baseManager = \Aimeos\MShop::create($context, 'order/base');
79 79
 
80
-		$baseItem = $baseManager->getItem( $subscription->getOrderBaseId() );
81
-		$item = $manager->getItem( $baseItem->getCustomerId(), ['customer/group'] );
80
+		$baseItem = $baseManager->getItem($subscription->getOrderBaseId());
81
+		$item = $manager->getItem($baseItem->getCustomerId(), ['customer/group']);
82 82
 
83
-		$item->setGroups( array_unique( array_merge( $item->getGroups(), $this->groupIds ) ) );
84
-		$manager->saveItem( $item );
83
+		$item->setGroups(array_unique(array_merge($item->getGroups(), $this->groupIds)));
84
+		$manager->saveItem($item);
85 85
 	}
86 86
 
87 87
 
@@ -90,21 +90,21 @@  discard block
 block discarded – undo
90 90
 	 *
91 91
 	 * @param \Aimeos\MShop\Subscription\Item\Iface $subscription Subscription item
92 92
 	 */
93
-	public function end( \Aimeos\MShop\Subscription\Item\Iface $subscription )
93
+	public function end(\Aimeos\MShop\Subscription\Item\Iface $subscription)
94 94
 	{
95
-		if( empty( $this->groupIds ) ) {
95
+		if (empty($this->groupIds)) {
96 96
 			return;
97 97
 		}
98 98
 
99 99
 		$context = $this->getContext();
100 100
 
101
-		$manager = \Aimeos\MShop::create( $context, 'customer' );
102
-		$baseManager = \Aimeos\MShop::create( $context, 'order/base' );
101
+		$manager = \Aimeos\MShop::create($context, 'customer');
102
+		$baseManager = \Aimeos\MShop::create($context, 'order/base');
103 103
 
104
-		$baseItem = $baseManager->getItem( $subscription->getOrderBaseId() );
105
-		$item = $manager->getItem( $baseItem->getCustomerId(), ['customer/group'] );
104
+		$baseItem = $baseManager->getItem($subscription->getOrderBaseId());
105
+		$item = $manager->getItem($baseItem->getCustomerId(), ['customer/group']);
106 106
 
107
-		$item->setGroups( array_diff( $item->getGroups(), $this->groupIds ) );
108
-		$manager->saveItem( $item );
107
+		$item->setGroups(array_diff($item->getGroups(), $this->groupIds));
108
+		$manager->saveItem($item);
109 109
 	}
110 110
 }
Please login to merge, or discard this patch.
common/src/Controller/Common/Coupon/Import/Csv/Processor/Code/Standard.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -40,20 +40,20 @@
 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\Coupon\Item\Code\Iface $item, array $data )
43
+	public function process(\Aimeos\MShop\Coupon\Item\Code\Iface $item, array $data)
44 44
 	{
45
-		$manager = \Aimeos\MShop::create( $this->getContext(), 'coupon/code' );
46
-		$map = $this->getMappedChunk( $data, $this->getMapping() );
45
+		$manager = \Aimeos\MShop::create($this->getContext(), 'coupon/code');
46
+		$map = $this->getMappedChunk($data, $this->getMapping());
47 47
 
48
-		foreach( $map as $list )
48
+		foreach ($map as $list)
49 49
 		{
50
-			if( trim( $list['coupon.code.code'] ) == '' ) {
50
+			if (trim($list['coupon.code.code']) == '') {
51 51
 				continue;
52 52
 			}
53 53
 
54
-			$item = $manager->saveItem( $item->fromArray( $list ) );
54
+			$item = $manager->saveItem($item->fromArray($list));
55 55
 		}
56 56
 
57
-		return $this->getObject()->process( $item, $data );
57
+		return $this->getObject()->process($item, $data);
58 58
 	}
59 59
 }
Please login to merge, or discard this patch.
controller/common/src/Controller/Common/Coupon/Import/Csv/Base.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -26,17 +26,17 @@  discard block
 block discarded – undo
26 26
 	 * @param array $codes List of coupon codes
27 27
 	 * @return array Associative list of coupon codes as key and coupon code items as value
28 28
 	 */
29
-	protected function getCouponCodeItems( array $codes )
29
+	protected function getCouponCodeItems(array $codes)
30 30
 	{
31 31
 		$result = [];
32
-		$manager = \Aimeos\MShop::create( $this->getContext(), 'coupon/code' );
32
+		$manager = \Aimeos\MShop::create($this->getContext(), 'coupon/code');
33 33
 
34 34
 		$search = $manager->createSearch();
35
-		$search->setConditions( $search->compare( '==', 'coupon.code.code', $codes ) );
36
-		$search->setSlice( 0, count( $codes ) );
35
+		$search->setConditions($search->compare('==', 'coupon.code.code', $codes));
36
+		$search->setSlice(0, count($codes));
37 37
 
38
-		foreach( $manager->searchItems( $search ) as $item ) {
39
-			$result[ $item->getCode() ] = $item;
38
+		foreach ($manager->searchItems($search) as $item) {
39
+			$result[$item->getCode()] = $item;
40 40
 		}
41 41
 
42 42
 		return $result;
@@ -51,15 +51,15 @@  discard block
 block discarded – undo
51 51
 	 * @param integer $codePos Column position which contains the unique coupon code (starting from 0)
52 52
 	 * @return array List of arrays with coupon codes as keys and list of values from the CSV file
53 53
 	 */
54
-	protected function getData( \Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos )
54
+	protected function getData(\Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos)
55 55
 	{
56 56
 		$count = 0;
57 57
 		$data = [];
58 58
 
59
-		while( $content->valid() && $count++ < $maxcnt )
59
+		while ($content->valid() && $count++ < $maxcnt)
60 60
 		{
61 61
 			$row = $content->current();
62
-			$data[ $row[$codePos] ] = $row;
62
+			$data[$row[$codePos]] = $row;
63 63
 			$content->next();
64 64
 		}
65 65
 
@@ -98,21 +98,21 @@  discard block
 block discarded – undo
98 98
 	 * @param array $mapping List of domain item keys with the CSV field position as key
99 99
 	 * @return array List of associative arrays containing the chunked properties
100 100
 	 */
101
-	protected function getMappedChunk( array &$data, array $mapping )
101
+	protected function getMappedChunk(array &$data, array $mapping)
102 102
 	{
103 103
 		$idx = 0;
104 104
 		$map = [];
105 105
 
106
-		foreach( $mapping as $pos => $key )
106
+		foreach ($mapping as $pos => $key)
107 107
 		{
108
-			if( isset( $map[$idx][$key] ) ) {
108
+			if (isset($map[$idx][$key])) {
109 109
 				$idx++;
110 110
 			}
111 111
 
112
-			if( isset( $data[$pos] ) )
112
+			if (isset($data[$pos]))
113 113
 			{
114 114
 				$map[$idx][$key] = $data[$pos];
115
-				unset( $data[$pos] );
115
+				unset($data[$pos]);
116 116
 			}
117 117
 		}
118 118
 
@@ -126,37 +126,37 @@  discard block
 block discarded – undo
126 126
 	 * @param array $mappings Associative list of processor types as keys and index/data mappings as values
127 127
 	 * @return \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface Processor object
128 128
 	 */
129
-	protected function getProcessors( array $mappings )
129
+	protected function getProcessors(array $mappings)
130 130
 	{
131 131
 		$context = $this->getContext();
132 132
 		$config = $context->getConfig();
133
-		$object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Done( $context, [] );
133
+		$object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Done($context, []);
134 134
 
135
-		foreach( $mappings as $type => $mapping )
135
+		foreach ($mappings as $type => $mapping)
136 136
 		{
137
-			if( ctype_alnum( $type ) === false )
137
+			if (ctype_alnum($type) === false)
138 138
 			{
139 139
 				$classname = is_string($type) ? '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\' . $type : '<not a string>';
140
-				throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
140
+				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
141 141
 			}
142 142
 
143
-			$name = $config->get( 'controller/common/coupon/import/csv/processor/' . $type . '/name', 'Standard' );
143
+			$name = $config->get('controller/common/coupon/import/csv/processor/' . $type . '/name', 'Standard');
144 144
 
145
-			if( ctype_alnum( $name ) === false )
145
+			if (ctype_alnum($name) === false)
146 146
 			{
147 147
 				$classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\' . $type . '\\' . $name : '<not a string>';
148
-				throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
148
+				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
149 149
 			}
150 150
 
151
-			$classname = '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\' . ucfirst( $type ) . '\\' . $name;
151
+			$classname = '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\' . ucfirst($type) . '\\' . $name;
152 152
 
153
-			if( class_exists( $classname ) === false ) {
154
-				throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) );
153
+			if (class_exists($classname) === false) {
154
+				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname));
155 155
 			}
156 156
 
157
-			$object = new $classname( $context, $mapping, $object );
157
+			$object = new $classname($context, $mapping, $object);
158 158
 
159
-			\Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\Iface', $object );
159
+			\Aimeos\MW\Common\Base::checkClass('\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\Iface', $object);
160 160
 		}
161 161
 
162 162
 		return $object;
Please login to merge, or discard this patch.
src/Controller/Common/Catalog/Import/Csv/Processor/Media/Standard.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
44 44
 	 * @param \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $object Decorated processor
45 45
 	 */
46
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping,
47
-			\Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $object = null )
46
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
47
+			\Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $object = null)
48 48
 	{
49
-		parent::__construct( $context, $mapping, $object );
49
+		parent::__construct($context, $mapping, $object);
50 50
 
51 51
 		/** controller/common/catalog/import/csv/processor/media/listtypes
52 52
 		 * Names of the catalog list types for media that are updated or removed
@@ -68,32 +68,32 @@  discard block
 block discarded – undo
68 68
 		 * @see controller/common/catalog/import/csv/processor/text/listtypes
69 69
 		 */
70 70
 		$key = 'controller/common/catalog/import/csv/processor/media/listtypes';
71
-		$this->listTypes = $context->getConfig()->get( $key );
71
+		$this->listTypes = $context->getConfig()->get($key);
72 72
 
73
-		if( $this->listTypes === null )
73
+		if ($this->listTypes === null)
74 74
 		{
75 75
 			$this->listTypes = [];
76
-			$manager = \Aimeos\MShop::create( $context, 'catalog/lists/type' );
76
+			$manager = \Aimeos\MShop::create($context, 'catalog/lists/type');
77 77
 
78
-			$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
79
-			$search->setConditions( $search->compare( '==', 'catalog.lists.type.domain', 'media' ) );
78
+			$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
79
+			$search->setConditions($search->compare('==', 'catalog.lists.type.domain', 'media'));
80 80
 
81
-			foreach( $manager->searchItems( $search ) as $item ) {
81
+			foreach ($manager->searchItems($search) as $item) {
82 82
 				$this->listTypes[$item->getCode()] = $item->getCode();
83 83
 			}
84 84
 		}
85 85
 		else
86 86
 		{
87
-			$this->listTypes = array_flip( $this->listTypes );
87
+			$this->listTypes = array_flip($this->listTypes);
88 88
 		}
89 89
 
90 90
 
91
-		$manager = \Aimeos\MShop::create( $context, 'media/type' );
91
+		$manager = \Aimeos\MShop::create($context, 'media/type');
92 92
 
93
-		$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
94
-		$search->setConditions( $search->compare( '==', 'media.type.domain', 'catalog' ) );
93
+		$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
94
+		$search->setConditions($search->compare('==', 'media.type.domain', 'catalog'));
95 95
 
96
-		foreach( $manager->searchItems( $search ) as $item ) {
96
+		foreach ($manager->searchItems($search) as $item) {
97 97
 			$this->types[$item->getCode()] = $item->getCode();
98 98
 		}
99 99
 	}
@@ -106,58 +106,58 @@  discard block
 block discarded – undo
106 106
 	 * @param array $data List of CSV fields with position as key and data as value
107 107
 	 * @return array List of data which hasn't been imported
108 108
 	 */
109
-	public function process( \Aimeos\MShop\Catalog\Item\Iface $catalog, array $data )
109
+	public function process(\Aimeos\MShop\Catalog\Item\Iface $catalog, array $data)
110 110
 	{
111 111
 		$context = $this->getContext();
112
-		$manager = \Aimeos\MShop::create( $context, 'media' );
113
-		$listManager = \Aimeos\MShop::create( $context, 'catalog/lists' );
114
-		$separator = $context->getConfig()->get( 'controller/common/catalog/import/csv/separator', "\n" );
112
+		$manager = \Aimeos\MShop::create($context, 'media');
113
+		$listManager = \Aimeos\MShop::create($context, 'catalog/lists');
114
+		$separator = $context->getConfig()->get('controller/common/catalog/import/csv/separator', "\n");
115 115
 
116 116
 		$listMap = [];
117
-		$map = $this->getMappedChunk( $data, $this->getMapping() );
118
-		$listItems = $catalog->getListItems( 'media', $this->listTypes );
117
+		$map = $this->getMappedChunk($data, $this->getMapping());
118
+		$listItems = $catalog->getListItems('media', $this->listTypes);
119 119
 
120
-		foreach( $listItems as $listItem )
120
+		foreach ($listItems as $listItem)
121 121
 		{
122
-			if( ( $refItem = $listItem->getRefItem() ) !== null ) {
123
-				$listMap[ $refItem->getUrl() ][ $refItem->getType() ][ $listItem->getType() ] = $listItem;
122
+			if (($refItem = $listItem->getRefItem()) !== null) {
123
+				$listMap[$refItem->getUrl()][$refItem->getType()][$listItem->getType()] = $listItem;
124 124
 			}
125 125
 		}
126 126
 
127
-		foreach( $map as $pos => $list )
127
+		foreach ($map as $pos => $list)
128 128
 		{
129
-			if( $this->checkEntry( $list ) === false ) {
129
+			if ($this->checkEntry($list) === false) {
130 130
 				continue;
131 131
 			}
132 132
 
133
-			$type = $this->getValue( $list, 'media.type', 'default' );
134
-			$listtype = $this->getValue( $list, 'catalog.lists.type', 'default' );
135
-			$urls = explode( $separator, $this->getValue( $list, 'media.url', '' ) );
133
+			$type = $this->getValue($list, 'media.type', 'default');
134
+			$listtype = $this->getValue($list, 'catalog.lists.type', 'default');
135
+			$urls = explode($separator, $this->getValue($list, 'media.url', ''));
136 136
 
137
-			foreach( $urls as $url )
137
+			foreach ($urls as $url)
138 138
 			{
139
-				if( isset( $listMap[$url][$type][$listtype] ) )
139
+				if (isset($listMap[$url][$type][$listtype]))
140 140
 				{
141 141
 					$listItem = $listMap[$url][$type][$listtype];
142 142
 					$refItem = $listItem->getRefItem();
143
-					unset( $listItems[ $listItem->getId() ] );
143
+					unset($listItems[$listItem->getId()]);
144 144
 				}
145 145
 				else
146 146
 				{
147
-					$listItem = $listManager->createItem()->setType( $listtype );
148
-					$refItem = $manager->createItem()->setType( $type );
147
+					$listItem = $listManager->createItem()->setType($listtype);
148
+					$refItem = $manager->createItem()->setType($type);
149 149
 				}
150 150
 
151
-				$listItem = $listItem->setPosition( $pos++ )->fromArray( $list );
152
-				$refItem = $refItem->setLabel( $url )->setPreview( $url )->fromArray( $list )->setUrl( $url );
151
+				$listItem = $listItem->setPosition($pos++)->fromArray($list);
152
+				$refItem = $refItem->setLabel($url)->setPreview($url)->fromArray($list)->setUrl($url);
153 153
 
154
-				$catalog->addListItem( 'media', $listItem, $refItem );
154
+				$catalog->addListItem('media', $listItem, $refItem);
155 155
 			}
156 156
 		}
157 157
 
158
-		$catalog->deleteListItems( $listItems, true );
158
+		$catalog->deleteListItems($listItems, true);
159 159
 
160
-		return $this->getObject()->process( $catalog, $data );
160
+		return $this->getObject()->process($catalog, $data);
161 161
 	}
162 162
 
163 163
 
@@ -167,22 +167,22 @@  discard block
 block discarded – undo
167 167
 	 * @param array $list Associative list of key/value pairs from the mapping
168 168
 	 * @return boolean True if valid, false if not
169 169
 	 */
170
-	protected function checkEntry( array $list )
170
+	protected function checkEntry(array $list)
171 171
 	{
172
-		if( $this->getValue( $list, 'media.url' ) === null ) {
172
+		if ($this->getValue($list, 'media.url') === null) {
173 173
 			return false;
174 174
 		}
175 175
 
176
-		if( ( $type = $this->getValue( $list, 'catalog.lists.type' ) ) && !isset( $this->listTypes[$type] ) )
176
+		if (($type = $this->getValue($list, 'catalog.lists.type')) && !isset($this->listTypes[$type]))
177 177
 		{
178
-			$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'catalog list' );
179
-			throw new \Aimeos\Controller\Common\Exception( $msg );
178
+			$msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'catalog list');
179
+			throw new \Aimeos\Controller\Common\Exception($msg);
180 180
 		}
181 181
 
182
-		if( ( $type = $this->getValue( $list, 'media.type' ) ) && !isset( $this->types[$type] ) )
182
+		if (($type = $this->getValue($list, 'media.type')) && !isset($this->types[$type]))
183 183
 		{
184
-			$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'media' );
185
-			throw new \Aimeos\Controller\Common\Exception( $msg );
184
+			$msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'media');
185
+			throw new \Aimeos\Controller\Common\Exception($msg);
186 186
 		}
187 187
 
188 188
 		return true;
Please login to merge, or discard this patch.