@@ -26,17 +26,17 @@ discard block |
||
26 | 26 | * @param array $codes List of coupon codes |
27 | 27 | * @return array Associative list of coupon codes as key and coupon code items as value |
28 | 28 | */ |
29 | - protected function getCouponCodeItems( array $codes ) |
|
29 | + protected function getCouponCodeItems(array $codes) |
|
30 | 30 | { |
31 | 31 | $result = []; |
32 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon/code' ); |
|
32 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon/code'); |
|
33 | 33 | |
34 | 34 | $search = $manager->createSearch(); |
35 | - $search->setConditions( $search->compare( '==', 'coupon.code.code', $codes ) ); |
|
36 | - $search->setSlice( 0, count( $codes ) ); |
|
35 | + $search->setConditions($search->compare('==', 'coupon.code.code', $codes)); |
|
36 | + $search->setSlice(0, count($codes)); |
|
37 | 37 | |
38 | - foreach( $manager->searchItems( $search ) as $item ) { |
|
39 | - $result[ $item->getCode() ] = $item; |
|
38 | + foreach ($manager->searchItems($search) as $item) { |
|
39 | + $result[$item->getCode()] = $item; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | return $result; |
@@ -51,15 +51,15 @@ discard block |
||
51 | 51 | * @param integer $codePos Column position which contains the unique coupon code (starting from 0) |
52 | 52 | * @return array List of arrays with coupon codes as keys and list of values from the CSV file |
53 | 53 | */ |
54 | - protected function getData( \Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos ) |
|
54 | + protected function getData(\Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos) |
|
55 | 55 | { |
56 | 56 | $count = 0; |
57 | 57 | $data = []; |
58 | 58 | |
59 | - while( $content->valid() && $count++ < $maxcnt ) |
|
59 | + while ($content->valid() && $count++ < $maxcnt) |
|
60 | 60 | { |
61 | 61 | $row = $content->current(); |
62 | - $data[ $row[$codePos] ] = $row; |
|
62 | + $data[$row[$codePos]] = $row; |
|
63 | 63 | $content->next(); |
64 | 64 | } |
65 | 65 | |
@@ -98,21 +98,21 @@ discard block |
||
98 | 98 | * @param array $mapping List of domain item keys with the CSV field position as key |
99 | 99 | * @return array List of associative arrays containing the chunked properties |
100 | 100 | */ |
101 | - protected function getMappedChunk( array &$data, array $mapping ) |
|
101 | + protected function getMappedChunk(array &$data, array $mapping) |
|
102 | 102 | { |
103 | 103 | $idx = 0; |
104 | 104 | $map = []; |
105 | 105 | |
106 | - foreach( $mapping as $pos => $key ) |
|
106 | + foreach ($mapping as $pos => $key) |
|
107 | 107 | { |
108 | - if( isset( $map[$idx][$key] ) ) { |
|
108 | + if (isset($map[$idx][$key])) { |
|
109 | 109 | $idx++; |
110 | 110 | } |
111 | 111 | |
112 | - if( isset( $data[$pos] ) ) |
|
112 | + if (isset($data[$pos])) |
|
113 | 113 | { |
114 | 114 | $map[$idx][$key] = $data[$pos]; |
115 | - unset( $data[$pos] ); |
|
115 | + unset($data[$pos]); |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
@@ -126,37 +126,37 @@ discard block |
||
126 | 126 | * @param array $mappings Associative list of processor types as keys and index/data mappings as values |
127 | 127 | * @return \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface Processor object |
128 | 128 | */ |
129 | - protected function getProcessors( array $mappings ) |
|
129 | + protected function getProcessors(array $mappings) |
|
130 | 130 | { |
131 | 131 | $context = $this->getContext(); |
132 | 132 | $config = $context->getConfig(); |
133 | - $object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Done( $context, [] ); |
|
133 | + $object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Done($context, []); |
|
134 | 134 | |
135 | - foreach( $mappings as $type => $mapping ) |
|
135 | + foreach ($mappings as $type => $mapping) |
|
136 | 136 | { |
137 | - if( ctype_alnum( $type ) === false ) |
|
137 | + if (ctype_alnum($type) === false) |
|
138 | 138 | { |
139 | 139 | $classname = is_string($type) ? '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\' . $type : '<not a string>'; |
140 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
140 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
141 | 141 | } |
142 | 142 | |
143 | - $name = $config->get( 'controller/common/coupon/import/csv/processor/' . $type . '/name', 'Standard' ); |
|
143 | + $name = $config->get('controller/common/coupon/import/csv/processor/' . $type . '/name', 'Standard'); |
|
144 | 144 | |
145 | - if( ctype_alnum( $name ) === false ) |
|
145 | + if (ctype_alnum($name) === false) |
|
146 | 146 | { |
147 | 147 | $classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\' . $type . '\\' . $name : '<not a string>'; |
148 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
148 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
149 | 149 | } |
150 | 150 | |
151 | - $classname = '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\' . ucfirst( $type ) . '\\' . $name; |
|
151 | + $classname = '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\' . ucfirst($type) . '\\' . $name; |
|
152 | 152 | |
153 | - if( class_exists( $classname ) === false ) { |
|
154 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) ); |
|
153 | + if (class_exists($classname) === false) { |
|
154 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname)); |
|
155 | 155 | } |
156 | 156 | |
157 | - $object = new $classname( $context, $mapping, $object ); |
|
157 | + $object = new $classname($context, $mapping, $object); |
|
158 | 158 | |
159 | - \Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\Iface', $object ); |
|
159 | + \Aimeos\MW\Common\Base::checkClass('\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\Iface', $object); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | return $object; |
@@ -30,14 +30,14 @@ discard block |
||
30 | 30 | * @param array $data Associative list of catalog codes and lists of CSV field indexes and their data |
31 | 31 | * @return array Associative list of CSV field indexes and their converted data |
32 | 32 | */ |
33 | - protected function convertData( array $convlist, array $data ) |
|
33 | + protected function convertData(array $convlist, array $data) |
|
34 | 34 | { |
35 | - foreach( $convlist as $idx => $converter ) |
|
35 | + foreach ($convlist as $idx => $converter) |
|
36 | 36 | { |
37 | - foreach( $data as $code => $list ) |
|
37 | + foreach ($data as $code => $list) |
|
38 | 38 | { |
39 | - if( isset( $list[$idx] ) ) { |
|
40 | - $data[$code][$idx] = $converter->translate( $list[$idx] ); |
|
39 | + if (isset($list[$idx])) { |
|
40 | + $data[$code][$idx] = $converter->translate($list[$idx]); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | } |
@@ -53,36 +53,36 @@ discard block |
||
53 | 53 | * @param string|null Name of the cache implementation |
54 | 54 | * @return \Aimeos\Controller\Common\Catalog\Import\Csv\Cache\Iface Cache object |
55 | 55 | */ |
56 | - protected function getCache( $type, $name = null ) |
|
56 | + protected function getCache($type, $name = null) |
|
57 | 57 | { |
58 | 58 | $context = $this->getContext(); |
59 | 59 | $config = $context->getConfig(); |
60 | 60 | |
61 | - if( ctype_alnum( $type ) === false ) |
|
61 | + if (ctype_alnum($type) === false) |
|
62 | 62 | { |
63 | 63 | $classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Cache\\' . $type : '<not a string>'; |
64 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
64 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
65 | 65 | } |
66 | 66 | |
67 | - if( $name === null ) { |
|
68 | - $name = $config->get( 'controller/common/catalog/import/csv/cache/' . $type . '/name', 'Standard' ); |
|
67 | + if ($name === null) { |
|
68 | + $name = $config->get('controller/common/catalog/import/csv/cache/' . $type . '/name', 'Standard'); |
|
69 | 69 | } |
70 | 70 | |
71 | - if( ctype_alnum( $name ) === false ) |
|
71 | + if (ctype_alnum($name) === false) |
|
72 | 72 | { |
73 | 73 | $classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Cache\\' . $type . '\\' . $name : '<not a string>'; |
74 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
74 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
75 | 75 | } |
76 | 76 | |
77 | - $classname = '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Cache\\' . ucfirst( $type ) . '\\' . $name; |
|
77 | + $classname = '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Cache\\' . ucfirst($type) . '\\' . $name; |
|
78 | 78 | |
79 | - if( class_exists( $classname ) === false ) { |
|
80 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) ); |
|
79 | + if (class_exists($classname) === false) { |
|
80 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname)); |
|
81 | 81 | } |
82 | 82 | |
83 | - $object = new $classname( $context ); |
|
83 | + $object = new $classname($context); |
|
84 | 84 | |
85 | - \Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Cache\\Iface', $object ); |
|
85 | + \Aimeos\MW\Common\Base::checkClass('\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Cache\\Iface', $object); |
|
86 | 86 | |
87 | 87 | return $object; |
88 | 88 | } |
@@ -94,12 +94,12 @@ discard block |
||
94 | 94 | * @param array $convmap List of converter names for the values at the position in the CSV file |
95 | 95 | * @return array Associative list of positions and converter objects |
96 | 96 | */ |
97 | - protected function getConverterList( array $convmap ) |
|
97 | + protected function getConverterList(array $convmap) |
|
98 | 98 | { |
99 | 99 | $convlist = []; |
100 | 100 | |
101 | - foreach( $convmap as $idx => $name ) { |
|
102 | - $convlist[$idx] = \Aimeos\MW\Convert\Factory::createConverter( $name ); |
|
101 | + foreach ($convmap as $idx => $name) { |
|
102 | + $convlist[$idx] = \Aimeos\MW\Convert\Factory::createConverter($name); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | return $convlist; |
@@ -114,15 +114,15 @@ discard block |
||
114 | 114 | * @param integer $codePos Column position which contains the unique catalog code (starting from 0) |
115 | 115 | * @return array List of arrays with catalog codes as keys and list of values from the CSV file |
116 | 116 | */ |
117 | - protected function getData( \Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos ) |
|
117 | + protected function getData(\Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos) |
|
118 | 118 | { |
119 | 119 | $count = 0; |
120 | 120 | $data = []; |
121 | 121 | |
122 | - while( $content->valid() && $count++ < $maxcnt ) |
|
122 | + while ($content->valid() && $count++ < $maxcnt) |
|
123 | 123 | { |
124 | 124 | $row = $content->current(); |
125 | - $data[ $row[$codePos] ] = $row; |
|
125 | + $data[$row[$codePos]] = $row; |
|
126 | 126 | $content->next(); |
127 | 127 | } |
128 | 128 | |
@@ -178,21 +178,21 @@ discard block |
||
178 | 178 | * @param array $mapping List of domain item keys with the CSV field position as key |
179 | 179 | * @return array List of associative arrays containing the chunked properties |
180 | 180 | */ |
181 | - protected function getMappedChunk( array &$data, array $mapping ) |
|
181 | + protected function getMappedChunk(array &$data, array $mapping) |
|
182 | 182 | { |
183 | 183 | $idx = 0; |
184 | 184 | $map = []; |
185 | 185 | |
186 | - foreach( $mapping as $pos => $key ) |
|
186 | + foreach ($mapping as $pos => $key) |
|
187 | 187 | { |
188 | - if( isset( $map[$idx][$key] ) ) { |
|
188 | + if (isset($map[$idx][$key])) { |
|
189 | 189 | $idx++; |
190 | 190 | } |
191 | 191 | |
192 | - if( isset( $data[$pos] ) ) |
|
192 | + if (isset($data[$pos])) |
|
193 | 193 | { |
194 | 194 | $map[$idx][$key] = $data[$pos]; |
195 | - unset( $data[$pos] ); |
|
195 | + unset($data[$pos]); |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
@@ -206,37 +206,37 @@ discard block |
||
206 | 206 | * @param array $mappings Associative list of processor types as keys and index/data mappings as values |
207 | 207 | * @return \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface Processor object |
208 | 208 | */ |
209 | - protected function getProcessors( array $mappings ) |
|
209 | + protected function getProcessors(array $mappings) |
|
210 | 210 | { |
211 | 211 | $context = $this->getContext(); |
212 | 212 | $config = $context->getConfig(); |
213 | - $object = new \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Done( $context, [] ); |
|
213 | + $object = new \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Done($context, []); |
|
214 | 214 | |
215 | - foreach( $mappings as $type => $mapping ) |
|
215 | + foreach ($mappings as $type => $mapping) |
|
216 | 216 | { |
217 | - if( ctype_alnum( $type ) === false ) |
|
217 | + if (ctype_alnum($type) === false) |
|
218 | 218 | { |
219 | 219 | $classname = is_string($type) ? '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Processor\\' . $type : '<not a string>'; |
220 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
220 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
221 | 221 | } |
222 | 222 | |
223 | - $name = $config->get( 'controller/common/catalog/import/csv/processor/' . $type . '/name', 'Standard' ); |
|
223 | + $name = $config->get('controller/common/catalog/import/csv/processor/' . $type . '/name', 'Standard'); |
|
224 | 224 | |
225 | - if( ctype_alnum( $name ) === false ) |
|
225 | + if (ctype_alnum($name) === false) |
|
226 | 226 | { |
227 | 227 | $classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Processor\\' . $type . '\\' . $name : '<not a string>'; |
228 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
228 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
229 | 229 | } |
230 | 230 | |
231 | - $classname = '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Processor\\' . ucfirst( $type ) . '\\' . $name; |
|
231 | + $classname = '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Processor\\' . ucfirst($type) . '\\' . $name; |
|
232 | 232 | |
233 | - if( class_exists( $classname ) === false ) { |
|
234 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) ); |
|
233 | + if (class_exists($classname) === false) { |
|
234 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname)); |
|
235 | 235 | } |
236 | 236 | |
237 | - $object = new $classname( $context, $mapping, $object ); |
|
237 | + $object = new $classname($context, $mapping, $object); |
|
238 | 238 | |
239 | - \Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Processor\\Iface', $object ); |
|
239 | + \Aimeos\MW\Common\Base::checkClass('\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Processor\\Iface', $object); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | return $object; |
@@ -251,23 +251,23 @@ discard block |
||
251 | 251 | * @param string $code Unique code of the type item |
252 | 252 | * @return string Unique ID of the type item |
253 | 253 | */ |
254 | - protected function getTypeId( $path, $domain, $code ) |
|
254 | + protected function getTypeId($path, $domain, $code) |
|
255 | 255 | { |
256 | - if( !isset( self::$types[$path][$domain] ) ) |
|
256 | + if (!isset(self::$types[$path][$domain])) |
|
257 | 257 | { |
258 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $path ); |
|
259 | - $key = str_replace( '/', '.', $path ); |
|
258 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $path); |
|
259 | + $key = str_replace('/', '.', $path); |
|
260 | 260 | |
261 | 261 | $search = $manager->createSearch(); |
262 | - $search->setConditions( $search->compare( '==', $key . '.domain', $domain ) ); |
|
262 | + $search->setConditions($search->compare('==', $key . '.domain', $domain)); |
|
263 | 263 | |
264 | - foreach( $manager->searchItems( $search ) as $id => $item ) { |
|
265 | - self::$types[$path][$domain][ $item->getCode() ] = $id; |
|
264 | + foreach ($manager->searchItems($search) as $id => $item) { |
|
265 | + self::$types[$path][$domain][$item->getCode()] = $id; |
|
266 | 266 | } |
267 | 267 | } |
268 | 268 | |
269 | - if( !isset( self::$types[$path][$domain][$code] ) ) { |
|
270 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'No type item for "%1$s/%2$s" in "%3$s" found', $domain, $code, $path ) ); |
|
269 | + if (!isset(self::$types[$path][$domain][$code])) { |
|
270 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('No type item for "%1$s/%2$s" in "%3$s" found', $domain, $code, $path)); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | return self::$types[$path][$domain][$code]; |