Completed
Push — master ( cbc921...0b1729 )
by Aimeos
02:05
created
common/src/Controller/Common/Product/Import/Csv/Cache/Product/Standard.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -42,20 +42,20 @@  discard block
 block discarded – undo
42 42
 	 * @param string|null $type Attribute type
43 43
 	 * @return string|null Product ID or null if not found
44 44
 	 */
45
-	public function get( $code, $type = null )
45
+	public function get($code, $type = null)
46 46
 	{
47
-		if( isset( $this->prodmap[$code] ) ) {
47
+		if (isset($this->prodmap[$code])) {
48 48
 			return $this->prodmap[$code];
49 49
 		}
50 50
 
51
-		$manager = \Aimeos\MShop::create( $this->getContext(), 'product' );
51
+		$manager = \Aimeos\MShop::create($this->getContext(), 'product');
52 52
 
53 53
 		$search = $manager->createSearch();
54
-		$search->setConditions( $search->compare( '==', 'product.code', $code ) );
54
+		$search->setConditions($search->compare('==', 'product.code', $code));
55 55
 
56
-		$result = $manager->searchItems( $search );
56
+		$result = $manager->searchItems($search);
57 57
 
58
-		if( ( $item = reset( $result ) ) !== false )
58
+		if (($item = reset($result)) !== false)
59 59
 		{
60 60
 			$this->prodmap[$code] = $item->getId();
61 61
 			return $this->prodmap[$code];
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
 	 *
69 69
 	 * @param \Aimeos\MShop\Common\Item\Iface $item Product object
70 70
 	 */
71
-	public function set( \Aimeos\MShop\Common\Item\Iface $item )
71
+	public function set(\Aimeos\MShop\Common\Item\Iface $item)
72 72
 	{
73
-		$this->prodmap[ $item->getCode() ] = $item->getId();
73
+		$this->prodmap[$item->getCode()] = $item->getId();
74 74
 	}
75 75
 }
76 76
\ No newline at end of file
Please login to merge, or discard this patch.
common/src/Controller/Common/Product/Import/Csv/Cache/Catalog/Standard.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -40,15 +40,15 @@  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
-		$manager = \Aimeos\MShop::create( $context, 'catalog' );
48
-		$result = $manager->searchItems( $manager->createSearch() );
47
+		$manager = \Aimeos\MShop::create($context, 'catalog');
48
+		$result = $manager->searchItems($manager->createSearch());
49 49
 
50
-		foreach( $result as $id => $item ) {
51
-			$this->categories[ $item->getCode() ] = $id;
50
+		foreach ($result as $id => $item) {
51
+			$this->categories[$item->getCode()] = $id;
52 52
 		}
53 53
 	}
54 54
 
@@ -60,20 +60,20 @@  discard block
 block discarded – undo
60 60
 	 * @param string|null $type Not used
61 61
 	 * @return string|null Catalog ID or null if not found
62 62
 	 */
63
-	public function get( $code, $type = null )
63
+	public function get($code, $type = null)
64 64
 	{
65
-		if( isset( $this->categories[$code] ) ) {
65
+		if (isset($this->categories[$code])) {
66 66
 			return $this->categories[$code];
67 67
 		}
68 68
 
69
-		$manager = \Aimeos\MShop::create( $this->getContext(), 'catalog' );
69
+		$manager = \Aimeos\MShop::create($this->getContext(), 'catalog');
70 70
 
71 71
 		$search = $manager->createSearch();
72
-		$search->setConditions( $search->compare( '==', 'catalog.code', $code ) );
72
+		$search->setConditions($search->compare('==', 'catalog.code', $code));
73 73
 
74
-		$result = $manager->searchItems( $search );
74
+		$result = $manager->searchItems($search);
75 75
 
76
-		if( ( $item = reset( $result ) ) !== false )
76
+		if (($item = reset($result)) !== false)
77 77
 		{
78 78
 			$this->categories[$code] = $item->getId();
79 79
 			return $item->getId();
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
 	 *
87 87
 	 * @param \Aimeos\MShop\Common\Item\Iface $item Catalog object
88 88
 	 */
89
-	public function set( \Aimeos\MShop\Common\Item\Iface $item )
89
+	public function set(\Aimeos\MShop\Common\Item\Iface $item)
90 90
 	{
91
-		$this->categories[ $item->getCode() ] = $item->getId();
91
+		$this->categories[$item->getCode()] = $item->getId();
92 92
 	}
93 93
 }
94 94
\ No newline at end of file
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Cache/Attribute/Standard.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -40,15 +40,15 @@  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
-		$manager = \Aimeos\MShop::create( $context, 'attribute' );
48
-		$result = $manager->searchItems( $manager->createSearch() );
47
+		$manager = \Aimeos\MShop::create($context, 'attribute');
48
+		$result = $manager->searchItems($manager->createSearch());
49 49
 
50
-		foreach( $result as $id => $item ) {
51
-			$this->attributes[ $item->getCode() ][ $item->getType() ] = $item;
50
+		foreach ($result as $id => $item) {
51
+			$this->attributes[$item->getCode()][$item->getType()] = $item;
52 52
 		}
53 53
 	}
54 54
 
@@ -60,24 +60,24 @@  discard block
 block discarded – undo
60 60
 	 * @param string|null $type Attribute type
61 61
 	 * @return \Aimeos\MShop\Attribute\Item\Iface|null Attribute object or null if not found
62 62
 	 */
63
-	public function get( $code, $type = null )
63
+	public function get($code, $type = null)
64 64
 	{
65
-		if( isset( $this->attributes[$code] ) && isset( $this->attributes[$code][$type] ) ) {
65
+		if (isset($this->attributes[$code]) && isset($this->attributes[$code][$type])) {
66 66
 			return $this->attributes[$code][$type];
67 67
 		}
68 68
 
69
-		$manager = \Aimeos\MShop::create( $this->getContext(), 'attribute' );
69
+		$manager = \Aimeos\MShop::create($this->getContext(), 'attribute');
70 70
 
71 71
 		$search = $manager->createSearch();
72 72
 		$expr = array(
73
-			$search->compare( '==', 'attribute.code', $code ),
74
-			$search->compare( '==', 'attribute.type', $type ),
73
+			$search->compare('==', 'attribute.code', $code),
74
+			$search->compare('==', 'attribute.type', $type),
75 75
 		);
76
-		$search->setConditions( $search->combine( '&&', $expr ) );
76
+		$search->setConditions($search->combine('&&', $expr));
77 77
 
78
-		$result = $manager->searchItems( $search );
78
+		$result = $manager->searchItems($search);
79 79
 
80
-		if( ( $item = reset( $result ) ) !== false )
80
+		if (($item = reset($result)) !== false)
81 81
 		{
82 82
 			$this->attributes[$code][$type] = $item;
83 83
 			return $item;
@@ -90,14 +90,14 @@  discard block
 block discarded – undo
90 90
 	 *
91 91
 	 * @param \Aimeos\MShop\Common\Item\Iface $item Attribute object
92 92
 	 */
93
-	public function set( \Aimeos\MShop\Common\Item\Iface $item )
93
+	public function set(\Aimeos\MShop\Common\Item\Iface $item)
94 94
 	{
95 95
 		$code = $item->getCode();
96 96
 
97
-		if( !isset( $this->attributes[$code] ) || !is_array( $this->attributes[$code] ) ) {
97
+		if (!isset($this->attributes[$code]) || !is_array($this->attributes[$code])) {
98 98
 			$this->attributes[$code] = [];
99 99
 		}
100 100
 
101
-		$this->attributes[$code][ $item->getType() ] = $item;
101
+		$this->attributes[$code][$item->getType()] = $item;
102 102
 	}
103 103
 }
104 104
\ No newline at end of file
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Processor/Product/Standard.php 1 patch
Spacing   +35 added lines, -35 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/product/listtypes
52 52
 		 * Names of the product list types that are updated or removed
@@ -74,26 +74,26 @@  discard block
 block discarded – undo
74 74
 		 * @see controller/common/product/import/csv/processor/text/listtypes
75 75
 		 */
76 76
 		$key = 'controller/common/product/import/csv/processor/product/listtypes';
77
-		$this->listTypes = $context->getConfig()->get( $key, ['default', 'suggestion'] );
77
+		$this->listTypes = $context->getConfig()->get($key, ['default', 'suggestion']);
78 78
 
79
-		if( $this->listTypes === null )
79
+		if ($this->listTypes === null)
80 80
 		{
81 81
 			$this->listTypes = [];
82
-			$manager = \Aimeos\MShop::create( $context, 'product/lists/type' );
82
+			$manager = \Aimeos\MShop::create($context, 'product/lists/type');
83 83
 
84
-			$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
85
-			$search->setConditions( $search->compare( '==', 'product.lists.type.domain', 'product' ) );
84
+			$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
85
+			$search->setConditions($search->compare('==', 'product.lists.type.domain', 'product'));
86 86
 
87
-			foreach( $manager->searchItems( $search ) as $item ) {
87
+			foreach ($manager->searchItems($search) as $item) {
88 88
 				$this->listTypes[$item->getCode()] = $item->getCode();
89 89
 			}
90 90
 		}
91 91
 		else
92 92
 		{
93
-			$this->listTypes = array_flip( $this->listTypes );
93
+			$this->listTypes = array_flip($this->listTypes);
94 94
 		}
95 95
 
96
-		$this->cache = $this->getCache( 'product' );
96
+		$this->cache = $this->getCache('product');
97 97
 	}
98 98
 
99 99
 
@@ -104,47 +104,47 @@  discard block
 block discarded – undo
104 104
 	 * @param array $data List of CSV fields with position as key and data as value
105 105
 	 * @return array List of data which has not been imported
106 106
 	 */
107
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
107
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
108 108
 	{
109 109
 		$context = $this->getContext();
110
-		$manager = \Aimeos\MShop::create( $context, 'product/lists' );
111
-		$separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" );
110
+		$manager = \Aimeos\MShop::create($context, 'product/lists');
111
+		$separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n");
112 112
 
113
-		$listItems = $product->getListItems( 'product', null, null, false );
114
-		$this->cache->set( $product );
113
+		$listItems = $product->getListItems('product', null, null, false);
114
+		$this->cache->set($product);
115 115
 
116
-		foreach( $this->getMappedChunk( $data, $this->getMapping() ) as $list )
116
+		foreach ($this->getMappedChunk($data, $this->getMapping()) as $list)
117 117
 		{
118
-			if( $this->checkEntry( $list ) === false ) {
118
+			if ($this->checkEntry($list) === false) {
119 119
 				continue;
120 120
 			}
121 121
 
122
-			$listtype = $this->getValue( $list, 'product.lists.type', 'default' );
122
+			$listtype = $this->getValue($list, 'product.lists.type', 'default');
123 123
 
124
-			foreach( explode( $separator, $this->getValue( $list, 'product.code', '' ) ) as $code )
124
+			foreach (explode($separator, $this->getValue($list, 'product.code', '')) as $code)
125 125
 			{
126
-				$code = trim( $code );
126
+				$code = trim($code);
127 127
 
128
-				if( ( $prodid = $this->cache->get( $code ) ) === null )
128
+				if (($prodid = $this->cache->get($code)) === null)
129 129
 				{
130 130
 					$msg = 'No product for code "%1$s" available when importing product with code "%2$s"';
131
-					throw new \Aimeos\Controller\Jobs\Exception( sprintf( $msg, $code, $product->getCode() ) );
131
+					throw new \Aimeos\Controller\Jobs\Exception(sprintf($msg, $code, $product->getCode()));
132 132
 				}
133 133
 
134
-				if( ( $listItem = $product->getListItem( 'product', $listtype, $prodid ) ) === null ) {
135
-					$listItem = $manager->createItem()->setType( $listtype );
134
+				if (($listItem = $product->getListItem('product', $listtype, $prodid)) === null) {
135
+					$listItem = $manager->createItem()->setType($listtype);
136 136
 				} else {
137
-					unset( $listItems[$listItem->getId()] );
137
+					unset($listItems[$listItem->getId()]);
138 138
 				}
139 139
 
140
-				$listItem = $listItem->fromArray( $list )->setRefId( $prodid );
141
-				$product->addListItem( 'product', $listItem );
140
+				$listItem = $listItem->fromArray($list)->setRefId($prodid);
141
+				$product->addListItem('product', $listItem);
142 142
 			}
143 143
 		}
144 144
 
145
-		$product->deleteListItems( $listItems );
145
+		$product->deleteListItems($listItems);
146 146
 
147
-		return $this->getObject()->process( $product, $data );
147
+		return $this->getObject()->process($product, $data);
148 148
 	}
149 149
 
150 150
 
@@ -154,16 +154,16 @@  discard block
 block discarded – undo
154 154
 	 * @param array $list Associative list of key/value pairs from the mapping
155 155
 	 * @return boolean True if valid, false if not
156 156
 	 */
157
-	protected function checkEntry( array $list )
157
+	protected function checkEntry(array $list)
158 158
 	{
159
-		if( $this->getValue( $list, 'product.code' ) === null ) {
159
+		if ($this->getValue($list, 'product.code') === null) {
160 160
 			return false;
161 161
 		}
162 162
 
163
-		if( ( $type = $this->getValue( $list, 'product.lists.type' ) ) && !isset( $this->listTypes[$type] ) )
163
+		if (($type = $this->getValue($list, 'product.lists.type')) && !isset($this->listTypes[$type]))
164 164
 		{
165
-			$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'product list' );
166
-			throw new \Aimeos\Controller\Common\Exception( $msg );
165
+			$msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'product list');
166
+			throw new \Aimeos\Controller\Common\Exception($msg);
167 167
 		}
168 168
 
169 169
 		return true;
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Processor/Property/Standard.php 1 patch
Spacing   +23 added lines, -23 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, 'product/property/type' );
51
-		$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
50
+		$manager = \Aimeos\MShop::create($context, 'product/property/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,45 +63,45 @@  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(), 'product/property' );
68
+		$manager = \Aimeos\MShop::create($this->getContext(), 'product/property');
69 69
 
70 70
 		$propMap = [];
71
-		$items = $product->getPropertyItems( null, false );
72
-		$map = $this->getMappedChunk( $data, $this->getMapping() );
71
+		$items = $product->getPropertyItems(null, false);
72
+		$map = $this->getMappedChunk($data, $this->getMapping());
73 73
 
74
-		foreach( $items as $item ) {
75
-			$propMap[ $item->getValue() ][ $item->getType() ] = $item;
74
+		foreach ($items as $item) {
75
+			$propMap[$item->getValue()][$item->getType()] = $item;
76 76
 		}
77 77
 
78
-		foreach( $map as $list )
78
+		foreach ($map as $list)
79 79
 		{
80
-			if( ( $value = $this->getValue( $list, 'product.property.value' ) ) === null ) {
80
+			if (($value = $this->getValue($list, 'product.property.value')) === null) {
81 81
 				continue;
82 82
 			}
83 83
 
84
-			if( ( $type = $this->getValue( $list, 'product.property.type' ) ) && !isset( $this->types[$type] ) )
84
+			if (($type = $this->getValue($list, 'product.property.type')) && !isset($this->types[$type]))
85 85
 			{
86
-				$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'product property' );
87
-				throw new \Aimeos\Controller\Common\Exception( $msg );
86
+				$msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'product property');
87
+				throw new \Aimeos\Controller\Common\Exception($msg);
88 88
 			}
89 89
 
90
-			if( isset( $propMap[$value][$type] ) )
90
+			if (isset($propMap[$value][$type]))
91 91
 			{
92 92
 				$item = $propMap[$value][$type];
93
-				unset( $items[ $item->getId() ] );
93
+				unset($items[$item->getId()]);
94 94
 			}
95 95
 			else
96 96
 			{
97
-				$item = $manager->createItem()->setType( $type );
97
+				$item = $manager->createItem()->setType($type);
98 98
 			}
99 99
 
100
-			$product->addPropertyItem( $item->fromArray( $list ) );
100
+			$product->addPropertyItem($item->fromArray($list));
101 101
 		}
102 102
 
103
-		$product->deletePropertyItems( $items );
103
+		$product->deletePropertyItems($items);
104 104
 
105
-		return $this->getObject()->process( $product, $data );
105
+		return $this->getObject()->process($product, $data);
106 106
 	}
107 107
 }
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Processor/Catalog/Standard.php 1 patch
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
44 44
 	 * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor
45 45
 	 */
46
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping,
47
-		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null )
46
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
47
+		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null)
48 48
 	{
49
-		parent::__construct( $context, $mapping, $object );
49
+		parent::__construct($context, $mapping, $object);
50 50
 
51 51
 		/** controller/common/product/import/csv/processor/catalog/listtypes
52 52
 		 * Names of the catalog list types that are updated or removed
@@ -68,26 +68,26 @@  discard block
 block discarded – undo
68 68
 		 * @see controller/common/product/import/csv/processor/text/listtypes
69 69
 		 */
70 70
 		$key = 'controller/common/product/import/csv/processor/catalog/listtypes';
71
-		$this->listTypes = $context->getConfig()->get( $key );
71
+		$this->listTypes = $context->getConfig()->get($key);
72 72
 
73
-		if( $this->listTypes === null )
73
+		if ($this->listTypes === null)
74 74
 		{
75 75
 			$this->listTypes = [];
76
-			$manager = \Aimeos\MShop::create( $context, 'catalog/lists/type' );
76
+			$manager = \Aimeos\MShop::create($context, 'catalog/lists/type');
77 77
 
78
-			$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
79
-			$search->setConditions( $search->compare( '==', 'catalog.lists.type.domain', 'product' ) );
78
+			$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
79
+			$search->setConditions($search->compare('==', 'catalog.lists.type.domain', 'product'));
80 80
 
81
-			foreach( $manager->searchItems( $search ) as $item ) {
81
+			foreach ($manager->searchItems($search) as $item) {
82 82
 				$this->listTypes[$item->getCode()] = $item->getCode();
83 83
 			}
84 84
 		}
85 85
 		else
86 86
 		{
87
-			$this->listTypes = array_flip( $this->listTypes );
87
+			$this->listTypes = array_flip($this->listTypes);
88 88
 		}
89 89
 
90
-		$this->cache = $this->getCache( 'catalog' );
90
+		$this->cache = $this->getCache('catalog');
91 91
 	}
92 92
 
93 93
 
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
 	 * @param array $data List of CSV fields with position as key and data as value
99 99
 	 * @return array List of data which hasn't been imported
100 100
 	 */
101
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
101
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
102 102
 	{
103 103
 		$context = $this->getContext();
104
-		$manager = \Aimeos\MShop::create( $context, 'catalog' );
105
-		$listManager = \Aimeos\MShop::create( $context, 'catalog/lists' );
104
+		$manager = \Aimeos\MShop::create($context, 'catalog');
105
+		$listManager = \Aimeos\MShop::create($context, 'catalog/lists');
106 106
 
107 107
 		/** controller/common/product/import/csv/separator
108 108
 		 * Single separator character for multiple entries in one field of the import file
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 		 * @category Developer
123 123
 		 * @see controller/common/product/import/csv/domains
124 124
 		 */
125
-		$separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" );
125
+		$separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n");
126 126
 
127 127
 		$manager->begin();
128 128
 
@@ -130,57 +130,57 @@  discard block
 block discarded – undo
130 130
 		{
131 131
 			$listMap = [];
132 132
 			$prodid = $product->getId();
133
-			$map = $this->getMappedChunk( $data, $this->getMapping() );
134
-			$listItems = $this->getListItems( $prodid, $this->listTypes );
133
+			$map = $this->getMappedChunk($data, $this->getMapping());
134
+			$listItems = $this->getListItems($prodid, $this->listTypes);
135 135
 
136
-			foreach( $listItems as $listItem ) {
137
-				$listMap[ $listItem->getParentId() ][ $listItem->getType() ] = $listItem;
136
+			foreach ($listItems as $listItem) {
137
+				$listMap[$listItem->getParentId()][$listItem->getType()] = $listItem;
138 138
 			}
139 139
 
140
-			foreach( $map as $pos => $list )
140
+			foreach ($map as $pos => $list)
141 141
 			{
142
-				if( $this->checkEntry( $list ) === false ) {
142
+				if ($this->checkEntry($list) === false) {
143 143
 					continue;
144 144
 				}
145 145
 
146
-				$codes = explode( $separator, $this->getValue( $list, 'catalog.code', '' ) );
147
-				$listtype = $this->getValue( $list, 'catalog.lists.type', 'default' );
146
+				$codes = explode($separator, $this->getValue($list, 'catalog.code', ''));
147
+				$listtype = $this->getValue($list, 'catalog.lists.type', 'default');
148 148
 
149
-				foreach( $codes as $code )
149
+				foreach ($codes as $code)
150 150
 				{
151
-					$code = trim( $code );
151
+					$code = trim($code);
152 152
 
153
-					if( ( $catid = $this->cache->get( $code ) ) === null )
153
+					if (($catid = $this->cache->get($code)) === null)
154 154
 					{
155 155
 						$msg = 'No category for code "%1$s" available when importing product with code "%2$s"';
156
-						throw new \Aimeos\Controller\Jobs\Exception( sprintf( $msg, $code, $product->getCode() ) );
156
+						throw new \Aimeos\Controller\Jobs\Exception(sprintf($msg, $code, $product->getCode()));
157 157
 					}
158 158
 
159 159
 					$list['catalog.lists.parentid'] = $catid;
160 160
 					$list['catalog.lists.refid'] = $prodid;
161 161
 					$list['catalog.lists.domain'] = 'product';
162 162
 
163
-					if( isset( $listMap[$catid][$listtype] ) )
163
+					if (isset($listMap[$catid][$listtype]))
164 164
 					{
165 165
 						$listItem = $listMap[$catid][$listtype];
166
-						unset( $listItems[ $listItem->getId() ] );
166
+						unset($listItems[$listItem->getId()]);
167 167
 					}
168 168
 					else
169 169
 					{
170
-						$listItem = $listManager->createItem()->setType( $listtype );
170
+						$listItem = $listManager->createItem()->setType($listtype);
171 171
 					}
172 172
 
173
-					$listItem = $listItem->setPosition( $pos++ )->fromArray( $list );
174
-					$listManager->saveItem( $listItem, false );
173
+					$listItem = $listItem->setPosition($pos++)->fromArray($list);
174
+					$listManager->saveItem($listItem, false);
175 175
 				}
176 176
 			}
177 177
 
178
-			$listManager->deleteItems( array_keys( $listItems ) );
179
-			$data = $this->getObject()->process( $product, $data );
178
+			$listManager->deleteItems(array_keys($listItems));
179
+			$data = $this->getObject()->process($product, $data);
180 180
 
181 181
 			$manager->commit();
182 182
 		}
183
-		catch( \Exception $e )
183
+		catch (\Exception $e)
184 184
 		{
185 185
 			$manager->rollback();
186 186
 			throw $e;
@@ -197,13 +197,13 @@  discard block
 block discarded – undo
197 197
 	 * @param integer $pos Computed position of the list item in the associated list of items
198 198
 	 * @return array Given associative list enriched by default values if they were not already set
199 199
 	 */
200
-	protected function addListItemDefaults( array $list, $pos )
200
+	protected function addListItemDefaults(array $list, $pos)
201 201
 	{
202
-		if( !isset( $list['catalog.lists.position'] ) ) {
202
+		if (!isset($list['catalog.lists.position'])) {
203 203
 			$list['catalog.lists.position'] = $pos;
204 204
 		}
205 205
 
206
-		if( !isset( $list['catalog.lists.status'] ) ) {
206
+		if (!isset($list['catalog.lists.status'])) {
207 207
 			$list['catalog.lists.status'] = 1;
208 208
 		}
209 209
 
@@ -217,16 +217,16 @@  discard block
 block discarded – undo
217 217
 	 * @param array $list Associative list of key/value pairs from the mapped data
218 218
 	 * @return boolean True if the entry is valid, false if not
219 219
 	 */
220
-	protected function checkEntry( array $list )
220
+	protected function checkEntry(array $list)
221 221
 	{
222
-		if( $this->getValue( $list, 'catalog.code' ) === null ) {
222
+		if ($this->getValue($list, 'catalog.code') === null) {
223 223
 			return false;
224 224
 		}
225 225
 
226
-		if( ( $type = $this->getValue( $list, 'catalog.lists.type' ) ) && !isset( $this->listTypes[$type] ) )
226
+		if (($type = $this->getValue($list, 'catalog.lists.type')) && !isset($this->listTypes[$type]))
227 227
 		{
228
-			$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'catalog list' );
229
-			throw new \Aimeos\Controller\Common\Exception( $msg );
228
+			$msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'catalog list');
229
+			throw new \Aimeos\Controller\Common\Exception($msg);
230 230
 		}
231 231
 
232 232
 		return true;
@@ -240,24 +240,24 @@  discard block
 block discarded – undo
240 240
 	 * @param array|null $types List of catalog list types
241 241
 	 * @return array List of catalog list items
242 242
 	 */
243
-	protected function getListItems( $prodid, $types )
243
+	protected function getListItems($prodid, $types)
244 244
 	{
245
-		$manager = \Aimeos\MShop::create( $this->getContext(), 'catalog/lists' );
245
+		$manager = \Aimeos\MShop::create($this->getContext(), 'catalog/lists');
246 246
 		$search = $manager->createSearch();
247 247
 
248 248
 		$expr = array(
249
-			$search->compare( '==', 'catalog.lists.domain', 'product' ),
250
-			$search->compare( '==', 'catalog.lists.refid', $prodid ),
249
+			$search->compare('==', 'catalog.lists.domain', 'product'),
250
+			$search->compare('==', 'catalog.lists.refid', $prodid),
251 251
 		);
252 252
 
253
-		if( $types !== null ) {
254
-			$expr[] = $search->compare( '==', 'catalog.lists.type', $types );
253
+		if ($types !== null) {
254
+			$expr[] = $search->compare('==', 'catalog.lists.type', $types);
255 255
 		}
256 256
 
257
-		$search->setConditions( $search->combine( '&&', $expr ) );
258
-		$search->setSortations( array( $search->sort( '+', 'catalog.lists.position' ) ) );
259
-		$search->setSlice( 0, 0x7FFFFFFF );
257
+		$search->setConditions($search->combine('&&', $expr));
258
+		$search->setSortations(array($search->sort('+', 'catalog.lists.position')));
259
+		$search->setSlice(0, 0x7FFFFFFF);
260 260
 
261
-		return $manager->searchItems( $search );
261
+		return $manager->searchItems($search);
262 262
 	}
263 263
 }
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Processor/Media/Standard.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
44 44
 	 * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor
45 45
 	 */
46
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping,
47
-			\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null )
46
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
47
+			\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null)
48 48
 	{
49
-		parent::__construct( $context, $mapping, $object );
49
+		parent::__construct($context, $mapping, $object);
50 50
 
51 51
 		/** controller/common/product/import/csv/processor/media/listtypes
52 52
 		 * Names of the product list types for media that are updated or removed
@@ -68,32 +68,32 @@  discard block
 block discarded – undo
68 68
 		 * @see controller/common/product/import/csv/processor/text/listtypes
69 69
 		 */
70 70
 		$key = 'controller/common/product/import/csv/processor/media/listtypes';
71
-		$this->listTypes = $context->getConfig()->get( $key );
71
+		$this->listTypes = $context->getConfig()->get($key);
72 72
 
73
-		if( $this->listTypes === null )
73
+		if ($this->listTypes === null)
74 74
 		{
75 75
 			$this->listTypes = [];
76
-			$manager = \Aimeos\MShop::create( $context, 'product/lists/type' );
76
+			$manager = \Aimeos\MShop::create($context, 'product/lists/type');
77 77
 
78
-			$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
79
-			$search->setConditions( $search->compare( '==', 'product.lists.type.domain', 'media' ) );
78
+			$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
79
+			$search->setConditions($search->compare('==', 'product.lists.type.domain', 'media'));
80 80
 
81
-			foreach( $manager->searchItems( $search ) as $item ) {
81
+			foreach ($manager->searchItems($search) as $item) {
82 82
 				$this->listTypes[$item->getCode()] = $item->getCode();
83 83
 			}
84 84
 		}
85 85
 		else
86 86
 		{
87
-			$this->listTypes = array_flip( $this->listTypes );
87
+			$this->listTypes = array_flip($this->listTypes);
88 88
 		}
89 89
 
90 90
 
91
-		$manager = \Aimeos\MShop::create( $context, 'media/type' );
91
+		$manager = \Aimeos\MShop::create($context, 'media/type');
92 92
 
93
-		$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
94
-		$search->setConditions( $search->compare( '==', 'media.type.domain', 'product' ) );
93
+		$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
94
+		$search->setConditions($search->compare('==', 'media.type.domain', 'product'));
95 95
 
96
-		foreach( $manager->searchItems( $search ) as $item ) {
96
+		foreach ($manager->searchItems($search) as $item) {
97 97
 			$this->types[$item->getCode()] = $item->getCode();
98 98
 		}
99 99
 	}
@@ -106,60 +106,60 @@  discard block
 block discarded – undo
106 106
 	 * @param array $data List of CSV fields with position as key and data as value
107 107
 	 * @return array List of data which hasn't been imported
108 108
 	 */
109
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
109
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
110 110
 	{
111 111
 		$context = $this->getContext();
112
-		$manager = \Aimeos\MShop::create( $context, 'media' );
113
-		$listManager = \Aimeos\MShop::create( $context, 'product/lists' );
114
-		$separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" );
112
+		$manager = \Aimeos\MShop::create($context, 'media');
113
+		$listManager = \Aimeos\MShop::create($context, 'product/lists');
114
+		$separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n");
115 115
 
116 116
 		$listMap = [];
117
-		$map = $this->getMappedChunk( $data, $this->getMapping() );
118
-		$listItems = $product->getListItems( 'media', $this->listTypes );
117
+		$map = $this->getMappedChunk($data, $this->getMapping());
118
+		$listItems = $product->getListItems('media', $this->listTypes);
119 119
 
120
-		foreach( $listItems as $listItem )
120
+		foreach ($listItems as $listItem)
121 121
 		{
122
-			if( ( $refItem = $listItem->getRefItem() ) !== null ) {
123
-				$listMap[ $refItem->getUrl() ][ $refItem->getType() ][ $listItem->getType() ] = $listItem;
122
+			if (($refItem = $listItem->getRefItem()) !== null) {
123
+				$listMap[$refItem->getUrl()][$refItem->getType()][$listItem->getType()] = $listItem;
124 124
 			}
125 125
 		}
126 126
 
127
-		foreach( $map as $pos => $list )
127
+		foreach ($map as $pos => $list)
128 128
 		{
129
-			if( $this->checkEntry( $list ) === false ) {
129
+			if ($this->checkEntry($list) === false) {
130 130
 				continue;
131 131
 			}
132 132
 
133
-			$type = $this->getValue( $list, 'media.type', 'default' );
134
-			$listtype = $this->getValue( $list, 'product.lists.type', 'default' );
135
-			$urls = explode( $separator, $this->getValue( $list, 'media.url', '' ) );
133
+			$type = $this->getValue($list, 'media.type', 'default');
134
+			$listtype = $this->getValue($list, 'product.lists.type', 'default');
135
+			$urls = explode($separator, $this->getValue($list, 'media.url', ''));
136 136
 
137
-			foreach( $urls as $url )
137
+			foreach ($urls as $url)
138 138
 			{
139
-				$url = trim( $url );
139
+				$url = trim($url);
140 140
 
141
-				if( isset( $listMap[$url][$type][$listtype] ) )
141
+				if (isset($listMap[$url][$type][$listtype]))
142 142
 				{
143 143
 					$listItem = $listMap[$url][$type][$listtype];
144 144
 					$refItem = $listItem->getRefItem();
145
-					unset( $listItems[ $listItem->getId() ] );
145
+					unset($listItems[$listItem->getId()]);
146 146
 				}
147 147
 				else
148 148
 				{
149
-					$listItem = $listManager->createItem()->setType( $listtype );
150
-					$refItem = $manager->createItem()->setType( $type );
149
+					$listItem = $listManager->createItem()->setType($listtype);
150
+					$refItem = $manager->createItem()->setType($type);
151 151
 				}
152 152
 
153
-				$listItem = $listItem->setPosition( $pos++ )->fromArray( $list );
154
-				$refItem = $refItem->setLabel( $url )->setPreview( $url )->fromArray( $list )->setUrl( $url );
153
+				$listItem = $listItem->setPosition($pos++)->fromArray($list);
154
+				$refItem = $refItem->setLabel($url)->setPreview($url)->fromArray($list)->setUrl($url);
155 155
 
156
-				$product->addListItem( 'media', $listItem, $refItem );
156
+				$product->addListItem('media', $listItem, $refItem);
157 157
 			}
158 158
 		}
159 159
 
160
-		$product->deleteListItems( $listItems, true );
160
+		$product->deleteListItems($listItems, true);
161 161
 
162
-		return $this->getObject()->process( $product, $data );
162
+		return $this->getObject()->process($product, $data);
163 163
 	}
164 164
 
165 165
 
@@ -169,22 +169,22 @@  discard block
 block discarded – undo
169 169
 	 * @param array $list Associative list of key/value pairs from the mapping
170 170
 	 * @return boolean True if valid, false if not
171 171
 	 */
172
-	protected function checkEntry( array $list )
172
+	protected function checkEntry(array $list)
173 173
 	{
174
-		if( $this->getValue( $list, 'media.url' ) === null ) {
174
+		if ($this->getValue($list, 'media.url') === null) {
175 175
 			return false;
176 176
 		}
177 177
 
178
-		if( ( $type = $this->getValue( $list, 'product.lists.type' ) ) && !isset( $this->listTypes[$type] ) )
178
+		if (($type = $this->getValue($list, 'product.lists.type')) && !isset($this->listTypes[$type]))
179 179
 		{
180
-			$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'product list' );
181
-			throw new \Aimeos\Controller\Common\Exception( $msg );
180
+			$msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'product list');
181
+			throw new \Aimeos\Controller\Common\Exception($msg);
182 182
 		}
183 183
 
184
-		if( ( $type = $this->getValue( $list, 'media.type' ) ) && !isset( $this->types[$type] ) )
184
+		if (($type = $this->getValue($list, 'media.type')) && !isset($this->types[$type]))
185 185
 		{
186
-			$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $type, 'media' );
187
-			throw new \Aimeos\Controller\Common\Exception( $msg );
186
+			$msg = sprintf('Invalid type "%1$s" (%2$s)', $type, 'media');
187
+			throw new \Aimeos\Controller\Common\Exception($msg);
188 188
 		}
189 189
 
190 190
 		return true;
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Processor/Price/Standard.php 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.