Completed
Push — master ( 0ed5fa...41d654 )
by Aimeos
02:01
created
src/Controller/Common/Product/Import/Csv/Processor/Stock/Standard.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
43 43
 	 * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor
44 44
 	 */
45
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping,
46
-		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null )
45
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
46
+		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null)
47 47
 	{
48
-		parent::__construct( $context, $mapping, $object );
48
+		parent::__construct($context, $mapping, $object);
49 49
 
50
-		$this->cache = $this->getCache( 'stocktype' );
50
+		$this->cache = $this->getCache('stocktype');
51 51
 	}
52 52
 
53 53
 
@@ -58,53 +58,53 @@  discard block
 block discarded – undo
58 58
 	 * @param array $data List of CSV fields with position as key and data as value
59 59
 	 * @return array List of data which hasn't been imported
60 60
 	 */
61
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
61
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
62 62
 	{
63
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'stock' );
63
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'stock');
64 64
 		$manager->begin();
65 65
 
66 66
 		try
67 67
 		{
68
-			$map = $this->getMappedChunk( $data, $this->getMapping() );
69
-			$items = $this->getStockItems( $product->getCode() );
68
+			$map = $this->getMappedChunk($data, $this->getMapping());
69
+			$items = $this->getStockItems($product->getCode());
70 70
 
71
-			foreach( $map as $pos => $list )
71
+			foreach ($map as $pos => $list)
72 72
 			{
73
-				if( !array_key_exists( 'stock.stocklevel', $list ) ) {
73
+				if (!array_key_exists('stock.stocklevel', $list)) {
74 74
 					continue;
75 75
 				}
76 76
 
77
-				$stockType = trim( isset( $list['stock.type'] ) ? $list['stock.type'] : 'default' );
77
+				$stockType = trim(isset($list['stock.type']) ? $list['stock.type'] : 'default');
78 78
 
79
-				if( !isset( $list['stock.typeid'] ) ) {
80
-					$list['stock.typeid'] = $this->cache->get( $stockType );
79
+				if (!isset($list['stock.typeid'])) {
80
+					$list['stock.typeid'] = $this->cache->get($stockType);
81 81
 				}
82 82
 
83
-				if( isset( $list['stock.dateback'] ) && trim( $list['stock.dateback'] ) === '' ) {
83
+				if (isset($list['stock.dateback']) && trim($list['stock.dateback']) === '') {
84 84
 					$list['stock.dateback'] = null;
85 85
 				}
86 86
 
87
-				if( trim( $list['stock.stocklevel'] ) === '' ) {
87
+				if (trim($list['stock.stocklevel']) === '') {
88 88
 					$list['stock.stocklevel'] = null;
89 89
 				}
90 90
 
91 91
 				$list['stock.productcode'] = $product->getCode();
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
-				$item->fromArray( $list );
98
-				$manager->saveItem( $item, false );
97
+				$item->fromArray($list);
98
+				$manager->saveItem($item, false);
99 99
 			}
100 100
 
101
-			$manager->deleteItems( array_keys( $items ) );
101
+			$manager->deleteItems(array_keys($items));
102 102
 
103
-			$data = $this->getObject()->process( $product, $data );
103
+			$data = $this->getObject()->process($product, $data);
104 104
 
105 105
 			$manager->commit();
106 106
 		}
107
-		catch( \Exception $e )
107
+		catch (\Exception $e)
108 108
 		{
109 109
 			$manager->rollback();
110 110
 			throw $e;
@@ -120,13 +120,13 @@  discard block
 block discarded – undo
120 120
 	 * @param string $code Unique product code
121 121
 	 * @return \Aimeos\MShop\Stock\Item\Iface[] Associative list of stock items
122 122
 	 */
123
-	protected function getStockItems( $code )
123
+	protected function getStockItems($code)
124 124
 	{
125
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'stock' );
125
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'stock');
126 126
 
127 127
 		$search = $manager->createSearch();
128
-		$search->setConditions( $search->compare( '==', 'stock.productcode', $code ) );
128
+		$search->setConditions($search->compare('==', 'stock.productcode', $code));
129 129
 
130
-		return $manager->searchItems( $search );
130
+		return $manager->searchItems($search);
131 131
 	}
132 132
 }
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Processor/Product/Standard.php 1 patch
Spacing   +32 added lines, -32 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
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
 		 * @see controller/common/product/import/csv/processor/price/listtypes
74 74
 		 * @see controller/common/product/import/csv/processor/text/listtypes
75 75
 		 */
76
-		$default = array( 'default', 'suggestion' );
76
+		$default = array('default', 'suggestion');
77 77
 		$key = 'controller/common/product/import/csv/processor/product/listtypes';
78
-		$this->listTypes = $context->getConfig()->get( $key, $default );
78
+		$this->listTypes = $context->getConfig()->get($key, $default);
79 79
 
80
-		$this->cache = $this->getCache( 'product' );
80
+		$this->cache = $this->getCache('product');
81 81
 	}
82 82
 
83 83
 
@@ -88,13 +88,13 @@  discard block
 block discarded – undo
88 88
 	 * @param array $data List of CSV fields with position as key and data as value
89 89
 	 * @return array List of data which hasn't been imported
90 90
 	 */
91
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
91
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
92 92
 	{
93 93
 		$context = $this->getContext();
94
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'product' );
95
-		$separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" );
94
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'product');
95
+		$separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n");
96 96
 
97
-		$this->cache->set( $product );
97
+		$this->cache->set($product);
98 98
 
99 99
 		$manager->begin();
100 100
 
@@ -102,39 +102,39 @@  discard block
 block discarded – undo
102 102
 		{
103 103
 			$types = [];
104 104
 
105
-			foreach( $this->getMappedChunk( $data, $this->getMapping() ) as $list )
105
+			foreach ($this->getMappedChunk($data, $this->getMapping()) as $list)
106 106
 			{
107
-				if( $this->checkEntry( $list ) === false ) {
107
+				if ($this->checkEntry($list) === false) {
108 108
 					continue;
109 109
 				}
110 110
 
111 111
 				$listMap = [];
112
-				$type = trim( isset( $list['product.lists.type'] ) ? $list['product.lists.type'] : 'default' );
112
+				$type = trim(isset($list['product.lists.type']) ? $list['product.lists.type'] : 'default');
113 113
 				$types[] = $type;
114 114
 
115
-				foreach( explode( $separator, trim( $list['product.code'] ) ) as $code )
115
+				foreach (explode($separator, trim($list['product.code'])) as $code)
116 116
 				{
117
-					$code = trim( $code );
117
+					$code = trim($code);
118 118
 
119
-					if( ( $prodid = $this->cache->get( $code ) ) === null )
119
+					if (($prodid = $this->cache->get($code)) === null)
120 120
 					{
121 121
 						$msg = 'No product for code "%1$s" available when importing product with code "%2$s"';
122
-						throw new \Aimeos\Controller\Jobs\Exception( sprintf( $msg, $code, $product->getCode() ) );
122
+						throw new \Aimeos\Controller\Jobs\Exception(sprintf($msg, $code, $product->getCode()));
123 123
 					}
124 124
 
125 125
 					$listMap[$prodid] = $list;
126 126
 				}
127 127
 
128
-				$manager->updateListItems( $product, $listMap, 'product', $type );
128
+				$manager->updateListItems($product, $listMap, 'product', $type);
129 129
 			}
130 130
 
131
-			$this->deleteListItems( $product->getId(), $types );
131
+			$this->deleteListItems($product->getId(), $types);
132 132
 
133
-			$data = $this->getObject()->process( $product, $data );
133
+			$data = $this->getObject()->process($product, $data);
134 134
 
135 135
 			$manager->commit();
136 136
 		}
137
-		catch( \Exception $e )
137
+		catch (\Exception $e)
138 138
 		{
139 139
 			$manager->rollback();
140 140
 			throw $e;
@@ -150,10 +150,10 @@  discard block
 block discarded – undo
150 150
 	 * @param array $list Associative list of key/value pairs from the mapping
151 151
 	 * @return boolean True if valid, false if not
152 152
 	 */
153
-	protected function checkEntry( array $list )
153
+	protected function checkEntry(array $list)
154 154
 	{
155
-		if( !isset( $list['product.code'] ) || trim( $list['product.code'] ) === '' || isset( $list['product.lists.type'] )
156
-			&& $this->listTypes !== null && !in_array( trim( $list['product.lists.type'] ), (array) $this->listTypes )
155
+		if (!isset($list['product.code']) || trim($list['product.code']) === '' || isset($list['product.lists.type'])
156
+			&& $this->listTypes !== null && !in_array(trim($list['product.lists.type']), (array) $this->listTypes)
157 157
 		) {
158 158
 			return false;
159 159
 		}
@@ -168,19 +168,19 @@  discard block
 block discarded – undo
168 168
 	 * @param string $prodId Unique product ID
169 169
 	 * @param array $types List of types that have been updated
170 170
 	 */
171
-	protected function deleteListItems( $prodId, array $types )
171
+	protected function deleteListItems($prodId, array $types)
172 172
 	{
173
-		$codes = array_diff( $this->listTypes, $types );
174
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists' );
173
+		$codes = array_diff($this->listTypes, $types);
174
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists');
175 175
 
176 176
 		$search = $manager->createSearch();
177 177
 		$expr = array(
178
-			$search->compare( '==', 'product.lists.parentid', $prodId ),
179
-			$search->compare( '==', 'product.lists.domain', 'product' ),
180
-			$search->compare( '==', 'product.lists.type.code', $codes ),
178
+			$search->compare('==', 'product.lists.parentid', $prodId),
179
+			$search->compare('==', 'product.lists.domain', 'product'),
180
+			$search->compare('==', 'product.lists.type.code', $codes),
181 181
 		);
182
-		$search->setConditions( $search->combine( '&&', $expr ) );
182
+		$search->setConditions($search->combine('&&', $expr));
183 183
 
184
-		$manager->deleteItems( array_keys( $manager->searchItems( $search ) ) );
184
+		$manager->deleteItems(array_keys($manager->searchItems($search)));
185 185
 	}
186 186
 }
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Processor/Property/Standard.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -40,54 +40,54 @@  discard block
 block discarded – undo
40 40
 	 * @param array $data List of CSV fields with position as key and data as value
41 41
 	 * @return array List of data which hasn't been imported
42 42
 	 */
43
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
43
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
44 44
 	{
45
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/property' );
45
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/property');
46 46
 		$manager->begin();
47 47
 
48 48
 		try
49 49
 		{
50 50
 			$propMap = [];
51
-			$map = $this->getMappedChunk( $data, $this->getMapping() );
52
-			$items = $this->getPropertyItems( $product->getId() );
51
+			$map = $this->getMappedChunk($data, $this->getMapping());
52
+			$items = $this->getPropertyItems($product->getId());
53 53
 
54
-			foreach( $items as $item ) {
55
-				$propMap[ $item->getValue() ][ $item->getType() ] = $item;
54
+			foreach ($items as $item) {
55
+				$propMap[$item->getValue()][$item->getType()] = $item;
56 56
 			}
57 57
 
58
-			foreach( $map as $list )
58
+			foreach ($map as $list)
59 59
 			{
60
-				$typecode = trim( $list['product.property.type'] );
61
-				$value = trim( $list['product.property.value'] );
60
+				$typecode = trim($list['product.property.type']);
61
+				$value = trim($list['product.property.value']);
62 62
 
63
-				if( $typecode == '' || $value == '' ) {
63
+				if ($typecode == '' || $value == '') {
64 64
 					continue;
65 65
 				}
66 66
 
67
-				$list['product.property.typeid'] = $this->getTypeId( 'product/property/type', 'product', $typecode );
67
+				$list['product.property.typeid'] = $this->getTypeId('product/property/type', 'product', $typecode);
68 68
 				$list['product.property.parentid'] = $product->getId();
69 69
 
70
-				if( isset( $propMap[$value][$typecode] ) )
70
+				if (isset($propMap[$value][$typecode]))
71 71
 				{
72 72
 					$item = $propMap[$value][$typecode];
73
-					unset( $items[ $item->getId() ] );
73
+					unset($items[$item->getId()]);
74 74
 				}
75 75
 				else
76 76
 				{
77 77
 					$item = $manager->createItem();
78 78
 				}
79 79
 
80
-				$item->fromArray( $list );
81
-				$manager->saveItem( $item, false );
80
+				$item->fromArray($list);
81
+				$manager->saveItem($item, false);
82 82
 			}
83 83
 
84
-			$manager->deleteItems( array_keys( $items ) );
84
+			$manager->deleteItems(array_keys($items));
85 85
 
86
-			$data = $this->getObject()->process( $product, $data );
86
+			$data = $this->getObject()->process($product, $data);
87 87
 
88 88
 			$manager->commit();
89 89
 		}
90
-		catch( \Exception $e )
90
+		catch (\Exception $e)
91 91
 		{
92 92
 			$manager->rollback();
93 93
 			throw $e;
@@ -103,13 +103,13 @@  discard block
 block discarded – undo
103 103
 	 * @param string $prodid Unique product ID
104 104
 	 * @return array Associative list of product property items
105 105
 	 */
106
-	protected function getPropertyItems( $prodid )
106
+	protected function getPropertyItems($prodid)
107 107
 	{
108
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/property' );
108
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/property');
109 109
 
110 110
 		$search = $manager->createSearch();
111
-		$search->setConditions( $search->compare( '==', 'product.property.parentid', $prodid ) );
111
+		$search->setConditions($search->compare('==', 'product.property.parentid', $prodid));
112 112
 
113
-		return $manager->searchItems( $search );
113
+		return $manager->searchItems($search);
114 114
 	}
115 115
 }
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Processor/Media/Standard.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -42,10 +42,10 @@  discard block
 block discarded – undo
42 42
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
43 43
 	 * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor
44 44
 	 */
45
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping,
46
-			\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null )
45
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
46
+			\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null)
47 47
 	{
48
-		parent::__construct( $context, $mapping, $object );
48
+		parent::__construct($context, $mapping, $object);
49 49
 
50 50
 		/** controller/common/product/import/csv/processor/media/listtypes
51 51
 		 * Names of the product list types for media that are updated or removed
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 		 * @see controller/common/product/import/csv/processor/price/listtypes
67 67
 		 * @see controller/common/product/import/csv/processor/text/listtypes
68 68
 		 */
69
-		$this->listTypes = $context->getConfig()->get( 'controller/common/product/import/csv/processor/media/listtypes' );
69
+		$this->listTypes = $context->getConfig()->get('controller/common/product/import/csv/processor/media/listtypes');
70 70
 	}
71 71
 
72 72
 
@@ -77,47 +77,47 @@  discard block
 block discarded – undo
77 77
 	 * @param array $data List of CSV fields with position as key and data as value
78 78
 	 * @return array List of data which hasn't been imported
79 79
 	 */
80
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
80
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
81 81
 	{
82 82
 		$context = $this->getContext();
83
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'media' );
84
-		$listManager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' );
85
-		$separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" );
83
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'media');
84
+		$listManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists');
85
+		$separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n");
86 86
 
87 87
 		$manager->begin();
88 88
 
89 89
 		try
90 90
 		{
91 91
 			$delete = $listMap = [];
92
-			$map = $this->getMappedChunk( $data, $this->getMapping() );
93
-			$listItems = $product->getListItems( 'media', $this->listTypes );
92
+			$map = $this->getMappedChunk($data, $this->getMapping());
93
+			$listItems = $product->getListItems('media', $this->listTypes);
94 94
 
95
-			foreach( $listItems as $listItem )
95
+			foreach ($listItems as $listItem)
96 96
 			{
97
-				if( ( $refItem = $listItem->getRefItem() ) !== null ) {
98
-					$listMap[ $refItem->getUrl() ][ $refItem->getType() ][ $listItem->getType() ] = $listItem;
97
+				if (($refItem = $listItem->getRefItem()) !== null) {
98
+					$listMap[$refItem->getUrl()][$refItem->getType()][$listItem->getType()] = $listItem;
99 99
 				}
100 100
 			}
101 101
 
102
-			foreach( $map as $pos => $list )
102
+			foreach ($map as $pos => $list)
103 103
 			{
104
-				if( $this->checkEntry( $list ) === false ) {
104
+				if ($this->checkEntry($list) === false) {
105 105
 					continue;
106 106
 				}
107 107
 
108
-				$urls = explode( $separator, trim( $list['media.url'] ) );
109
-				$type = trim( $this->getValue( $list, 'media.type', 'default' ) );
110
-				$typecode = trim( $this->getValue( $list, 'product.lists.type', 'default' ) );
108
+				$urls = explode($separator, trim($list['media.url']));
109
+				$type = trim($this->getValue($list, 'media.type', 'default'));
110
+				$typecode = trim($this->getValue($list, 'product.lists.type', 'default'));
111 111
 
112
-				foreach( $urls as $url )
112
+				foreach ($urls as $url)
113 113
 				{
114
-					$url = trim( $url );
114
+					$url = trim($url);
115 115
 
116
-					if( isset( $listMap[$url][$type][$typecode] ) )
116
+					if (isset($listMap[$url][$type][$typecode]))
117 117
 					{
118 118
 						$listItem = $listMap[$url][$type][$typecode];
119 119
 						$refItem = $listItem->getRefItem();
120
-						unset( $listItems[ $listItem->getId() ] );
120
+						unset($listItems[$listItem->getId()]);
121 121
 					}
122 122
 					else
123 123
 					{
@@ -125,35 +125,35 @@  discard block
 block discarded – undo
125 125
 						$refItem = $manager->createItem();
126 126
 					}
127 127
 
128
-					$list['media.typeid'] = $this->getTypeId( 'media/type', 'product', $type );
128
+					$list['media.typeid'] = $this->getTypeId('media/type', 'product', $type);
129 129
 					$list['media.domain'] = 'product';
130 130
 					$list['media.url'] = $url;
131 131
 
132
-					$refItem->fromArray( $this->addItemDefaults( $list ) );
133
-					$refItem = $manager->saveItem( $refItem );
132
+					$refItem->fromArray($this->addItemDefaults($list));
133
+					$refItem = $manager->saveItem($refItem);
134 134
 
135
-					$list['product.lists.typeid'] = $this->getTypeId( 'product/lists/type', 'media', $typecode );
135
+					$list['product.lists.typeid'] = $this->getTypeId('product/lists/type', 'media', $typecode);
136 136
 					$list['product.lists.parentid'] = $product->getId();
137 137
 					$list['product.lists.refid'] = $refItem->getId();
138 138
 					$list['product.lists.domain'] = 'media';
139 139
 
140
-					$listItem->fromArray( $this->addListItemDefaults( $list, $pos++ ) );
141
-					$listManager->saveItem( $listItem, false );
140
+					$listItem->fromArray($this->addListItemDefaults($list, $pos++));
141
+					$listManager->saveItem($listItem, false);
142 142
 				}
143 143
 			}
144 144
 
145
-			foreach( $listItems as $listItem ) {
145
+			foreach ($listItems as $listItem) {
146 146
 				$delete[] = $listItem->getRefId();
147 147
 			}
148 148
 
149
-			$manager->deleteItems( $delete );
150
-			$listManager->deleteItems( array_keys( $listItems ) );
149
+			$manager->deleteItems($delete);
150
+			$listManager->deleteItems(array_keys($listItems));
151 151
 
152
-			$data = $this->getObject()->process( $product, $data );
152
+			$data = $this->getObject()->process($product, $data);
153 153
 
154 154
 			$manager->commit();
155 155
 		}
156
-		catch( \Exception $e )
156
+		catch (\Exception $e)
157 157
 		{
158 158
 			$manager->rollback();
159 159
 			throw $e;
@@ -169,17 +169,17 @@  discard block
 block discarded – undo
169 169
 	 * @param array $list Associative list of domain item keys and their values, e.g. "media.status" => 1
170 170
 	 * @return array Given associative list enriched by default values if they were not already set
171 171
 	 */
172
-	protected function addItemDefaults( array $list )
172
+	protected function addItemDefaults(array $list)
173 173
 	{
174
-		if( !isset( $list['media.label'] ) ) {
174
+		if (!isset($list['media.label'])) {
175 175
 			$list['media.label'] = $list['media.url'];
176 176
 		}
177 177
 
178
-		if( !isset( $list['media.preview'] ) ) {
178
+		if (!isset($list['media.preview'])) {
179 179
 			$list['media.preview'] = $list['media.url'];
180 180
 		}
181 181
 
182
-		if( !isset( $list['media.status'] ) ) {
182
+		if (!isset($list['media.status'])) {
183 183
 			$list['media.status'] = 1;
184 184
 		}
185 185
 
@@ -193,10 +193,10 @@  discard block
 block discarded – undo
193 193
 	 * @param array $list Associative list of key/value pairs from the mapping
194 194
 	 * @return boolean True if valid, false if not
195 195
 	 */
196
-	protected function checkEntry( array $list )
196
+	protected function checkEntry(array $list)
197 197
 	{
198
-		if( !isset( $list['media.url'] ) || trim( $list['media.url'] ) === '' || isset( $list['product.lists.type'] )
199
-				&& $this->listTypes !== null && !in_array( trim( $list['product.lists.type'] ), (array) $this->listTypes )
198
+		if (!isset($list['media.url']) || trim($list['media.url']) === '' || isset($list['product.lists.type'])
199
+				&& $this->listTypes !== null && !in_array(trim($list['product.lists.type']), (array) $this->listTypes)
200 200
 		) {
201 201
 			return false;
202 202
 		}
Please login to merge, or discard this patch.
common/src/Controller/Common/Coupon/Import/Csv/Processor/Code/Standard.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -40,21 +40,21 @@
 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\Factory::createManager( $this->getContext(), 'coupon/code' );
46
-		$map = $this->getMappedChunk( $data, $this->getMapping() );
45
+		$manager = \Aimeos\MShop\Factory::createManager($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->fromArray( $list );
55
-			$manager->saveItem( $item );
54
+			$item->fromArray($list);
55
+			$manager->saveItem($item);
56 56
 		}
57 57
 
58
-		return $this->getObject()->process( $item, $data );
58
+		return $this->getObject()->process($item, $data);
59 59
 	}
60 60
 }
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Processor/Attribute/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\Product\Import\Csv\Processor\Iface $object Decorated processor
45 45
 	 */
46
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping,
47
-		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null )
46
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
47
+		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null)
48 48
 	{
49
-		parent::__construct( $context, $mapping, $object );
49
+		parent::__construct($context, $mapping, $object);
50 50
 
51 51
 		/** controller/common/product/import/csv/processor/attribute/listtypes
52 52
 		 * Names of the product list types for attributes that are updated or removed
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
 		 * @see controller/common/product/import/csv/processor/price/listtypes
68 68
 		 * @see controller/common/product/import/csv/processor/text/listtypes
69 69
 		 */
70
-		$this->listTypes = $context->getConfig()->get( 'controller/common/product/import/csv/processor/attribute/listtypes');
70
+		$this->listTypes = $context->getConfig()->get('controller/common/product/import/csv/processor/attribute/listtypes');
71 71
 
72
-		$this->cache = $this->getCache( 'attribute' );
72
+		$this->cache = $this->getCache('attribute');
73 73
 	}
74 74
 
75 75
 
@@ -80,73 +80,73 @@  discard block
 block discarded – undo
80 80
 	 * @param array $data List of CSV fields with position as key and data as value
81 81
 	 * @return array List of data which hasn't been imported
82 82
 	 */
83
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
83
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
84 84
 	{
85 85
 		$context = $this->getContext();
86
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'attribute' );
87
-		$listManager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' );
88
-		$separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" );
86
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'attribute');
87
+		$listManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists');
88
+		$separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n");
89 89
 
90 90
 		$manager->begin();
91 91
 
92 92
 		try
93 93
 		{
94 94
 			$listMap = [];
95
-			$map = $this->getMappedChunk( $data, $this->getMapping() );
96
-			$listItems = $product->getListItems( 'attribute', $this->listTypes );
95
+			$map = $this->getMappedChunk($data, $this->getMapping());
96
+			$listItems = $product->getListItems('attribute', $this->listTypes);
97 97
 
98
-			foreach( $listItems as $listItem )
98
+			foreach ($listItems as $listItem)
99 99
 			{
100
-				if( ( $refItem = $listItem->getRefItem() ) !== null ) {
101
-					$listMap[ $refItem->getCode() ][ $listItem->getType() ] = $listItem;
100
+				if (($refItem = $listItem->getRefItem()) !== null) {
101
+					$listMap[$refItem->getCode()][$listItem->getType()] = $listItem;
102 102
 				}
103 103
 			}
104 104
 
105
-			foreach( $map as $pos => $list )
105
+			foreach ($map as $pos => $list)
106 106
 			{
107
-				if( $this->checkEntry( $list ) === false ) {
107
+				if ($this->checkEntry($list) === false) {
108 108
 					continue;
109 109
 				}
110 110
 
111
-				$codes = explode( $separator, trim( $list['attribute.code'] ) );
111
+				$codes = explode($separator, trim($list['attribute.code']));
112 112
 
113
-				foreach( $codes as $code )
113
+				foreach ($codes as $code)
114 114
 				{
115
-					$code = trim( $code );
115
+					$code = trim($code);
116 116
 
117
-					$attrItem = $this->getAttributeItem( $code, trim( $list['attribute.type'] ) );
118
-					$attrItem->fromArray( $list );
119
-					$attrItem->setCode( $code );
120
-					$attrItem = $manager->saveItem( $attrItem );
117
+					$attrItem = $this->getAttributeItem($code, trim($list['attribute.type']));
118
+					$attrItem->fromArray($list);
119
+					$attrItem->setCode($code);
120
+					$attrItem = $manager->saveItem($attrItem);
121 121
 
122
-					$typecode = trim( $this->getValue( $list, 'product.lists.type', 'default' ) );
123
-					$list['product.lists.typeid'] = $this->getTypeId( 'product/lists/type', 'attribute', $typecode );
122
+					$typecode = trim($this->getValue($list, 'product.lists.type', 'default'));
123
+					$list['product.lists.typeid'] = $this->getTypeId('product/lists/type', 'attribute', $typecode);
124 124
 					$list['product.lists.refid'] = $attrItem->getId();
125 125
 					$list['product.lists.parentid'] = $product->getId();
126 126
 					$list['product.lists.domain'] = 'attribute';
127 127
 
128
-					if( isset( $listMap[$code][$typecode] ) )
128
+					if (isset($listMap[$code][$typecode]))
129 129
 					{
130 130
 						$listItem = $listMap[$code][$typecode];
131
-						unset( $listItems[ $listItem->getId() ] );
131
+						unset($listItems[$listItem->getId()]);
132 132
 					}
133 133
 					else
134 134
 					{
135 135
 						$listItem = $listManager->createItem();
136 136
 					}
137 137
 
138
-					$listItem->fromArray( $this->addListItemDefaults( $list, $pos ) );
139
-					$listManager->saveItem( $listItem, false );
138
+					$listItem->fromArray($this->addListItemDefaults($list, $pos));
139
+					$listManager->saveItem($listItem, false);
140 140
 				}
141 141
 			}
142 142
 
143
-			$listManager->deleteItems( array_keys( $listItems ) );
143
+			$listManager->deleteItems(array_keys($listItems));
144 144
 
145
-			$data = $this->getObject()->process( $product, $data );
145
+			$data = $this->getObject()->process($product, $data);
146 146
 
147 147
 			$manager->commit();
148 148
 		}
149
-		catch( \Exception $e )
149
+		catch (\Exception $e)
150 150
 		{
151 151
 			$manager->rollback();
152 152
 			throw $e;
@@ -162,11 +162,11 @@  discard block
 block discarded – undo
162 162
 	 * @param array $list Associative list of key/value pairs from the mapped data
163 163
 	 * @return boolean True if the entry is valid, false if not
164 164
 	 */
165
-	protected function checkEntry( array $list )
165
+	protected function checkEntry(array $list)
166 166
 	{
167
-		if( !isset( $list['attribute.code'] ) || trim( $list['attribute.code'] ) === ''
168
-			|| trim( $list['attribute.type'] ) === '' || isset( $list['product.lists.type'] )
169
-			&& $this->listTypes !== null && !in_array( trim( $list['product.lists.type'] ), (array) $this->listTypes )
167
+		if (!isset($list['attribute.code']) || trim($list['attribute.code']) === ''
168
+			|| trim($list['attribute.type']) === '' || isset($list['product.lists.type'])
169
+			&& $this->listTypes !== null && !in_array(trim($list['product.lists.type']), (array) $this->listTypes)
170 170
 		) {
171 171
 			return false;
172 172
 		}
@@ -182,22 +182,22 @@  discard block
 block discarded – undo
182 182
 	 * @param string $type Attribute type
183 183
 	 * @return \Aimeos\MShop\Attribute\Item\Iface Attribute item object
184 184
 	 */
185
-	protected function getAttributeItem( $code, $type )
185
+	protected function getAttributeItem($code, $type)
186 186
 	{
187
-		if( ( $item = $this->cache->get( $code, $type ) ) === null )
187
+		if (($item = $this->cache->get($code, $type)) === null)
188 188
 		{
189
-			$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' );
189
+			$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute');
190 190
 
191 191
 			$item = $manager->createItem();
192
-			$item->setTypeId( $this->getTypeId( 'attribute/type', 'product', $type ) );
193
-			$item->setDomain( 'product' );
194
-			$item->setLabel( $code );
195
-			$item->setCode( $code );
196
-			$item->setStatus( 1 );
192
+			$item->setTypeId($this->getTypeId('attribute/type', 'product', $type));
193
+			$item->setDomain('product');
194
+			$item->setLabel($code);
195
+			$item->setCode($code);
196
+			$item->setStatus(1);
197 197
 
198
-			$item = $manager->saveItem( $item );
198
+			$item = $manager->saveItem($item);
199 199
 
200
-			$this->cache->set( $item );
200
+			$this->cache->set($item);
201 201
 		}
202 202
 
203 203
 		return $item;
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Product/Import/Csv/Standard.php 1 patch
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	public function getName()
30 30
 	{
31
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Product import CSV' );
31
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Product import CSV');
32 32
 	}
33 33
 
34 34
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	public function getDescription()
41 41
 	{
42
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Imports new and updates existing products from CSV files' );
42
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Imports new and updates existing products from CSV files');
43 43
 	}
44 44
 
45 45
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		$context = $this->getContext();
55 55
 		$config = $context->getConfig();
56 56
 		$logger = $context->getLogger();
57
-		$domains = array( 'attribute', 'media', 'price', 'product', 'text' );
57
+		$domains = array('attribute', 'media', 'price', 'product', 'text');
58 58
 		$mappings = $this->getDefaultMapping();
59 59
 
60 60
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 		 * @see controller/common/product/import/csv/converter
75 75
 		 * @see controller/common/product/import/csv/max-size
76 76
 		 */
77
-		$domains = $config->get( 'controller/common/product/import/csv/domains', $domains );
77
+		$domains = $config->get('controller/common/product/import/csv/domains', $domains);
78 78
 
79 79
 		/** controller/jobs/product/import/csv/domains
80 80
 		 * List of item domain names that should be retrieved along with the product items
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 		 * @see controller/jobs/product/import/csv/backup
95 95
 		 * @see controller/common/product/import/csv/max-size
96 96
 		 */
97
-		$domains = $config->get( 'controller/jobs/product/import/csv/domains', $domains );
97
+		$domains = $config->get('controller/jobs/product/import/csv/domains', $domains);
98 98
 
99 99
 
100 100
 		/** controller/common/product/import/csv/mapping
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 		 * @see controller/common/product/import/csv/converter
123 123
 		 * @see controller/common/product/import/csv/max-size
124 124
 		 */
125
-		$mappings = $config->get( 'controller/common/product/import/csv/mapping', $mappings );
125
+		$mappings = $config->get('controller/common/product/import/csv/mapping', $mappings);
126 126
 
127 127
 		/** controller/jobs/product/import/csv/mapping
128 128
 		 * List of mappings between the position in the CSV file and item keys
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 		 * @see controller/jobs/product/import/csv/backup
143 143
 		 * @see controller/common/product/import/csv/max-size
144 144
 		 */
145
-		$mappings = $config->get( 'controller/jobs/product/import/csv/mapping', $mappings );
145
+		$mappings = $config->get('controller/jobs/product/import/csv/mapping', $mappings);
146 146
 
147 147
 
148 148
 		/** controller/common/product/import/csv/converter
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 		 * @see controller/common/product/import/csv/mapping
185 185
 		 * @see controller/common/product/import/csv/max-size
186 186
 		 */
187
-		$converters = $config->get( 'controller/common/product/import/csv/converter', [] );
187
+		$converters = $config->get('controller/common/product/import/csv/converter', []);
188 188
 
189 189
 		/** controller/jobs/product/import/csv/converter
190 190
 		 * List of converter names for the values at the position in the CSV file
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 		 * @see controller/jobs/product/import/csv/backup
205 205
 		 * @see controller/common/product/import/csv/max-size
206 206
 		 */
207
-		$converters = $config->get( 'controller/jobs/product/import/csv/converter', $converters );
207
+		$converters = $config->get('controller/jobs/product/import/csv/converter', $converters);
208 208
 
209 209
 
210 210
 		/** controller/common/product/import/csv/max-size
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 		 * @see controller/common/product/import/csv/mapping
225 225
 		 * @see controller/common/product/import/csv/converter
226 226
 		 */
227
-		$maxcnt = (int) $config->get( 'controller/common/product/import/csv/max-size', 1000 );
227
+		$maxcnt = (int) $config->get('controller/common/product/import/csv/max-size', 1000);
228 228
 
229 229
 
230 230
 		/** controller/jobs/product/import/csv/skip-lines
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 		 * @see controller/jobs/product/import/csv/backup
247 247
 		 * @see controller/common/product/import/csv/max-size
248 248
 		 */
249
-		$skiplines = (int) $config->get( 'controller/jobs/product/import/csv/skip-lines', 0 );
249
+		$skiplines = (int) $config->get('controller/jobs/product/import/csv/skip-lines', 0);
250 250
 
251 251
 
252 252
 		/** controller/jobs/product/import/csv/strict
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 		 * @see controller/jobs/product/import/csv/backup
271 271
 		 * @see controller/common/product/import/csv/max-size
272 272
 		 */
273
-		$strict = (bool) $config->get( 'controller/jobs/product/import/csv/strict', true );
273
+		$strict = (bool) $config->get('controller/jobs/product/import/csv/strict', true);
274 274
 
275 275
 
276 276
 		/** controller/jobs/product/import/csv/backup
@@ -303,74 +303,74 @@  discard block
 block discarded – undo
303 303
 		 * @see controller/jobs/product/import/csv/strict
304 304
 		 * @see controller/common/product/import/csv/max-size
305 305
 		 */
306
-		$backup = $config->get( 'controller/jobs/product/import/csv/backup' );
306
+		$backup = $config->get('controller/jobs/product/import/csv/backup');
307 307
 
308 308
 
309
-		if( !isset( $mappings['item'] ) || !is_array( $mappings['item'] ) )
309
+		if (!isset($mappings['item']) || !is_array($mappings['item']))
310 310
 		{
311
-			$msg = sprintf( 'Required mapping key "%1$s" is missing or contains no array', 'item' );
312
-			throw new \Aimeos\Controller\Jobs\Exception( $msg );
311
+			$msg = sprintf('Required mapping key "%1$s" is missing or contains no array', 'item');
312
+			throw new \Aimeos\Controller\Jobs\Exception($msg);
313 313
 		}
314 314
 
315 315
 		try
316 316
 		{
317 317
 			$procMappings = $mappings;
318
-			unset( $procMappings['item'] );
318
+			unset($procMappings['item']);
319 319
 
320
-			$codePos = $this->getCodePosition( $mappings['item'] );
321
-			$convlist = $this->getConverterList( $converters );
322
-			$processor = $this->getProcessors( $procMappings );
320
+			$codePos = $this->getCodePosition($mappings['item']);
321
+			$convlist = $this->getConverterList($converters);
322
+			$processor = $this->getProcessors($procMappings);
323 323
 			$container = $this->getContainer();
324 324
 			$path = $container->getName();
325 325
 
326
-			$msg = sprintf( 'Started product import from "%1$s" (%2$s)', $path, __CLASS__ );
327
-			$logger->log( $msg, \Aimeos\MW\Logger\Base::NOTICE );
326
+			$msg = sprintf('Started product import from "%1$s" (%2$s)', $path, __CLASS__);
327
+			$logger->log($msg, \Aimeos\MW\Logger\Base::NOTICE);
328 328
 
329
-			foreach( $container as $content )
329
+			foreach ($container as $content)
330 330
 			{
331 331
 				$name = $content->getName();
332 332
 
333
-				for( $i = 0; $i < $skiplines; $i++ ) {
333
+				for ($i = 0; $i < $skiplines; $i++) {
334 334
 					$content->next();
335 335
 				}
336 336
 
337
-				while( ( $data = $this->getData( $content, $maxcnt, $codePos ) ) !== [] )
337
+				while (($data = $this->getData($content, $maxcnt, $codePos)) !== [])
338 338
 				{
339
-					$data = $this->convertData( $convlist, $data );
340
-					$products = $this->getProducts( array_keys( $data ), $domains );
341
-					$errcnt = $this->import( $products, $data, $mappings['item'], $processor, $strict );
342
-					$chunkcnt = count( $data );
339
+					$data = $this->convertData($convlist, $data);
340
+					$products = $this->getProducts(array_keys($data), $domains);
341
+					$errcnt = $this->import($products, $data, $mappings['item'], $processor, $strict);
342
+					$chunkcnt = count($data);
343 343
 
344 344
 					$msg = 'Imported product lines from "%1$s": %2$d/%3$d (%4$s)';
345
-					$logger->log( sprintf( $msg, $name, $chunkcnt - $errcnt, $chunkcnt, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE );
345
+					$logger->log(sprintf($msg, $name, $chunkcnt - $errcnt, $chunkcnt, __CLASS__), \Aimeos\MW\Logger\Base::NOTICE);
346 346
 
347 347
 					$errors += $errcnt;
348 348
 					$total += $chunkcnt;
349
-					unset( $products, $data );
349
+					unset($products, $data);
350 350
 				}
351 351
 			}
352 352
 
353 353
 			$container->close();
354 354
 		}
355
-		catch( \Exception $e )
355
+		catch (\Exception $e)
356 356
 		{
357
-			$logger->log( 'Product import error: ' . $e->getMessage() );
358
-			$logger->log( $e->getTraceAsString() );
357
+			$logger->log('Product import error: ' . $e->getMessage());
358
+			$logger->log($e->getTraceAsString());
359 359
 
360
-			throw new \Aimeos\Controller\Jobs\Exception( $e->getMessage() );
360
+			throw new \Aimeos\Controller\Jobs\Exception($e->getMessage());
361 361
 		}
362 362
 
363 363
 		$msg = 'Finished product import from "%1$s": %2$d successful, %3$s errors, %4$s total (%5$s)';
364
-		$logger->log( sprintf( $msg, $path, $total - $errors, $errors, $total, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE );
364
+		$logger->log(sprintf($msg, $path, $total - $errors, $errors, $total, __CLASS__), \Aimeos\MW\Logger\Base::NOTICE);
365 365
 
366
-		if( $errors > 0 )
366
+		if ($errors > 0)
367 367
 		{
368
-			$msg = sprintf( 'Invalid product lines in "%1$s": %2$d/%3$d', $path, $errors, $total );
369
-			throw new \Aimeos\Controller\Jobs\Exception( $msg );
368
+			$msg = sprintf('Invalid product lines in "%1$s": %2$d/%3$d', $path, $errors, $total);
369
+			throw new \Aimeos\Controller\Jobs\Exception($msg);
370 370
 		}
371 371
 
372
-		if( !empty( $backup ) && @rename( $path, strftime( $backup ) ) === false ) {
373
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Unable to move imported file' ) );
372
+		if (!empty($backup) && @rename($path, strftime($backup)) === false) {
373
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('Unable to move imported file'));
374 374
 		}
375 375
 	}
376 376
 
@@ -382,16 +382,16 @@  discard block
 block discarded – undo
382 382
 	 * @return integer Position of the "product.code" column
383 383
 	 * @throws \Aimeos\Controller\Jobs\Exception If no mapping for "product.code" is found
384 384
 	 */
385
-	protected function getCodePosition( array $mapping )
385
+	protected function getCodePosition(array $mapping)
386 386
 	{
387
-		foreach( $mapping as $pos => $key )
387
+		foreach ($mapping as $pos => $key)
388 388
 		{
389
-			if( $key === 'product.code' ) {
389
+			if ($key === 'product.code') {
390 390
 				return $pos;
391 391
 			}
392 392
 		}
393 393
 
394
-		throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'No "product.code" column in CSV mapping found' ) );
394
+		throw new \Aimeos\Controller\Jobs\Exception(sprintf('No "product.code" column in CSV mapping found'));
395 395
 	}
396 396
 
397 397
 
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 		 * @see controller/jobs/product/import/csv/container/content
427 427
 		 * @see controller/jobs/product/import/csv/container/options
428 428
 		 */
429
-		$location = $config->get( 'controller/jobs/product/import/csv/location' );
429
+		$location = $config->get('controller/jobs/product/import/csv/location');
430 430
 
431 431
 		/** controller/jobs/product/import/csv/container/type
432 432
 		 * Nave of the container type to read the data from
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
 		 * @see controller/jobs/product/import/csv/container/content
450 450
 		 * @see controller/jobs/product/import/csv/container/options
451 451
 		 */
452
-		$container = $config->get( 'controller/jobs/product/import/csv/container/type', 'Directory' );
452
+		$container = $config->get('controller/jobs/product/import/csv/container/type', 'Directory');
453 453
 
454 454
 		/** controller/jobs/product/import/csv/container/content
455 455
 		 * Name of the content type inside the container to read the data from
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 		 * @see controller/jobs/product/import/csv/container/type
471 471
 		 * @see controller/jobs/product/import/csv/container/options
472 472
 		 */
473
-		$content = $config->get( 'controller/jobs/product/import/csv/container/content', 'CSV' );
473
+		$content = $config->get('controller/jobs/product/import/csv/container/content', 'CSV');
474 474
 
475 475
 		/** controller/jobs/product/import/csv/container/options
476 476
 		 * List of file container options for the product import files
@@ -488,15 +488,15 @@  discard block
 block discarded – undo
488 488
 		 * @see controller/jobs/product/import/csv/container/content
489 489
 		 * @see controller/jobs/product/import/csv/container/type
490 490
 		 */
491
-		$options = $config->get( 'controller/jobs/product/import/csv/container/options', [] );
491
+		$options = $config->get('controller/jobs/product/import/csv/container/options', []);
492 492
 
493
-		if( $location === null )
493
+		if ($location === null)
494 494
 		{
495
-			$msg = sprintf( 'Required configuration for "%1$s" is missing', 'controller/jobs/product/import/csv/location' );
496
-			throw new \Aimeos\Controller\Jobs\Exception( $msg );
495
+			$msg = sprintf('Required configuration for "%1$s" is missing', 'controller/jobs/product/import/csv/location');
496
+			throw new \Aimeos\Controller\Jobs\Exception($msg);
497 497
 		}
498 498
 
499
-		return \Aimeos\MW\Container\Factory::getContainer( $location, $container, $content, $options );
499
+		return \Aimeos\MW\Container\Factory::getContainer($location, $container, $content, $options);
500 500
 	}
501 501
 
502 502
 
@@ -511,56 +511,56 @@  discard block
 block discarded – undo
511 511
 	 * @return integer Number of products that couldn't be imported
512 512
 	 * @throws \Aimeos\Controller\Jobs\Exception
513 513
 	 */
514
-	protected function import( array $products, array $data, array $mapping,
515
-		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor, $strict )
514
+	protected function import(array $products, array $data, array $mapping,
515
+		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor, $strict)
516 516
 	{
517 517
 		$errors = 0;
518 518
 		$context = $this->getContext();
519
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'product' );
519
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'product');
520 520
 
521
-		foreach( $data as $code => $list )
521
+		foreach ($data as $code => $list)
522 522
 		{
523 523
 			$manager->begin();
524 524
 
525 525
 			try
526 526
 			{
527
-				$code = trim( $code );
527
+				$code = trim($code);
528 528
 
529
-				if( isset( $products[$code] ) ) {
529
+				if (isset($products[$code])) {
530 530
 					$product = $products[$code];
531 531
 				} else {
532 532
 					$product = $manager->createItem();
533 533
 				}
534 534
 
535
-				$map = $this->getMappedChunk( $list, $mapping );
535
+				$map = $this->getMappedChunk($list, $mapping);
536 536
 
537
-				if( isset( $map[0] ) )
537
+				if (isset($map[0]))
538 538
 				{
539 539
 					$map = $map[0]; // there can only be one chunk for the base product data
540 540
 
541
-					$typecode = trim( isset( $map['product.type'] ) ? $map['product.type'] : 'default' );
542
-					$map['product.typeid'] = $this->getTypeId( 'product/type', 'product', $typecode );
541
+					$typecode = trim(isset($map['product.type']) ? $map['product.type'] : 'default');
542
+					$map['product.typeid'] = $this->getTypeId('product/type', 'product', $typecode);
543 543
 
544
-					$product->fromArray( $this->addItemDefaults( $map ) );
545
-					$product = $manager->saveItem( $product );
544
+					$product->fromArray($this->addItemDefaults($map));
545
+					$product = $manager->saveItem($product);
546 546
 
547
-					$list = $processor->process( $product, $list );
547
+					$list = $processor->process($product, $list);
548 548
 				}
549 549
 
550 550
 				$manager->commit();
551 551
 			}
552
-			catch( \Exception $e )
552
+			catch (\Exception $e)
553 553
 			{
554 554
 				$manager->rollback();
555 555
 
556
-				$msg = sprintf( 'Unable to import product with code "%1$s": %2$s', $code, $e->getMessage() );
557
-				$context->getLogger()->log( $msg );
556
+				$msg = sprintf('Unable to import product with code "%1$s": %2$s', $code, $e->getMessage());
557
+				$context->getLogger()->log($msg);
558 558
 
559 559
 				$errors++;
560 560
 			}
561 561
 
562
-			if( $strict && !empty( $list ) ) {
563
-				$context->getLogger()->log( 'Not imported: ' . print_r( $list, true ) );
562
+			if ($strict && !empty($list)) {
563
+				$context->getLogger()->log('Not imported: ' . print_r($list, true));
564 564
 			}
565 565
 		}
566 566
 
@@ -574,9 +574,9 @@  discard block
 block discarded – undo
574 574
 	 * @param array $list Associative list of domain item keys and their values, e.g. "product.status" => 1
575 575
 	 * @return array Given associative list enriched by default values if they were not already set
576 576
 	 */
577
-	protected function addItemDefaults( array $list )
577
+	protected function addItemDefaults(array $list)
578 578
 	{
579
-		if( !isset( $list['product.status'] ) ) {
579
+		if (!isset($list['product.status'])) {
580 580
 			$list['product.status'] = 1;
581 581
 		}
582 582
 
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Product/Export/Sitemap/Standard.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	public function getName()
30 30
 	{
31
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Product site map' );
31
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Product site map');
32 32
 	}
33 33
 
34 34
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	public function getDescription()
41 41
 	{
42
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Creates a product site map for search engines' );
42
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Creates a product site map for search engines');
43 43
 	}
44 44
 
45 45
 
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
 	{
53 53
 		$container = $this->createContainer();
54 54
 
55
-		$files = $this->export( $container );
56
-		$this->createSitemapIndex( $container, $files );
55
+		$files = $this->export($container);
56
+		$this->createSitemapIndex($container, $files);
57 57
 
58 58
 		$container->close();
59 59
 	}
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 * @param \Aimeos\MW\Container\Content\Iface $content File content object
66 66
 	 * @param \Aimeos\MShop\Product\Item\Iface[] $items List of product items
67 67
 	 */
68
-	protected function addItems( \Aimeos\MW\Container\Content\Iface $content, array $items )
68
+	protected function addItems(\Aimeos\MW\Container\Content\Iface $content, array $items)
69 69
 	{
70 70
 		$config = $this->getContext()->getConfig();
71 71
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 		 * @see controller/jobs/product/export/sitemap/max-items
97 97
 		 * @see controller/jobs/product/export/sitemap/max-query
98 98
 		 */
99
-		$changefreq = $config->get( 'controller/jobs/product/export/sitemap/changefreq', 'daily' );
99
+		$changefreq = $config->get('controller/jobs/product/export/sitemap/changefreq', 'daily');
100 100
 
101 101
 		/** controller/jobs/product/export/sitemap/standard/template-items
102 102
 		 * Relative path to the XML items template of the product site map job controller.
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 		$view->siteItems = $items;
130 130
 		$view->siteFreq = $changefreq;
131 131
 
132
-		$content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) );
132
+		$content->add($view->render($context->getConfig()->get($tplconf, $default)));
133 133
 	}
134 134
 
135 135
 
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 		 * @see controller/jobs/product/export/sitemap/max-query
176 176
 		 * @see controller/jobs/product/export/sitemap/changefreq
177 177
 		 */
178
-		$location = $config->get( 'controller/jobs/product/export/sitemap/location' );
178
+		$location = $config->get('controller/jobs/product/export/sitemap/location');
179 179
 
180 180
 		/** controller/jobs/product/export/sitemap/container/options
181 181
 		 * List of file container options for the site map files
@@ -196,16 +196,16 @@  discard block
 block discarded – undo
196 196
 		 * @see controller/jobs/product/export/sitemap/max-query
197 197
 		 * @see controller/jobs/product/export/sitemap/changefreq
198 198
 		 */
199
-		$default = array( 'gzip-mode' => 'wb' );
200
-		$options = $config->get( 'controller/jobs/product/export/sitemap/container/options', $default );
199
+		$default = array('gzip-mode' => 'wb');
200
+		$options = $config->get('controller/jobs/product/export/sitemap/container/options', $default);
201 201
 
202
-		if( $location === null )
202
+		if ($location === null)
203 203
 		{
204
-			$msg = sprintf( 'Required configuration for "%1$s" is missing', 'controller/jobs/product/export/sitemap/location' );
205
-			throw new \Aimeos\Controller\Jobs\Exception( $msg );
204
+			$msg = sprintf('Required configuration for "%1$s" is missing', 'controller/jobs/product/export/sitemap/location');
205
+			throw new \Aimeos\Controller\Jobs\Exception($msg);
206 206
 		}
207 207
 
208
-		return \Aimeos\MW\Container\Factory::getContainer( $location, 'Directory', 'Gzip', $options );
208
+		return \Aimeos\MW\Container\Factory::getContainer($location, 'Directory', 'Gzip', $options);
209 209
 	}
210 210
 
211 211
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	 * @param integer $filenum New file number
217 217
 	 * @return \Aimeos\MW\Container\Content\Iface New content object
218 218
 	 */
219
-	protected function createContent( \Aimeos\MW\Container\Iface $container, $filenum )
219
+	protected function createContent(\Aimeos\MW\Container\Iface $container, $filenum)
220 220
 	{
221 221
 		/** controller/jobs/product/export/sitemap/standard/template-header
222 222
 		 * Relative path to the XML site map header template of the product site map job controller.
@@ -246,9 +246,9 @@  discard block
 block discarded – undo
246 246
 		$context = $this->getContext();
247 247
 		$view = $context->getView();
248 248
 
249
-		$content = $container->create( $this->getFilename( $filenum ) );
250
-		$content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) );
251
-		$container->add( $content );
249
+		$content = $container->create($this->getFilename($filenum));
250
+		$content->add($view->render($context->getConfig()->get($tplconf, $default)));
251
+		$container->add($content);
252 252
 
253 253
 		return $content;
254 254
 	}
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 	 *
260 260
 	 * @param \Aimeos\MW\Container\Content\Iface $content
261 261
 	 */
262
-	protected function closeContent( \Aimeos\MW\Container\Content\Iface $content )
262
+	protected function closeContent(\Aimeos\MW\Container\Content\Iface $content)
263 263
 	{
264 264
 		/** controller/jobs/product/export/sitemap/standard/template-footer
265 265
 		 * Relative path to the XML site map footer template of the product site map job controller.
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 		$context = $this->getContext();
290 290
 		$view = $context->getView();
291 291
 
292
-		$content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) );
292
+		$content->add($view->render($context->getConfig()->get($tplconf, $default)));
293 293
 	}
294 294
 
295 295
 
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	 * @param \Aimeos\MW\Container\Iface $container File container object
300 300
 	 * @param array $files List of generated site map file names
301 301
 	 */
302
-	protected function createSitemapIndex( \Aimeos\MW\Container\Iface $container, array $files )
302
+	protected function createSitemapIndex(\Aimeos\MW\Container\Iface $container, array $files)
303 303
 	{
304 304
 		/** controller/jobs/product/export/sitemap/standard/template-index
305 305
 		 * Relative path to the XML site map index template of the product site map job controller.
@@ -331,9 +331,9 @@  discard block
 block discarded – undo
331 331
 
332 332
 		$view->siteFiles = $files;
333 333
 
334
-		$content = $container->create( 'aimeos-sitemap-index.xml' );
335
-		$content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) );
336
-		$container->add( $content );
334
+		$content = $container->create('aimeos-sitemap-index.xml');
335
+		$content->add($view->render($context->getConfig()->get($tplconf, $default)));
336
+		$container->add($content);
337 337
 	}
338 338
 
339 339
 
@@ -344,11 +344,11 @@  discard block
 block discarded – undo
344 344
 	 * @param mixed $default Default value if name is unknown
345 345
 	 * @return mixed Configuration value
346 346
 	 */
347
-	protected function getConfig( $name, $default = null )
347
+	protected function getConfig($name, $default = null)
348 348
 	{
349 349
 		$config = $this->getContext()->getConfig();
350 350
 
351
-		switch( $name )
351
+		switch ($name)
352 352
 		{
353 353
 			case 'domain':
354 354
 				return [];
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 				 * @see controller/jobs/product/export/sitemap/max-query
376 376
 				 * @see controller/jobs/product/export/sitemap/changefreq
377 377
 				 */
378
-				return $config->get( 'controller/jobs/product/export/sitemap/max-items', 50000 );
378
+				return $config->get('controller/jobs/product/export/sitemap/max-items', 50000);
379 379
 
380 380
 			case 'max-query':
381 381
 				/** controller/jobs/product/export/sitemap/max-query
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 				 * @see controller/jobs/product/export/sitemap/max-items
396 396
 				 * @see controller/jobs/product/export/sitemap/changefreq
397 397
 				 */
398
-				return $config->get( 'controller/jobs/product/export/sitemap/max-query', 1000 );
398
+				return $config->get('controller/jobs/product/export/sitemap/max-query', 1000);
399 399
 		}
400 400
 
401 401
 		return $default;
@@ -408,8 +408,8 @@  discard block
 block discarded – undo
408 408
 	 * @param integer $number Current file number
409 409
 	 * @return string New file name
410 410
 	 */
411
-	protected function getFilename( $number )
411
+	protected function getFilename($number)
412 412
 	{
413
-		return sprintf( 'aimeos-sitemap-%d.xml', $number );
413
+		return sprintf('aimeos-sitemap-%d.xml', $number);
414 414
 	}
415 415
 }
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Order/Export/Csv/Standard.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	public function getName()
30 30
 	{
31
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Order export CSV' );
31
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Order export CSV');
32 32
 	}
33 33
 
34 34
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	public function getDescription()
41 41
 	{
42
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Exports orders to CSV file' );
42
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Exports orders to CSV file');
43 43
 	}
44 44
 
45 45
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 		 * @category Developer
74 74
 		 * @see controller/common/order/export/csv/max-size
75 75
 		 */
76
-		$mappings = $config->get( 'controller/common/order/export/csv/mapping', $mappings );
76
+		$mappings = $config->get('controller/common/order/export/csv/mapping', $mappings);
77 77
 
78 78
 		/** controller/jobs/order/export/csv/mapping
79 79
 		 * List of mappings between the position in the CSV file and item keys
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 		 * @category Developer
89 89
 		 * @see controller/common/order/export/csv/max-size
90 90
 		 */
91
-		$mappings = $config->get( 'controller/jobs/order/export/csv/mapping', $mappings );
91
+		$mappings = $config->get('controller/jobs/order/export/csv/mapping', $mappings);
92 92
 
93 93
 
94 94
 		/** controller/common/order/export/csv/max-size
@@ -106,29 +106,29 @@  discard block
 block discarded – undo
106 106
 		 * @category Developer
107 107
 		 * @see controller/common/order/export/csv/mapping
108 108
 		 */
109
-		$maxcnt = (int) $config->get( 'controller/common/order/export/csv/max-size', 1000 );
109
+		$maxcnt = (int) $config->get('controller/common/order/export/csv/max-size', 1000);
110 110
 
111 111
 
112
-		$processors = $this->getProcessors( $mappings );
113
-		$mq = $context->getMessageQueueManager()->get( 'mq-admin' )->getQueue( 'order-export' );
112
+		$processors = $this->getProcessors($mappings);
113
+		$mq = $context->getMessageQueueManager()->get('mq-admin')->getQueue('order-export');
114 114
 
115
-		while( ( $msg = $mq->get() ) !== null )
115
+		while (($msg = $mq->get()) !== null)
116 116
 		{
117 117
 			try
118 118
 			{
119
-				if( ( $data = json_decode( $msg->getBody(), true ) ) === null ) {
120
-					throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid message: %1$s', $msg->getBody() ) );
119
+				if (($data = json_decode($msg->getBody(), true)) === null) {
120
+					throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid message: %1$s', $msg->getBody()));
121 121
 				}
122 122
 
123
-				$this->export( $processors, $data, $maxcnt );
123
+				$this->export($processors, $data, $maxcnt);
124 124
 			}
125
-			catch( \Exception $e )
125
+			catch (\Exception $e)
126 126
 			{
127
-				$logger->log( 'Order export error: ' . $e->getMessage() );
128
-				$logger->log( $e->getTraceAsString() );
127
+				$logger->log('Order export error: ' . $e->getMessage());
128
+				$logger->log($e->getTraceAsString());
129 129
 			}
130 130
 
131
-			$mq->del( $msg );
131
+			$mq->del($msg);
132 132
 		}
133 133
 	}
134 134
 
@@ -139,15 +139,15 @@  discard block
 block discarded – undo
139 139
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context item
140 140
 	 * @param string $path Absolute path to the exported file
141 141
 	 */
142
-	protected function addJob( $context, $path )
142
+	protected function addJob($context, $path)
143 143
 	{
144
-		$manager = \Aimeos\MAdmin\Factory::createManager( $context, 'job' );
144
+		$manager = \Aimeos\MAdmin\Factory::createManager($context, 'job');
145 145
 
146 146
 		$item = $manager->createItem();
147
-		$item->setResult( ['file' => $path] );
148
-		$item->setLabel( $path );
147
+		$item->setResult(['file' => $path]);
148
+		$item->setLabel($path);
149 149
 
150
-		$manager->saveItem( $item, false );
150
+		$manager->saveItem($item, false);
151 151
 	}
152 152
 
153 153
 
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 		 * @see controller/jobs/order/export/csv/container/content
178 178
 		 * @see controller/jobs/order/export/csv/container/options
179 179
 		 */
180
-		$location = $config->get( 'controller/jobs/order/export/csv/location', sys_get_temp_dir() );
180
+		$location = $config->get('controller/jobs/order/export/csv/location', sys_get_temp_dir());
181 181
 
182 182
 		/** controller/jobs/order/export/csv/container/type
183 183
 		 * Nave of the container type to read the data from
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 		 * @see controller/jobs/order/export/csv/container/content
201 201
 		 * @see controller/jobs/order/export/csv/container/options
202 202
 		 */
203
-		$container = $config->get( 'controller/jobs/order/export/csv/container/type', 'Directory' );
203
+		$container = $config->get('controller/jobs/order/export/csv/container/type', 'Directory');
204 204
 
205 205
 		/** controller/jobs/order/export/csv/container/content
206 206
 		 * Name of the content type inside the container to read the data from
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 		 * @see controller/jobs/order/export/csv/container/type
222 222
 		 * @see controller/jobs/order/export/csv/container/options
223 223
 		 */
224
-		$content = $config->get( 'controller/jobs/order/export/csv/container/content', 'CSV' );
224
+		$content = $config->get('controller/jobs/order/export/csv/container/content', 'CSV');
225 225
 
226 226
 		/** controller/jobs/order/export/csv/container/options
227 227
 		 * List of file container options for the order export files
@@ -239,9 +239,9 @@  discard block
 block discarded – undo
239 239
 		 * @see controller/jobs/order/export/csv/container/content
240 240
 		 * @see controller/jobs/order/export/csv/container/type
241 241
 		 */
242
-		$options = $config->get( 'controller/jobs/order/export/csv/container/options', [] );
242
+		$options = $config->get('controller/jobs/order/export/csv/container/options', []);
243 243
 
244
-		return \Aimeos\MW\Container\Factory::getContainer( $location, $container, $content, $options );
244
+		return \Aimeos\MW\Container\Factory::getContainer($location, $container, $content, $options);
245 245
 	}
246 246
 
247 247
 
@@ -253,56 +253,56 @@  discard block
 block discarded – undo
253 253
 	 * @param integer $maxcnt Maximum number of retrieved orders at once
254 254
 	 * @return string Path of the file containing the exported data
255 255
 	 */
256
-	protected function export( array $processors, $msg, $maxcnt )
256
+	protected function export(array $processors, $msg, $maxcnt)
257 257
 	{
258
-		$lcontext = $this->getLocaleContext( $msg );
258
+		$lcontext = $this->getLocaleContext($msg);
259 259
 		$baseRef = ['order/base/address', 'order/base/coupon', 'order/base/product', 'order/base/service'];
260 260
 
261
-		$manager = \Aimeos\MShop\Factory::createManager( $lcontext, 'order' );
262
-		$baseManager = \Aimeos\MShop\Factory::createManager( $lcontext, 'order/base' );
261
+		$manager = \Aimeos\MShop\Factory::createManager($lcontext, 'order');
262
+		$baseManager = \Aimeos\MShop\Factory::createManager($lcontext, 'order/base');
263 263
 
264 264
 		$container = $this->getContainer();
265
-		$content = $container->create( 'order-export_' . date( 'Y-m-d_H-i-s' ) );
266
-		$search = $this->initCriteria( $manager->createSearch()->setSlice( 0, 0x7fffffff ), $msg );
265
+		$content = $container->create('order-export_' . date('Y-m-d_H-i-s'));
266
+		$search = $this->initCriteria($manager->createSearch()->setSlice(0, 0x7fffffff), $msg);
267 267
 		$start = 0;
268 268
 
269 269
 		do
270 270
 		{
271 271
 			$baseIds = [];
272
-			$search->setSlice( $start, $maxcnt );
273
-			$items = $manager->searchItems( $search );
272
+			$search->setSlice($start, $maxcnt);
273
+			$items = $manager->searchItems($search);
274 274
 
275
-			foreach( $items as $item ) {
275
+			foreach ($items as $item) {
276 276
 				$baseIds[] = $item->getBaseId();
277 277
 			}
278 278
 
279 279
 			$baseSearch = $baseManager->createSearch();
280
-			$baseSearch->setConditions( $baseSearch->compare( '==', 'order.base.id', $baseIds ) );
281
-			$baseSearch->setSlice( 0, count( $baseIds ) );
280
+			$baseSearch->setConditions($baseSearch->compare('==', 'order.base.id', $baseIds));
281
+			$baseSearch->setSlice(0, count($baseIds));
282 282
 
283
-			$baseItems = $baseManager->searchItems( $baseSearch, $baseRef );
283
+			$baseItems = $baseManager->searchItems($baseSearch, $baseRef);
284 284
 
285
-			foreach( $items as $id => $item )
285
+			foreach ($items as $id => $item)
286 286
 			{
287
-				foreach( $processors as $type => $processor )
287
+				foreach ($processors as $type => $processor)
288 288
 				{
289
-					foreach( $processor->process( $item, $baseItems[$item->getBaseId()] ) as $line ) {
290
-						$content->add( [0 => $type, 1 => $id] + $line );
289
+					foreach ($processor->process($item, $baseItems[$item->getBaseId()]) as $line) {
290
+						$content->add([0 => $type, 1 => $id] + $line);
291 291
 					}
292 292
 				}
293 293
 			}
294 294
 
295
-			$count = count( $items );
295
+			$count = count($items);
296 296
 			$start += $count;
297 297
 		}
298
-		while( $count === $search->getSliceSize() );
298
+		while ($count === $search->getSliceSize());
299 299
 
300 300
 		$path = $content->getResource();
301
-		$container->add( $content );
301
+		$container->add($content);
302 302
 		$container->close();
303 303
 
304
-		$path = $this->moveFile( $lcontext, $path );
305
-		$this->addJob( $lcontext, $path );
304
+		$path = $this->moveFile($lcontext, $path);
305
+		$this->addJob($lcontext, $path);
306 306
 	}
307 307
 
308 308
 
@@ -312,15 +312,15 @@  discard block
 block discarded – undo
312 312
 	 * @param array $msg Message data including a "sitecode" value
313 313
 	 * @return \Aimeos\MShop\Context\Item\Iface New context item with updated locale
314 314
 	 */
315
-	protected function getLocaleContext( array $msg )
315
+	protected function getLocaleContext(array $msg)
316 316
 	{
317 317
 		$lcontext = clone $this->getContext();
318
-		$manager = \Aimeos\MShop\Factory::createManager( $lcontext, 'locale' );
318
+		$manager = \Aimeos\MShop\Factory::createManager($lcontext, 'locale');
319 319
 
320
-		$sitecode = ( isset( $msg['sitecode'] ) ? $msg['sitecode'] : 'default' );
321
-		$localeItem = $manager->bootstrap( $sitecode, '', '', false, \Aimeos\MShop\Locale\Manager\Base::SITE_ONE );
320
+		$sitecode = (isset($msg['sitecode']) ? $msg['sitecode'] : 'default');
321
+		$localeItem = $manager->bootstrap($sitecode, '', '', false, \Aimeos\MShop\Locale\Manager\Base::SITE_ONE);
322 322
 
323
-		return $lcontext->setLocale( $localeItem );
323
+		return $lcontext->setLocale($localeItem);
324 324
 	}
325 325
 
326 326
 
@@ -331,14 +331,14 @@  discard block
 block discarded – undo
331 331
 	 * @param array $msg Message data
332 332
 	 * @return \Aimeos\MW\Criteria\Iface Initialized criteria object
333 333
 	 */
334
-	protected function initCriteria( \Aimeos\MW\Criteria\Iface $criteria, array $msg )
334
+	protected function initCriteria(\Aimeos\MW\Criteria\Iface $criteria, array $msg)
335 335
 	{
336
-		if( isset( $msg['filter'] ) ) {
337
-			$criteria->setConditions( $criteria->toConditions( $msg['filter'] ) );
336
+		if (isset($msg['filter'])) {
337
+			$criteria->setConditions($criteria->toConditions($msg['filter']));
338 338
 		}
339 339
 
340
-		if( isset( $msg['sort'] ) ) {
341
-			$criteria->setSortations( $criteria->toSortations( $msg['sort'] ) );
340
+		if (isset($msg['sort'])) {
341
+			$criteria->setSortations($criteria->toSortations($msg['sort']));
342 342
 		}
343 343
 
344 344
 		return $criteria;
@@ -352,12 +352,12 @@  discard block
 block discarded – undo
352 352
 	 * @param string $path Absolute path to the exported file
353 353
 	 * @return string Relative path of the file in the storage
354 354
 	 */
355
-	protected function moveFile( $context, $path )
355
+	protected function moveFile($context, $path)
356 356
 	{
357
-		$filename = basename( $path );
358
-		$context->getFileSystemManager()->get( 'fs-admin' )->writef( $filename, $path );
357
+		$filename = basename($path);
358
+		$context->getFileSystemManager()->get('fs-admin')->writef($filename, $path);
359 359
 
360
-		unlink( $path );
360
+		unlink($path);
361 361
 		return $filename;
362 362
 	}
363 363
 }
Please login to merge, or discard this patch.