Completed
Push — master ( 7a3ba1...08fedb )
by Aimeos
02:02
created
src/Controller/Common/Product/Import/Csv/Processor/Price/Standard.php 2 patches
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -42,10 +42,10 @@  discard block
 block discarded – undo
42 42
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
43 43
 	 * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor
44 44
 	 */
45
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping,
46
-			\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null )
45
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
46
+			\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null)
47 47
 	{
48
-		parent::__construct( $context, $mapping, $object );
48
+		parent::__construct($context, $mapping, $object);
49 49
 
50 50
 		/** controller/common/product/import/csv/processor/price/listtypes
51 51
 		 * Names of the product list types for prices that are updated or removed
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 		 * @see controller/common/product/import/csv/processor/product/listtypes
67 67
 		 * @see controller/common/product/import/csv/processor/text/listtypes
68 68
 		 */
69
-		$this->listTypes = $context->getConfig()->get( 'controller/common/product/import/csv/processor/price/listtypes' );
69
+		$this->listTypes = $context->getConfig()->get('controller/common/product/import/csv/processor/price/listtypes');
70 70
 	}
71 71
 
72 72
 
@@ -77,54 +77,54 @@  discard block
 block discarded – undo
77 77
 	 * @param array $data List of CSV fields with position as key and data as value
78 78
 	 * @return array List of data which hasn't been imported
79 79
 	 */
80
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
80
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
81 81
 	{
82
-		$listManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists' );
83
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'price' );
82
+		$listManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists');
83
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'price');
84 84
 
85 85
 		$listMap = [];
86
-		$map = $this->getMappedChunk( $data, $this->getMapping() );
87
-		$listItems = $product->getListItems( 'price', $this->listTypes );
86
+		$map = $this->getMappedChunk($data, $this->getMapping());
87
+		$listItems = $product->getListItems('price', $this->listTypes);
88 88
 
89
-		foreach( $listItems as $listItem )
89
+		foreach ($listItems as $listItem)
90 90
 		{
91
-			if( ( $refItem = $listItem->getRefItem() ) !== null ) {
92
-				$listMap[ $refItem->getValue() ][ $refItem->getType() ][ $listItem->getType() ] = $listItem;
91
+			if (($refItem = $listItem->getRefItem()) !== null) {
92
+				$listMap[$refItem->getValue()][$refItem->getType()][$listItem->getType()] = $listItem;
93 93
 			}
94 94
 		}
95 95
 
96
-		foreach( $map as $pos => $list )
96
+		foreach ($map as $pos => $list)
97 97
 		{
98
-			if( $this->checkEntry( $list ) === false ) {
98
+			if ($this->checkEntry($list) === false) {
99 99
 				continue;
100 100
 			}
101 101
 
102
-			$value = trim( isset( $list['price.value'] ) ? $list['price.value'] : '0.00' );
103
-			$type = trim( isset( $list['price.type'] ) ? $list['price.type'] : 'default' );
104
-			$typecode = trim( isset( $list['product.lists.type'] ) ? $list['product.lists.type'] : 'default' );
102
+			$value = trim(isset($list['price.value']) ? $list['price.value'] : '0.00');
103
+			$type = trim(isset($list['price.type']) ? $list['price.type'] : 'default');
104
+			$typecode = trim(isset($list['product.lists.type']) ? $list['product.lists.type'] : 'default');
105 105
 
106
-			if( isset( $listMap[$value][$type][$typecode] ) )
106
+			if (isset($listMap[$value][$type][$typecode]))
107 107
 			{
108 108
 				$listItem = $listMap[$value][$type][$typecode];
109 109
 				$refItem = $listItem->getRefItem();
110
-				unset( $listItems[ $listItem->getId() ] );
110
+				unset($listItems[$listItem->getId()]);
111 111
 			}
112 112
 			else
113 113
 			{
114
-				$listItem = $listManager->createItem( $typecode, 'price' );
115
-				$refItem = $manager->createItem( $type, 'product' );
114
+				$listItem = $listManager->createItem($typecode, 'price');
115
+				$refItem = $manager->createItem($type, 'product');
116 116
 			}
117 117
 
118 118
 
119
-			$refItem->fromArray( $this->addItemDefaults( $list ) );
120
-			$listItem->fromArray( $this->addListItemDefaults( $list, $pos ) );
119
+			$refItem->fromArray($this->addItemDefaults($list));
120
+			$listItem->fromArray($this->addListItemDefaults($list, $pos));
121 121
 
122
-			$product->addListItem( 'price', $listItem, $refItem );
122
+			$product->addListItem('price', $listItem, $refItem);
123 123
 		}
124 124
 
125
-		$product->deleteListItems( $listItems, true );
125
+		$product->deleteListItems($listItems, true);
126 126
 
127
-		return $this->getObject()->process( $product, $data );
127
+		return $this->getObject()->process($product, $data);
128 128
 	}
129 129
 
130 130
 
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
 	 * @param array $list Associative list of domain item keys and their values, e.g. "price.status" => 1
135 135
 	 * @return array Given associative list enriched by default values if they were not already set
136 136
 	 */
137
-	protected function addItemDefaults( array $list )
137
+	protected function addItemDefaults(array $list)
138 138
 	{
139
-		if( !isset( $list['price.label'] ) ) {
139
+		if (!isset($list['price.label'])) {
140 140
 			$list['price.label'] = $list['price.currencyid'] . ' ' . $list['price.value'];
141 141
 		}
142 142
 
143
-		if( !isset( $list['price.status'] ) ) {
143
+		if (!isset($list['price.status'])) {
144 144
 			$list['price.status'] = 1;
145 145
 		}
146 146
 
@@ -154,10 +154,10 @@  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( !isset( $list['price.value'] ) || trim( $list['price.value'] ) === '' || isset( $list['product.lists.type'] )
160
-			&& $this->listTypes !== null && !in_array( trim( $list['product.lists.type'] ), (array) $this->listTypes )
159
+		if (!isset($list['price.value']) || trim($list['price.value']) === '' || isset($list['product.lists.type'])
160
+			&& $this->listTypes !== null && !in_array(trim($list['product.lists.type']), (array) $this->listTypes)
161 161
 		) {
162 162
 			return false;
163 163
 		}
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -108,8 +108,7 @@
 block discarded – undo
108 108
 				$listItem = $listMap[$value][$type][$typecode];
109 109
 				$refItem = $listItem->getRefItem();
110 110
 				unset( $listItems[ $listItem->getId() ] );
111
-			}
112
-			else
111
+			} else
113 112
 			{
114 113
 				$listItem = $listManager->createItem( $typecode, 'price' );
115 114
 				$refItem = $manager->createItem( $type, 'product' );
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Processor/Catalog/Standard.php 2 patches
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
44 44
 	 * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor
45 45
 	 */
46
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping,
47
-		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null )
46
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
47
+		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null)
48 48
 	{
49
-		parent::__construct( $context, $mapping, $object );
49
+		parent::__construct($context, $mapping, $object);
50 50
 
51 51
 		/** controller/common/product/import/csv/processor/catalog/listtypes
52 52
 		 * Names of the catalog list types that are updated or removed
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
 		 * @see controller/common/product/import/csv/processor/product/listtypes
68 68
 		 * @see controller/common/product/import/csv/processor/text/listtypes
69 69
 		 */
70
-		$this->listTypes = $context->getConfig()->get( 'controller/common/product/import/csv/processor/catalog/listtypes' );
70
+		$this->listTypes = $context->getConfig()->get('controller/common/product/import/csv/processor/catalog/listtypes');
71 71
 
72
-		$this->cache = $this->getCache( 'catalog' );
72
+		$this->cache = $this->getCache('catalog');
73 73
 	}
74 74
 
75 75
 
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
 	 * @param array $data List of CSV fields with position as key and data as value
81 81
 	 * @return array List of data which hasn't been imported
82 82
 	 */
83
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
83
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
84 84
 	{
85 85
 		$context = $this->getContext();
86
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'catalog' );
87
-		$listManager = \Aimeos\MShop\Factory::createManager( $context, 'catalog/lists' );
86
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'catalog');
87
+		$listManager = \Aimeos\MShop\Factory::createManager($context, 'catalog/lists');
88 88
 
89 89
 		/** controller/common/product/import/csv/separator
90 90
 		 * Single separator character for multiple entries in one field of the import file
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 		 * @category Developer
105 105
 		 * @see controller/common/product/import/csv/domains
106 106
 		 */
107
-		$separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" );
107
+		$separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n");
108 108
 
109 109
 		$manager->begin();
110 110
 
@@ -112,57 +112,57 @@  discard block
 block discarded – undo
112 112
 		{
113 113
 			$listMap = [];
114 114
 			$prodid = $product->getId();
115
-			$map = $this->getMappedChunk( $data, $this->getMapping() );
116
-			$listItems = $this->getListItems( $prodid, $this->listTypes );
115
+			$map = $this->getMappedChunk($data, $this->getMapping());
116
+			$listItems = $this->getListItems($prodid, $this->listTypes);
117 117
 
118
-			foreach( $listItems as $listItem ) {
119
-				$listMap[ $listItem->getParentId() ][ $listItem->getType() ] = $listItem;
118
+			foreach ($listItems as $listItem) {
119
+				$listMap[$listItem->getParentId()][$listItem->getType()] = $listItem;
120 120
 			}
121 121
 
122
-			foreach( $map as $pos => $list )
122
+			foreach ($map as $pos => $list)
123 123
 			{
124
-				if( $this->checkEntry( $list ) === false ) {
124
+				if ($this->checkEntry($list) === false) {
125 125
 					continue;
126 126
 				}
127 127
 
128
-				$codes = explode( $separator, trim( $list['catalog.code'] ) );
129
-				$type = trim( isset( $list['catalog.lists.type'] ) ? $list['catalog.lists.type'] : 'default' );
128
+				$codes = explode($separator, trim($list['catalog.code']));
129
+				$type = trim(isset($list['catalog.lists.type']) ? $list['catalog.lists.type'] : 'default');
130 130
 
131
-				foreach( $codes as $code )
131
+				foreach ($codes as $code)
132 132
 				{
133
-					$code = trim( $code );
133
+					$code = trim($code);
134 134
 
135
-					if( ( $catid = $this->cache->get( $code ) ) === null )
135
+					if (($catid = $this->cache->get($code)) === null)
136 136
 					{
137 137
 						$msg = 'No category for code "%1$s" available when importing product with code "%2$s"';
138
-						throw new \Aimeos\Controller\Jobs\Exception( sprintf( $msg, $code, $product->getCode() ) );
138
+						throw new \Aimeos\Controller\Jobs\Exception(sprintf($msg, $code, $product->getCode()));
139 139
 					}
140 140
 
141 141
 					$list['catalog.lists.parentid'] = $catid;
142 142
 					$list['catalog.lists.refid'] = $prodid;
143 143
 					$list['catalog.lists.domain'] = 'product';
144 144
 
145
-					if( isset( $listMap[$catid][$type] ) )
145
+					if (isset($listMap[$catid][$type]))
146 146
 					{
147 147
 						$listItem = $listMap[$catid][$type];
148
-						unset( $listItems[ $listItem->getId() ] );
148
+						unset($listItems[$listItem->getId()]);
149 149
 					}
150 150
 					else
151 151
 					{
152
-						$listItem = $listManager->createItem( $type, 'product' );
152
+						$listItem = $listManager->createItem($type, 'product');
153 153
 					}
154 154
 
155
-					$listItem->fromArray( $this->addListItemDefaults( $list, $pos++ ) );
156
-					$listManager->saveItem( $listItem, false );
155
+					$listItem->fromArray($this->addListItemDefaults($list, $pos++));
156
+					$listManager->saveItem($listItem, false);
157 157
 				}
158 158
 			}
159 159
 
160
-			$listManager->deleteItems( array_keys( $listItems ) );
161
-			$data = $this->getObject()->process( $product, $data );
160
+			$listManager->deleteItems(array_keys($listItems));
161
+			$data = $this->getObject()->process($product, $data);
162 162
 
163 163
 			$manager->commit();
164 164
 		}
165
-		catch( \Exception $e )
165
+		catch (\Exception $e)
166 166
 		{
167 167
 			$manager->rollback();
168 168
 			throw $e;
@@ -179,13 +179,13 @@  discard block
 block discarded – undo
179 179
 	 * @param integer $pos Computed position of the list item in the associated list of items
180 180
 	 * @return array Given associative list enriched by default values if they were not already set
181 181
 	 */
182
-	protected function addListItemDefaults( array $list, $pos )
182
+	protected function addListItemDefaults(array $list, $pos)
183 183
 	{
184
-		if( !isset( $list['catalog.lists.position'] ) ) {
184
+		if (!isset($list['catalog.lists.position'])) {
185 185
 			$list['catalog.lists.position'] = $pos;
186 186
 		}
187 187
 
188
-		if( !isset( $list['catalog.lists.status'] ) ) {
188
+		if (!isset($list['catalog.lists.status'])) {
189 189
 			$list['catalog.lists.status'] = 1;
190 190
 		}
191 191
 
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
 	 * @param array $list Associative list of key/value pairs from the mapped data
200 200
 	 * @return boolean True if the entry is valid, false if not
201 201
 	 */
202
-	protected function checkEntry( array $list )
202
+	protected function checkEntry(array $list)
203 203
 	{
204
-		if( !isset( $list['catalog.code'] ) || trim( $list['catalog.code'] ) === '' || isset( $list['catalog.lists.type'] )
205
-			&& $this->listTypes !== null && !in_array( trim( $list['catalog.lists.type'] ), (array) $this->listTypes )
204
+		if (!isset($list['catalog.code']) || trim($list['catalog.code']) === '' || isset($list['catalog.lists.type'])
205
+			&& $this->listTypes !== null && !in_array(trim($list['catalog.lists.type']), (array) $this->listTypes)
206 206
 		) {
207 207
 			return false;
208 208
 		}
@@ -218,24 +218,24 @@  discard block
 block discarded – undo
218 218
 	 * @param array|null $types List of catalog list types
219 219
 	 * @return array List of catalog list items
220 220
 	 */
221
-	protected function getListItems( $prodid, $types )
221
+	protected function getListItems($prodid, $types)
222 222
 	{
223
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' );
223
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists');
224 224
 		$search = $manager->createSearch();
225 225
 
226 226
 		$expr = array(
227
-			$search->compare( '==', 'catalog.lists.domain', 'product' ),
228
-			$search->compare( '==', 'catalog.lists.refid', $prodid ),
227
+			$search->compare('==', 'catalog.lists.domain', 'product'),
228
+			$search->compare('==', 'catalog.lists.refid', $prodid),
229 229
 		);
230 230
 
231
-		if( $types !== null ) {
232
-			$expr[] = $search->compare( '==', 'catalog.lists.type.code', $types );
231
+		if ($types !== null) {
232
+			$expr[] = $search->compare('==', 'catalog.lists.type.code', $types);
233 233
 		}
234 234
 
235
-		$search->setConditions( $search->combine( '&&', $expr ) );
236
-		$search->setSortations( array( $search->sort( '+', 'catalog.lists.position' ) ) );
237
-		$search->setSlice( 0, 0x7FFFFFFF );
235
+		$search->setConditions($search->combine('&&', $expr));
236
+		$search->setSortations(array($search->sort('+', 'catalog.lists.position')));
237
+		$search->setSlice(0, 0x7FFFFFFF);
238 238
 
239
-		return $manager->searchItems( $search );
239
+		return $manager->searchItems($search);
240 240
 	}
241 241
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -146,8 +146,7 @@  discard block
 block discarded – undo
146 146
 					{
147 147
 						$listItem = $listMap[$catid][$type];
148 148
 						unset( $listItems[ $listItem->getId() ] );
149
-					}
150
-					else
149
+					} else
151 150
 					{
152 151
 						$listItem = $listManager->createItem( $type, 'product' );
153 152
 					}
@@ -161,8 +160,7 @@  discard block
 block discarded – undo
161 160
 			$data = $this->getObject()->process( $product, $data );
162 161
 
163 162
 			$manager->commit();
164
-		}
165
-		catch( \Exception $e )
163
+		} catch( \Exception $e )
166 164
 		{
167 165
 			$manager->rollback();
168 166
 			throw $e;
Please login to merge, or discard this patch.
common/src/Controller/Common/Product/Import/Csv/Processor/Text/Standard.php 2 patches
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -42,10 +42,10 @@  discard block
 block discarded – undo
42 42
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
43 43
 	 * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor
44 44
 	 */
45
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping,
46
-			\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null )
45
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
46
+			\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null)
47 47
 	{
48
-		parent::__construct( $context, $mapping, $object );
48
+		parent::__construct($context, $mapping, $object);
49 49
 
50 50
 		/** controller/common/product/import/csv/processor/text/listtypes
51 51
 		 * Names of the product list types for texts that are updated or removed
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 		 * @see controller/common/product/import/csv/processor/price/listtypes
67 67
 		 * @see controller/common/product/import/csv/processor/product/listtypes
68 68
 		 */
69
-		$this->listTypes = $context->getConfig()->get( 'controller/common/product/import/csv/processor/text/listtypes' );
69
+		$this->listTypes = $context->getConfig()->get('controller/common/product/import/csv/processor/text/listtypes');
70 70
 	}
71 71
 
72 72
 
@@ -77,53 +77,53 @@  discard block
 block discarded – undo
77 77
 	 * @param array $data List of CSV fields with position as key and data as value
78 78
 	 * @return array List of data which hasn't been imported
79 79
 	 */
80
-	public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
80
+	public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data)
81 81
 	{
82
-		$listManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists' );
83
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'text' );
82
+		$listManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists');
83
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'text');
84 84
 
85 85
 		$listMap = [];
86
-		$map = $this->getMappedChunk( $data, $this->getMapping() );
87
-		$listItems = $product->getListItems( 'text', $this->listTypes );
86
+		$map = $this->getMappedChunk($data, $this->getMapping());
87
+		$listItems = $product->getListItems('text', $this->listTypes);
88 88
 
89
-		foreach( $listItems as $listItem )
89
+		foreach ($listItems as $listItem)
90 90
 		{
91
-			if( ( $refItem = $listItem->getRefItem() ) !== null ) {
92
-				$listMap[ $refItem->getContent() ][ $refItem->getType() ][ $listItem->getType() ] = $listItem;
91
+			if (($refItem = $listItem->getRefItem()) !== null) {
92
+				$listMap[$refItem->getContent()][$refItem->getType()][$listItem->getType()] = $listItem;
93 93
 			}
94 94
 		}
95 95
 
96
-		foreach( $map as $pos => $list )
96
+		foreach ($map as $pos => $list)
97 97
 		{
98
-			if( $this->checkEntry( $list ) === false ) {
98
+			if ($this->checkEntry($list) === false) {
99 99
 				continue;
100 100
 			}
101 101
 
102
-			$content = trim( $list['text.content'] );
103
-			$type = trim( isset( $list['text.type'] ) ? $list['text.type'] : 'name' );
104
-			$typecode = trim( isset( $list['product.lists.type'] ) ? $list['product.lists.type'] : 'default' );
102
+			$content = trim($list['text.content']);
103
+			$type = trim(isset($list['text.type']) ? $list['text.type'] : 'name');
104
+			$typecode = trim(isset($list['product.lists.type']) ? $list['product.lists.type'] : 'default');
105 105
 
106
-			if( isset( $listMap[$content][$type][$typecode] ) )
106
+			if (isset($listMap[$content][$type][$typecode]))
107 107
 			{
108 108
 				$listItem = $listMap[$content][$type][$typecode];
109 109
 				$refItem = $listItem->getRefItem();
110
-				unset( $listItems[ $listItem->getId() ] );
110
+				unset($listItems[$listItem->getId()]);
111 111
 			}
112 112
 			else
113 113
 			{
114
-				$listItem = $listManager->createItem( $typecode, 'text' );
115
-				$refItem = $manager->createItem( $type, 'product' );
114
+				$listItem = $listManager->createItem($typecode, 'text');
115
+				$refItem = $manager->createItem($type, 'product');
116 116
 			}
117 117
 
118
-			$refItem->fromArray( $this->addItemDefaults( $list ) );
119
-			$listItem->fromArray( $this->addListItemDefaults( $list, $pos ) );
118
+			$refItem->fromArray($this->addItemDefaults($list));
119
+			$listItem->fromArray($this->addListItemDefaults($list, $pos));
120 120
 
121
-			$product->addListItem( 'text', $listItem, $refItem );
121
+			$product->addListItem('text', $listItem, $refItem);
122 122
 		}
123 123
 
124
-		$product->deleteListItems( $listItems, true );
124
+		$product->deleteListItems($listItems, true);
125 125
 
126
-		return $this->getObject()->process( $product, $data );
126
+		return $this->getObject()->process($product, $data);
127 127
 	}
128 128
 
129 129
 
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
 	 * @param array $list Associative list of domain item keys and their values, e.g. "text.status" => 1
134 134
 	 * @return array Given associative list enriched by default values if they were not already set
135 135
 	 */
136
-	protected function addItemDefaults( array $list )
136
+	protected function addItemDefaults(array $list)
137 137
 	{
138
-		if( !isset( $list['text.label'] ) ) {
139
-			$list['text.label'] = mb_strcut( trim( $list['text.content'] ), 0, 255 );
138
+		if (!isset($list['text.label'])) {
139
+			$list['text.label'] = mb_strcut(trim($list['text.content']), 0, 255);
140 140
 		}
141 141
 
142
-		if( !isset( $list['text.status'] ) ) {
142
+		if (!isset($list['text.status'])) {
143 143
 			$list['text.status'] = 1;
144 144
 		}
145 145
 
@@ -153,10 +153,10 @@  discard block
 block discarded – undo
153 153
 	 * @param array $list Associative list of key/value pairs from the mapping
154 154
 	 * @return boolean True if valid, false if not
155 155
 	 */
156
-	protected function checkEntry( array $list )
156
+	protected function checkEntry(array $list)
157 157
 	{
158
-		if( !isset( $list['text.content'] ) || trim( $list['text.content'] ) === '' || isset( $list['product.lists.type'] )
159
-			&& $this->listTypes !== null && !in_array( trim( $list['product.lists.type'] ), (array) $this->listTypes )
158
+		if (!isset($list['text.content']) || trim($list['text.content']) === '' || isset($list['product.lists.type'])
159
+			&& $this->listTypes !== null && !in_array(trim($list['product.lists.type']), (array) $this->listTypes)
160 160
 		) {
161 161
 			return false;
162 162
 		}
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -108,8 +108,7 @@
 block discarded – undo
108 108
 				$listItem = $listMap[$content][$type][$typecode];
109 109
 				$refItem = $listItem->getRefItem();
110 110
 				unset( $listItems[ $listItem->getId() ] );
111
-			}
112
-			else
111
+			} else
113 112
 			{
114 113
 				$listItem = $listManager->createItem( $typecode, 'text' );
115 114
 				$refItem = $manager->createItem( $type, 'product' );
Please login to merge, or discard this patch.
src/Controller/Common/Product/Import/Csv/Processor/Attribute/Standard.php 2 patches
Spacing   +43 added lines, -43 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,59 +80,59 @@  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
-		$listManager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' );
87
-		$separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" );
86
+		$listManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists');
87
+		$separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n");
88 88
 
89 89
 		$listMap = [];
90
-		$map = $this->getMappedChunk( $data, $this->getMapping() );
91
-		$listItems = $product->getListItems( 'attribute', $this->listTypes );
90
+		$map = $this->getMappedChunk($data, $this->getMapping());
91
+		$listItems = $product->getListItems('attribute', $this->listTypes);
92 92
 
93
-		foreach( $listItems as $listItem )
93
+		foreach ($listItems as $listItem)
94 94
 		{
95
-			if( ( $refItem = $listItem->getRefItem() ) !== null ) {
96
-				$listMap[ $refItem->getCode() ][ $listItem->getType() ] = $listItem;
95
+			if (($refItem = $listItem->getRefItem()) !== null) {
96
+				$listMap[$refItem->getCode()][$listItem->getType()] = $listItem;
97 97
 			}
98 98
 		}
99 99
 
100
-		foreach( $map as $pos => $list )
100
+		foreach ($map as $pos => $list)
101 101
 		{
102
-			if( $this->checkEntry( $list ) === false ) {
102
+			if ($this->checkEntry($list) === false) {
103 103
 				continue;
104 104
 			}
105 105
 
106
-			$codes = explode( $separator, trim( $list['attribute.code'] ) );
106
+			$codes = explode($separator, trim($list['attribute.code']));
107 107
 
108
-			foreach( $codes as $code )
108
+			foreach ($codes as $code)
109 109
 			{
110
-				$code = trim( $code );
111
-				$typecode = trim( $this->getValue( $list, 'product.lists.type', 'default' ) );
110
+				$code = trim($code);
111
+				$typecode = trim($this->getValue($list, 'product.lists.type', 'default'));
112 112
 
113
-				if( isset( $listMap[$code][$typecode] ) )
113
+				if (isset($listMap[$code][$typecode]))
114 114
 				{
115 115
 					$listItem = $listMap[$code][$typecode];
116
-					unset( $listItems[ $listItem->getId() ] );
116
+					unset($listItems[$listItem->getId()]);
117 117
 				}
118 118
 				else
119 119
 				{
120
-					$listItem = $listManager->createItem( $typecode, 'attribute' );
120
+					$listItem = $listManager->createItem($typecode, 'attribute');
121 121
 				}
122 122
 
123
-				$attrItem = $this->getAttributeItem( $code, trim( $list['attribute.type'] ) );
124
-				$attrItem->fromArray( $list );
125
-				$attrItem->setCode( $code );
123
+				$attrItem = $this->getAttributeItem($code, trim($list['attribute.type']));
124
+				$attrItem->fromArray($list);
125
+				$attrItem->setCode($code);
126 126
 
127
-				$listItem->fromArray( $this->addListItemDefaults( $list, $pos ) );
127
+				$listItem->fromArray($this->addListItemDefaults($list, $pos));
128 128
 
129
-				$product->addListItem( 'attribute', $listItem, $attrItem );
129
+				$product->addListItem('attribute', $listItem, $attrItem);
130 130
 			}
131 131
 		}
132 132
 
133
-		$product->deleteListItems( $listItems );
133
+		$product->deleteListItems($listItems);
134 134
 
135
-		return $this->getObject()->process( $product, $data );
135
+		return $this->getObject()->process($product, $data);
136 136
 	}
137 137
 
138 138
 
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
 	 * @param array $list Associative list of key/value pairs from the mapped data
143 143
 	 * @return boolean True if the entry is valid, false if not
144 144
 	 */
145
-	protected function checkEntry( array $list )
145
+	protected function checkEntry(array $list)
146 146
 	{
147
-		if( !isset( $list['attribute.code'] ) || trim( $list['attribute.code'] ) === ''
148
-			|| trim( $list['attribute.type'] ) === '' || isset( $list['product.lists.type'] )
149
-			&& $this->listTypes !== null && !in_array( trim( $list['product.lists.type'] ), (array) $this->listTypes )
147
+		if (!isset($list['attribute.code']) || trim($list['attribute.code']) === ''
148
+			|| trim($list['attribute.type']) === '' || isset($list['product.lists.type'])
149
+			&& $this->listTypes !== null && !in_array(trim($list['product.lists.type']), (array) $this->listTypes)
150 150
 		) {
151 151
 			return false;
152 152
 		}
@@ -162,22 +162,22 @@  discard block
 block discarded – undo
162 162
 	 * @param string $type Attribute type
163 163
 	 * @return \Aimeos\MShop\Attribute\Item\Iface Attribute item object
164 164
 	 */
165
-	protected function getAttributeItem( $code, $type )
165
+	protected function getAttributeItem($code, $type)
166 166
 	{
167
-		if( ( $item = $this->cache->get( $code, $type ) ) === null )
167
+		if (($item = $this->cache->get($code, $type)) === null)
168 168
 		{
169
-			$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' );
169
+			$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute');
170 170
 
171 171
 			$item = $manager->createItem();
172
-			$item->setTypeId( $this->getTypeId( 'attribute/type', 'product', $type ) );
173
-			$item->setDomain( 'product' );
174
-			$item->setLabel( $code );
175
-			$item->setCode( $code );
176
-			$item->setStatus( 1 );
172
+			$item->setTypeId($this->getTypeId('attribute/type', 'product', $type));
173
+			$item->setDomain('product');
174
+			$item->setLabel($code);
175
+			$item->setCode($code);
176
+			$item->setStatus(1);
177 177
 
178
-			$item = $manager->saveItem( $item );
178
+			$item = $manager->saveItem($item);
179 179
 
180
-			$this->cache->set( $item );
180
+			$this->cache->set($item);
181 181
 		}
182 182
 
183 183
 		return $item;
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -114,8 +114,7 @@
 block discarded – undo
114 114
 				{
115 115
 					$listItem = $listMap[$code][$typecode];
116 116
 					unset( $listItems[ $listItem->getId() ] );
117
-				}
118
-				else
117
+				} else
119 118
 				{
120 119
 					$listItem = $listManager->createItem( $typecode, 'attribute' );
121 120
 				}
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Subscription/Process/Begin/Standard.php 2 patches
Spacing   +34 added lines, -34 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', 'Subscription process start' );
31
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Subscription process start');
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', 'Process subscriptions initially' );
42
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Process subscriptions initially');
43 43
 	}
44 44
 
45 45
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 		 * @see controller/common/subscription/process/payment-status
68 68
 		 * @see controller/common/subscription/process/payment-days
69 69
 		 */
70
-		$names = (array) $config->get( 'controller/common/subscription/process/processors', [] );
70
+		$names = (array) $config->get('controller/common/subscription/process/processors', []);
71 71
 
72 72
 		/** controller/common/subscription/process/payment-status
73 73
 		 * Minimum payment status that will activate the subscription
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 		 * @see controller/common/subscription/process/payment-days
87 87
 		 */
88 88
 		$status = \Aimeos\MShop\Order\Item\Base::PAY_AUTHORIZED;
89
-		$status = $config->get( 'controller/common/subscription/process/payment-status', $status );
89
+		$status = $config->get('controller/common/subscription/process/payment-status', $status);
90 90
 
91 91
 		/** controller/common/subscription/process/payment-days
92 92
 		 * Number of days to wait for the payment until subscription is removed
@@ -104,74 +104,74 @@  discard block
 block discarded – undo
104 104
 		 * @see controller/common/subscription/process/processors
105 105
 		 * @see controller/common/subscription/process/payment-status
106 106
 		 */
107
-		$days = (float) $config->get( 'controller/common/subscription/process/payment-days', 3 );
107
+		$days = (float) $config->get('controller/common/subscription/process/payment-days', 3);
108 108
 
109 109
 
110
-		$processors = $this->getProcessors( $names );
111
-		$orderManager = \Aimeos\MShop\Factory::createManager( $context, 'order' );
112
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'subscription' );
110
+		$processors = $this->getProcessors($names);
111
+		$orderManager = \Aimeos\MShop\Factory::createManager($context, 'order');
112
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'subscription');
113 113
 
114
-		$search = $manager->createSearch( true );
114
+		$search = $manager->createSearch(true);
115 115
 		$expr = [
116
-			$search->compare( '==', 'subscription.datenext', null ),
116
+			$search->compare('==', 'subscription.datenext', null),
117 117
 			$search->getConditions(),
118 118
 		];
119
-		$search->setConditions( $search->combine( '&&', $expr ) );
120
-		$search->setSortations( [$search->sort( '+', 'subscription.id' )] );
119
+		$search->setConditions($search->combine('&&', $expr));
120
+		$search->setSortations([$search->sort('+', 'subscription.id')]);
121 121
 
122
-		$date = date( 'Y-m-d H:i:s', time() - 86400 * $days );
122
+		$date = date('Y-m-d H:i:s', time() - 86400 * $days);
123 123
 		$start = 0;
124 124
 
125 125
 		do
126 126
 		{
127 127
 			$ordBaseIds = $payStatus = [];
128 128
 
129
-			$search->setSlice( $start, 100 );
130
-			$items = $manager->searchItems( $search );
129
+			$search->setSlice($start, 100);
130
+			$items = $manager->searchItems($search);
131 131
 
132
-			foreach( $items as $item ) {
132
+			foreach ($items as $item) {
133 133
 				$ordBaseIds[] = $item->getOrderBaseId();
134 134
 			}
135 135
 
136
-			$orderSearch = $orderManager->createSearch()->setSlice( 0, $search->getSliceSize() );
137
-			$orderSearch->setConditions( $orderSearch->compare( '==', 'order.base.id', $ordBaseIds ) );
138
-			$orderSearch->setSortations( [$orderSearch->sort( '+', 'order.id' )] );
136
+			$orderSearch = $orderManager->createSearch()->setSlice(0, $search->getSliceSize());
137
+			$orderSearch->setConditions($orderSearch->compare('==', 'order.base.id', $ordBaseIds));
138
+			$orderSearch->setSortations([$orderSearch->sort('+', 'order.id')]);
139 139
 
140
-			foreach( $orderManager->searchItems( $orderSearch ) as $orderItem ) {
140
+			foreach ($orderManager->searchItems($orderSearch) as $orderItem) {
141 141
 				$payStatus[$orderItem->getBaseId()] = $orderItem->getPaymentStatus();
142 142
 			}
143 143
 
144
-			foreach( $items as $item )
144
+			foreach ($items as $item)
145 145
 			{
146 146
 				try
147 147
 				{
148
-					if( isset( $payStatus[$item->getOrderBaseId()] ) && $payStatus[$item->getOrderBaseId()] >= $status )
148
+					if (isset($payStatus[$item->getOrderBaseId()]) && $payStatus[$item->getOrderBaseId()] >= $status)
149 149
 					{
150
-						foreach( $processors as $processor ) {
151
-							$processor->begin( $item );
150
+						foreach ($processors as $processor) {
151
+							$processor->begin($item);
152 152
 						}
153 153
 
154
-						$interval = new \DateInterval( $item->getInterval() );
155
-						$item->setDateNext( date_create( $item->getTimeCreated() )->add( $interval )->format( 'Y-m-d' ) );
154
+						$interval = new \DateInterval($item->getInterval());
155
+						$item->setDateNext(date_create($item->getTimeCreated())->add($interval)->format('Y-m-d'));
156 156
 					}
157
-					elseif( $item->getTimeCreated() < $date )
157
+					elseif ($item->getTimeCreated() < $date)
158 158
 					{
159
-						$item->setStatus( 0 );
159
+						$item->setStatus(0);
160 160
 					}
161 161
 
162
-					$manager->saveItem( $item );
162
+					$manager->saveItem($item);
163 163
 				}
164
-				catch( \Exception $e )
164
+				catch (\Exception $e)
165 165
 				{
166 166
 					$msg = 'Unable to process subscription with ID "%1$S": %2$s';
167
-					$logger->log( sprintf( $msg, $item->getId(), $e->getMessage() ) );
168
-					$logger->log( $e->getTraceAsString() );
167
+					$logger->log(sprintf($msg, $item->getId(), $e->getMessage()));
168
+					$logger->log($e->getTraceAsString());
169 169
 				}
170 170
 			}
171 171
 
172
-			$count = count( $items );
172
+			$count = count($items);
173 173
 			$start += $count;
174 174
 		}
175
-		while( $count === $search->getSliceSize() );
175
+		while ($count === $search->getSliceSize());
176 176
 	}
177 177
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -153,15 +153,13 @@
 block discarded – undo
153 153
 
154 154
 						$interval = new \DateInterval( $item->getInterval() );
155 155
 						$item->setDateNext( date_create( $item->getTimeCreated() )->add( $interval )->format( 'Y-m-d' ) );
156
-					}
157
-					elseif( $item->getTimeCreated() < $date )
156
+					} elseif( $item->getTimeCreated() < $date )
158 157
 					{
159 158
 						$item->setStatus( 0 );
160 159
 					}
161 160
 
162 161
 					$manager->saveItem( $item );
163
-				}
164
-				catch( \Exception $e )
162
+				} catch( \Exception $e )
165 163
 				{
166 164
 					$msg = 'Unable to process subscription with ID "%1$S": %2$s';
167 165
 					$logger->log( sprintf( $msg, $item->getId(), $e->getMessage() ) );
Please login to merge, or discard this patch.
controller/jobs/tests/TestHelperJobs.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -15,14 +15,14 @@  discard block
 block discarded – undo
15 15
 	public static function bootstrap()
16 16
 	{
17 17
 		self::getAimeos();
18
-		\Aimeos\MShop\Factory::setCache( false );
18
+		\Aimeos\MShop\Factory::setCache(false);
19 19
 	}
20 20
 
21 21
 
22
-	public static function getContext( $site = 'unittest' )
22
+	public static function getContext($site = 'unittest')
23 23
 	{
24
-		if( !isset( self::$context[$site] ) ) {
25
-			self::$context[$site] = self::createContext( $site );
24
+		if (!isset(self::$context[$site])) {
25
+			self::$context[$site] = self::createContext($site);
26 26
 		}
27 27
 
28 28
 		return clone self::$context[$site];
@@ -31,13 +31,13 @@  discard block
 block discarded – undo
31 31
 
32 32
 	public static function getAimeos()
33 33
 	{
34
-		if( !isset( self::$aimeos ) )
34
+		if (!isset(self::$aimeos))
35 35
 		{
36 36
 			require_once 'Bootstrap.php';
37
-			spl_autoload_register( 'Aimeos\\Bootstrap::autoload' );
37
+			spl_autoload_register('Aimeos\\Bootstrap::autoload');
38 38
 
39
-			$extdir = dirname( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) );
40
-			self::$aimeos = new \Aimeos\Bootstrap( array( $extdir ), true );
39
+			$extdir = dirname(dirname(dirname(dirname(dirname(__FILE__)))));
40
+			self::$aimeos = new \Aimeos\Bootstrap(array($extdir), true);
41 41
 		}
42 42
 
43 43
 		return self::$aimeos;
@@ -46,14 +46,14 @@  discard block
 block discarded – undo
46 46
 
47 47
 	public static function getControllerPaths()
48 48
 	{
49
-		return self::getAimeos()->getCustomPaths( 'controller/jobs' );
49
+		return self::getAimeos()->getCustomPaths('controller/jobs');
50 50
 	}
51 51
 
52 52
 
53 53
 	/**
54 54
 	 * @param string $site
55 55
 	 */
56
-	private static function createContext( $site )
56
+	private static function createContext($site)
57 57
 	{
58 58
 		$ctx = new \Aimeos\MShop\Context\Item\Standard();
59 59
 		$aimeos = self::getAimeos();
@@ -63,80 +63,80 @@  discard block
 block discarded – undo
63 63
 		$paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config';
64 64
 		$file = __DIR__ . DIRECTORY_SEPARATOR . 'confdoc.ser';
65 65
 
66
-		$conf = new \Aimeos\MW\Config\PHPArray( [], $paths );
67
-		$conf = new \Aimeos\MW\Config\Decorator\Memory( $conf );
68
-		$conf = new \Aimeos\MW\Config\Decorator\Documentor( $conf, $file );
69
-		$ctx->setConfig( $conf );
66
+		$conf = new \Aimeos\MW\Config\PHPArray([], $paths);
67
+		$conf = new \Aimeos\MW\Config\Decorator\Memory($conf);
68
+		$conf = new \Aimeos\MW\Config\Decorator\Documentor($conf, $file);
69
+		$ctx->setConfig($conf);
70 70
 
71 71
 
72
-		$logger = new \Aimeos\MW\Logger\File( $site . '.log', \Aimeos\MW\Logger\Base::DEBUG );
73
-		$ctx->setLogger( $logger );
72
+		$logger = new \Aimeos\MW\Logger\File($site . '.log', \Aimeos\MW\Logger\Base::DEBUG);
73
+		$ctx->setLogger($logger);
74 74
 
75 75
 
76
-		$dbm = new \Aimeos\MW\DB\Manager\PDO( $conf );
77
-		$ctx->setDatabaseManager( $dbm );
76
+		$dbm = new \Aimeos\MW\DB\Manager\PDO($conf);
77
+		$ctx->setDatabaseManager($dbm);
78 78
 
79 79
 
80
-		$fs = new \Aimeos\MW\Filesystem\Manager\Standard( $conf );
81
-		$ctx->setFilesystemManager( $fs );
80
+		$fs = new \Aimeos\MW\Filesystem\Manager\Standard($conf);
81
+		$ctx->setFilesystemManager($fs);
82 82
 
83 83
 
84
-		$mq = new \Aimeos\MW\MQueue\Manager\Standard( $conf );
85
-		$ctx->setMessageQueueManager( $mq );
84
+		$mq = new \Aimeos\MW\MQueue\Manager\Standard($conf);
85
+		$ctx->setMessageQueueManager($mq);
86 86
 
87 87
 
88 88
 		$cache = new \Aimeos\MW\Cache\None();
89
-		$ctx->setCache( $cache );
89
+		$ctx->setCache($cache);
90 90
 
91 91
 
92 92
 		$session = new \Aimeos\MW\Session\None();
93
-		$ctx->setSession( $session );
93
+		$ctx->setSession($session);
94 94
 
95 95
 
96
-		$i18n = new \Aimeos\MW\Translation\None( 'de' );
97
-		$ctx->setI18n( array( 'de' => $i18n ) );
96
+		$i18n = new \Aimeos\MW\Translation\None('de');
97
+		$ctx->setI18n(array('de' => $i18n));
98 98
 
99 99
 
100
-		$localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $ctx );
101
-		$locale = $localeManager->bootstrap( $site, 'de', '', false );
102
-		$ctx->setLocale( $locale );
100
+		$localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($ctx);
101
+		$locale = $localeManager->bootstrap($site, 'de', '', false);
102
+		$ctx->setLocale($locale);
103 103
 
104 104
 
105
-		$view = self::createView( $conf );
106
-		$ctx->setView( $view );
105
+		$view = self::createView($conf);
106
+		$ctx->setView($view);
107 107
 
108 108
 
109
-		$ctx->setEditor( 'core:controller/jobs' );
109
+		$ctx->setEditor('core:controller/jobs');
110 110
 
111 111
 		return $ctx;
112 112
 	}
113 113
 
114 114
 
115
-	protected static function createView( \Aimeos\MW\Config\Iface $config )
115
+	protected static function createView(\Aimeos\MW\Config\Iface $config)
116 116
 	{
117 117
 		$tmplpaths = array_merge_recursive(
118
-			self::getAimeos()->getCustomPaths( 'client/html/templates' ),
119
-			self::getAimeos()->getCustomPaths( 'controller/jobs/templates' )
118
+			self::getAimeos()->getCustomPaths('client/html/templates'),
119
+			self::getAimeos()->getCustomPaths('controller/jobs/templates')
120 120
 		);
121 121
 
122
-		$view = new \Aimeos\MW\View\Standard( $tmplpaths );
122
+		$view = new \Aimeos\MW\View\Standard($tmplpaths);
123 123
 
124
-		$trans = new \Aimeos\MW\Translation\None( 'de_DE' );
125
-		$helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $trans );
126
-		$view->addHelper( 'translate', $helper );
124
+		$trans = new \Aimeos\MW\Translation\None('de_DE');
125
+		$helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $trans);
126
+		$view->addHelper('translate', $helper);
127 127
 
128
-		$helper = new \Aimeos\MW\View\Helper\Url\Standard( $view, 'http://baseurl' );
129
-		$view->addHelper( 'url', $helper );
128
+		$helper = new \Aimeos\MW\View\Helper\Url\Standard($view, 'http://baseurl');
129
+		$view->addHelper('url', $helper);
130 130
 
131
-		$helper = new \Aimeos\MW\View\Helper\Number\Standard( $view, '.', '' );
132
-		$view->addHelper( 'number', $helper );
131
+		$helper = new \Aimeos\MW\View\Helper\Number\Standard($view, '.', '');
132
+		$view->addHelper('number', $helper);
133 133
 
134
-		$helper = new \Aimeos\MW\View\Helper\Date\Standard( $view, 'Y-m-d' );
135
-		$view->addHelper( 'date', $helper );
134
+		$helper = new \Aimeos\MW\View\Helper\Date\Standard($view, 'Y-m-d');
135
+		$view->addHelper('date', $helper);
136 136
 
137
-		$config = new \Aimeos\MW\Config\Decorator\Protect( $config, array( 'controller/jobs', 'client/html' ) );
138
-		$helper = new \Aimeos\MW\View\Helper\Config\Standard( $view, $config );
139
-		$view->addHelper( 'config', $helper );
137
+		$config = new \Aimeos\MW\Config\Decorator\Protect($config, array('controller/jobs', 'client/html'));
138
+		$helper = new \Aimeos\MW\View\Helper\Config\Standard($view, $config);
139
+		$view->addHelper('config', $helper);
140 140
 
141 141
 		return $view;
142 142
 	}
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Order/Service/Delivery/Standard.php 2 patches
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	public function getName()
31 31
 	{
32
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Process order delivery services' );
32
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Process order delivery services');
33 33
 	}
34 34
 
35 35
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	public function getDescription()
42 42
 	{
43
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Sends paid orders to the ERP system or logistic partner' );
43
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Sends paid orders to the ERP system or logistic partner');
44 44
 	}
45 45
 
46 46
 
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 		 * @see controller/jobs/order/email/delivery/standard/limit-days
70 70
 		 * @see controller/jobs/order/service/delivery/batch-max
71 71
 		 */
72
-		$days = $context->getConfig()->get( 'controller/jobs/order/service/delivery/limit-days', 90 );
73
-		$date = date( 'Y-m-d 00:00:00', time() - 86400 * $days );
72
+		$days = $context->getConfig()->get('controller/jobs/order/service/delivery/limit-days', 90);
73
+		$date = date('Y-m-d 00:00:00', time() - 86400 * $days);
74 74
 
75 75
 		/** controller/jobs/order/service/delivery/batch-max
76 76
 		 * Maximum number of orders processed at once by the delivery service provider
@@ -85,71 +85,71 @@  discard block
 block discarded – undo
85 85
 		 * @category Developer
86 86
 		 * @see controller/jobs/order/service/delivery/limit-days
87 87
 		 */
88
-		$maxItems = $context->getConfig()->get( 'controller/jobs/order/service/delivery/batch-max', 100 );
88
+		$maxItems = $context->getConfig()->get('controller/jobs/order/service/delivery/batch-max', 100);
89 89
 
90 90
 
91
-		$serviceManager = \Aimeos\MShop\Service\Manager\Factory::createManager( $context );
91
+		$serviceManager = \Aimeos\MShop\Service\Manager\Factory::createManager($context);
92 92
 		$serviceSearch = $serviceManager->createSearch();
93
-		$serviceSearch->setConditions( $serviceSearch->compare( '==', 'service.type.code', 'delivery' ) );
93
+		$serviceSearch->setConditions($serviceSearch->compare('==', 'service.type.code', 'delivery'));
94 94
 
95
-		$orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( $context );
95
+		$orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager($context);
96 96
 		$orderSearch = $orderManager->createSearch();
97 97
 
98 98
 		$start = 0;
99 99
 
100 100
 		do
101 101
 		{
102
-			$serviceItems = $serviceManager->searchItems( $serviceSearch );
102
+			$serviceItems = $serviceManager->searchItems($serviceSearch);
103 103
 
104
-			foreach( $serviceItems as $serviceItem )
104
+			foreach ($serviceItems as $serviceItem)
105 105
 			{
106 106
 				try
107 107
 				{
108
-					$serviceProvider = $serviceManager->getProvider( $serviceItem, $serviceItem->getType() );
108
+					$serviceProvider = $serviceManager->getProvider($serviceItem, $serviceItem->getType());
109 109
 
110 110
 					$expr = array(
111
-						$orderSearch->compare( '>', 'order.datepayment', $date ),
112
-						$orderSearch->compare( '>', 'order.statuspayment', \Aimeos\MShop\Order\Item\Base::PAY_PENDING ),
113
-						$orderSearch->compare( '==', 'order.statusdelivery', \Aimeos\MShop\Order\Item\Base::STAT_UNFINISHED ),
114
-						$orderSearch->compare( '==', 'order.base.service.code', $serviceItem->getCode() ),
115
-						$orderSearch->compare( '==', 'order.base.service.type', 'delivery' ),
111
+						$orderSearch->compare('>', 'order.datepayment', $date),
112
+						$orderSearch->compare('>', 'order.statuspayment', \Aimeos\MShop\Order\Item\Base::PAY_PENDING),
113
+						$orderSearch->compare('==', 'order.statusdelivery', \Aimeos\MShop\Order\Item\Base::STAT_UNFINISHED),
114
+						$orderSearch->compare('==', 'order.base.service.code', $serviceItem->getCode()),
115
+						$orderSearch->compare('==', 'order.base.service.type', 'delivery'),
116 116
 					);
117
-					$orderSearch->setConditions( $orderSearch->combine( '&&', $expr ) );
117
+					$orderSearch->setConditions($orderSearch->combine('&&', $expr));
118 118
 
119 119
 					$orderStart = 0;
120 120
 
121 121
 					do
122 122
 					{
123
-						$orderSearch->setSlice( $orderStart, $maxItems );
124
-						$orderItems = $orderManager->searchItems( $orderSearch );
123
+						$orderSearch->setSlice($orderStart, $maxItems);
124
+						$orderItems = $orderManager->searchItems($orderSearch);
125 125
 
126 126
 						try
127 127
 						{
128
-							$serviceProvider->processBatch( $orderItems );
129
-							$orderManager->saveItems( $orderItems );
128
+							$serviceProvider->processBatch($orderItems);
129
+							$orderManager->saveItems($orderItems);
130 130
 						}
131
-						catch( \Exception $e )
131
+						catch (\Exception $e)
132 132
 						{
133 133
 							$str = 'Error while processing orders by delivery service "%1$s": %2$s';
134
-							$context->getLogger()->log( sprintf( $str, $serviceItem->getLabel(), $e->getMessage() ) );
134
+							$context->getLogger()->log(sprintf($str, $serviceItem->getLabel(), $e->getMessage()));
135 135
 						}
136 136
 
137
-						$orderCount = count( $orderItems );
137
+						$orderCount = count($orderItems);
138 138
 						$orderStart += $orderCount;
139 139
 					}
140
-					while( $orderCount >= $orderSearch->getSliceSize() );
140
+					while ($orderCount >= $orderSearch->getSliceSize());
141 141
 				}
142
-				catch( \Exception $e )
142
+				catch (\Exception $e)
143 143
 				{
144 144
 					$str = 'Error while processing service with ID "%1$s": %2$s';
145
-					$context->getLogger()->log( sprintf( $str, $serviceItem->getId(), $e->getMessage() ) );
145
+					$context->getLogger()->log(sprintf($str, $serviceItem->getId(), $e->getMessage()));
146 146
 				}
147 147
 			}
148 148
 
149
-			$count = count( $serviceItems );
149
+			$count = count($serviceItems);
150 150
 			$start += $count;
151
-			$serviceSearch->setSlice( $start );
151
+			$serviceSearch->setSlice($start);
152 152
 		}
153
-		while( $count >= $serviceSearch->getSliceSize() );
153
+		while ($count >= $serviceSearch->getSliceSize());
154 154
 	}
155 155
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -127,8 +127,7 @@  discard block
 block discarded – undo
127 127
 						{
128 128
 							$serviceProvider->processBatch( $orderItems );
129 129
 							$orderManager->saveItems( $orderItems );
130
-						}
131
-						catch( \Exception $e )
130
+						} catch( \Exception $e )
132 131
 						{
133 132
 							$str = 'Error while processing orders by delivery service "%1$s": %2$s';
134 133
 							$context->getLogger()->log( sprintf( $str, $serviceItem->getLabel(), $e->getMessage() ) );
@@ -138,8 +137,7 @@  discard block
 block discarded – undo
138 137
 						$orderStart += $orderCount;
139 138
 					}
140 139
 					while( $orderCount >= $orderSearch->getSliceSize() );
141
-				}
142
-				catch( \Exception $e )
140
+				} catch( \Exception $e )
143 141
 				{
144 142
 					$str = 'Error while processing service with ID "%1$s": %2$s';
145 143
 					$context->getLogger()->log( sprintf( $str, $serviceItem->getId(), $e->getMessage() ) );
Please login to merge, or discard this patch.