@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | $context = \TestHelperJobs::getContext(); |
17 | 17 | $aimeos = \TestHelperJobs::getAimeos(); |
18 | 18 | |
19 | - $obj = \Aimeos\Controller\Jobs\Catalog\Import\Csv\Factory::createController( $context, $aimeos ); |
|
20 | - $this->assertInstanceOf( '\\Aimeos\\Controller\\Jobs\\Iface', $obj); |
|
19 | + $obj = \Aimeos\Controller\Jobs\Catalog\Import\Csv\Factory::createController($context, $aimeos); |
|
20 | + $this->assertInstanceOf('\\Aimeos\\Controller\\Jobs\\Iface', $obj); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | $context = \TestHelperJobs::getContext(); |
27 | 27 | $aimeos = \TestHelperJobs::getAimeos(); |
28 | 28 | |
29 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
30 | - \Aimeos\Controller\Jobs\Catalog\Import\Csv\Factory::createController( $context, $aimeos, 'Wrong$$$Name' ); |
|
29 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
30 | + \Aimeos\Controller\Jobs\Catalog\Import\Csv\Factory::createController($context, $aimeos, 'Wrong$$$Name'); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | $context = \TestHelperJobs::getContext(); |
37 | 37 | $aimeos = \TestHelperJobs::getAimeos(); |
38 | 38 | |
39 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
40 | - \Aimeos\Controller\Jobs\Catalog\Import\Csv\Factory::createController( $context, $aimeos, 'WrongClass' ); |
|
39 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
40 | + \Aimeos\Controller\Jobs\Catalog\Import\Csv\Factory::createController($context, $aimeos, 'WrongClass'); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | $context = \TestHelperJobs::getContext(); |
47 | 47 | $aimeos = \TestHelperJobs::getAimeos(); |
48 | 48 | |
49 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
50 | - \Aimeos\Controller\Jobs\Catalog\Import\Csv\Factory::createController( $context, $aimeos, 'Factory' ); |
|
49 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
50 | + \Aimeos\Controller\Jobs\Catalog\Import\Csv\Factory::createController($context, $aimeos, 'Factory'); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | \ No newline at end of file |
@@ -18,65 +18,65 @@ discard block |
||
18 | 18 | |
19 | 19 | protected function setUp() |
20 | 20 | { |
21 | - \Aimeos\MShop\Factory::setCache( true ); |
|
21 | + \Aimeos\MShop\Factory::setCache(true); |
|
22 | 22 | |
23 | 23 | $this->context = \TestHelperJobs::getContext(); |
24 | 24 | $this->aimeos = \TestHelperJobs::getAimeos(); |
25 | 25 | $config = $this->context->getConfig(); |
26 | 26 | |
27 | - $config->set( 'controller/jobs/catalog/import/csv/skip-lines', 1 ); |
|
28 | - $config->set( 'controller/jobs/catalog/import/csv/location', __DIR__ . '/_testfiles/valid' ); |
|
27 | + $config->set('controller/jobs/catalog/import/csv/skip-lines', 1); |
|
28 | + $config->set('controller/jobs/catalog/import/csv/location', __DIR__ . '/_testfiles/valid'); |
|
29 | 29 | |
30 | - $this->object = new \Aimeos\Controller\Jobs\Catalog\Import\Csv\Standard( $this->context, $this->aimeos ); |
|
30 | + $this->object = new \Aimeos\Controller\Jobs\Catalog\Import\Csv\Standard($this->context, $this->aimeos); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
34 | 34 | protected function tearDown() |
35 | 35 | { |
36 | - \Aimeos\MShop\Factory::setCache( false ); |
|
36 | + \Aimeos\MShop\Factory::setCache(false); |
|
37 | 37 | \Aimeos\MShop\Factory::clear(); |
38 | 38 | |
39 | 39 | $this->object = null; |
40 | 40 | |
41 | - if( file_exists( 'tmp/import.zip' ) ) { |
|
42 | - unlink( 'tmp/import.zip' ); |
|
41 | + if (file_exists('tmp/import.zip')) { |
|
42 | + unlink('tmp/import.zip'); |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
46 | 46 | |
47 | 47 | public function testGetName() |
48 | 48 | { |
49 | - $this->assertEquals( 'Catalog import CSV', $this->object->getName() ); |
|
49 | + $this->assertEquals('Catalog import CSV', $this->object->getName()); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | |
53 | 53 | public function testGetDescription() |
54 | 54 | { |
55 | 55 | $text = 'Imports new and updates existing categories from CSV files'; |
56 | - $this->assertEquals( $text, $this->object->getDescription() ); |
|
56 | + $this->assertEquals($text, $this->object->getDescription()); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | |
60 | 60 | public function testRun() |
61 | 61 | { |
62 | - $catcodes = array( 'job_csv_test', 'job_csv_test2', 'job_csv_test3', 'job_csv_test4' ); |
|
63 | - $domains = array( 'media', 'text' ); |
|
62 | + $catcodes = array('job_csv_test', 'job_csv_test2', 'job_csv_test3', 'job_csv_test4'); |
|
63 | + $domains = array('media', 'text'); |
|
64 | 64 | |
65 | 65 | $convert = array( |
66 | 66 | 1 => 'Text/LatinUTF8', |
67 | 67 | ); |
68 | 68 | |
69 | - $this->context->getConfig()->set( 'controller/jobs/catalog/import/csv/converter', $convert ); |
|
69 | + $this->context->getConfig()->set('controller/jobs/catalog/import/csv/converter', $convert); |
|
70 | 70 | |
71 | 71 | $this->object->run(); |
72 | 72 | |
73 | - $tree = $this->get( 'job_csv_test', $domains ); |
|
74 | - $this->delete( $tree, $domains ); |
|
73 | + $tree = $this->get('job_csv_test', $domains); |
|
74 | + $this->delete($tree, $domains); |
|
75 | 75 | |
76 | - $this->assertEquals( 2, count( $tree->getListItems() ) ); |
|
76 | + $this->assertEquals(2, count($tree->getListItems())); |
|
77 | 77 | |
78 | - foreach( $tree->getChildren() as $node ) { |
|
79 | - $this->assertEquals( 2, count( $node->getListItems() ) ); |
|
78 | + foreach ($tree->getChildren() as $node) { |
|
79 | + $this->assertEquals(2, count($node->getListItems())); |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
@@ -86,13 +86,13 @@ discard block |
||
86 | 86 | $this->object->run(); |
87 | 87 | $this->object->run(); |
88 | 88 | |
89 | - $tree = $this->get( 'job_csv_test', ['media', 'text'] ); |
|
90 | - $this->delete( $tree, ['media', 'text'] ); |
|
89 | + $tree = $this->get('job_csv_test', ['media', 'text']); |
|
90 | + $this->delete($tree, ['media', 'text']); |
|
91 | 91 | |
92 | - $this->assertEquals( 2, count( $tree->getListItems() ) ); |
|
92 | + $this->assertEquals(2, count($tree->getListItems())); |
|
93 | 93 | |
94 | - foreach( $tree->getChildren() as $node ) { |
|
95 | - $this->assertEquals( 2, count( $node->getListItems() ) ); |
|
94 | + foreach ($tree->getChildren() as $node) { |
|
95 | + $this->assertEquals(2, count($node->getListItems())); |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
@@ -100,18 +100,18 @@ discard block |
||
100 | 100 | public function testRunPosition() |
101 | 101 | { |
102 | 102 | $config = $this->context->getConfig(); |
103 | - $mapping = $config->set( 'controller/jobs/catalog/import/csv/mapping', [] ); |
|
104 | - $mapping['item'] = array( 0 => 'catalog.label', 1 => 'catalog.code', 2 => 'catalog.parent' ); |
|
103 | + $mapping = $config->set('controller/jobs/catalog/import/csv/mapping', []); |
|
104 | + $mapping['item'] = array(0 => 'catalog.label', 1 => 'catalog.code', 2 => 'catalog.parent'); |
|
105 | 105 | |
106 | - $config->set( 'controller/jobs/catalog/import/csv/mapping', $mapping ); |
|
107 | - $config->set( 'controller/jobs/catalog/import/csv/location', __DIR__ . '/_testfiles/position' ); |
|
106 | + $config->set('controller/jobs/catalog/import/csv/mapping', $mapping); |
|
107 | + $config->set('controller/jobs/catalog/import/csv/location', __DIR__ . '/_testfiles/position'); |
|
108 | 108 | |
109 | 109 | $this->object->run(); |
110 | 110 | |
111 | - $tree = $this->get( 'job_csv_test' ); |
|
112 | - $this->delete( $tree ); |
|
111 | + $tree = $this->get('job_csv_test'); |
|
112 | + $this->delete($tree); |
|
113 | 113 | |
114 | - $this->assertEquals( 1, count( $tree->getChildren() ) ); |
|
114 | + $this->assertEquals(1, count($tree->getChildren())); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | |
@@ -135,12 +135,12 @@ discard block |
||
135 | 135 | ), |
136 | 136 | ); |
137 | 137 | |
138 | - $this->context->getConfig()->set( 'controller/jobs/catalog/import/csv/mapping', $mapping ); |
|
138 | + $this->context->getConfig()->set('controller/jobs/catalog/import/csv/mapping', $mapping); |
|
139 | 139 | |
140 | 140 | $this->object->run(); |
141 | 141 | |
142 | - $tree = $this->get( 'job_csv_test' ); |
|
143 | - $this->delete( $tree ); |
|
142 | + $tree = $this->get('job_csv_test'); |
|
143 | + $this->delete($tree); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | ), |
153 | 153 | ); |
154 | 154 | |
155 | - $this->context->getConfig()->set( 'controller/jobs/catalog/import/csv/mapping', $mapping ); |
|
155 | + $this->context->getConfig()->set('controller/jobs/catalog/import/csv/mapping', $mapping); |
|
156 | 156 | |
157 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
157 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
158 | 158 | $this->object->run(); |
159 | 159 | } |
160 | 160 | |
@@ -178,15 +178,15 @@ discard block |
||
178 | 178 | ), |
179 | 179 | ); |
180 | 180 | |
181 | - $this->context->getConfig()->set( 'controller/jobs/catalog/import/csv/mapping', $mapping ); |
|
181 | + $this->context->getConfig()->set('controller/jobs/catalog/import/csv/mapping', $mapping); |
|
182 | 182 | |
183 | 183 | $config = $this->context->getConfig(); |
184 | - $config->set( 'controller/jobs/catalog/import/csv/skip-lines', 0 ); |
|
185 | - $config->set( 'controller/jobs/catalog/import/csv/location', __DIR__ . '/_testfiles/invalid' ); |
|
184 | + $config->set('controller/jobs/catalog/import/csv/skip-lines', 0); |
|
185 | + $config->set('controller/jobs/catalog/import/csv/location', __DIR__ . '/_testfiles/invalid'); |
|
186 | 186 | |
187 | - $this->object = new \Aimeos\Controller\Jobs\Catalog\Import\Csv\Standard( $this->context, $this->aimeos ); |
|
187 | + $this->object = new \Aimeos\Controller\Jobs\Catalog\Import\Csv\Standard($this->context, $this->aimeos); |
|
188 | 188 | |
189 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
189 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
190 | 190 | $this->object->run(); |
191 | 191 | } |
192 | 192 | |
@@ -194,65 +194,65 @@ discard block |
||
194 | 194 | public function testRunBackup() |
195 | 195 | { |
196 | 196 | $config = $this->context->getConfig(); |
197 | - $config->set( 'controller/jobs/catalog/import/csv/container/type', 'Zip' ); |
|
198 | - $config->set( 'controller/jobs/catalog/import/csv/location', 'tmp/import.zip' ); |
|
199 | - $config->set( 'controller/jobs/catalog/import/csv/backup', 'tmp/test-%Y-%m-%d.zip' ); |
|
197 | + $config->set('controller/jobs/catalog/import/csv/container/type', 'Zip'); |
|
198 | + $config->set('controller/jobs/catalog/import/csv/location', 'tmp/import.zip'); |
|
199 | + $config->set('controller/jobs/catalog/import/csv/backup', 'tmp/test-%Y-%m-%d.zip'); |
|
200 | 200 | |
201 | - if( copy( __DIR__ . '/_testfiles/import.zip', 'tmp/import.zip' ) === false ) { |
|
202 | - throw new \RuntimeException( 'Unable to copy test file' ); |
|
201 | + if (copy(__DIR__ . '/_testfiles/import.zip', 'tmp/import.zip') === false) { |
|
202 | + throw new \RuntimeException('Unable to copy test file'); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | $this->object->run(); |
206 | 206 | |
207 | - $filename = strftime( 'tmp/test-%Y-%m-%d.zip' ); |
|
208 | - $this->assertTrue( file_exists( $filename ) ); |
|
207 | + $filename = strftime('tmp/test-%Y-%m-%d.zip'); |
|
208 | + $this->assertTrue(file_exists($filename)); |
|
209 | 209 | |
210 | - unlink( $filename ); |
|
210 | + unlink($filename); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | |
214 | 214 | public function testRunBackupInvalid() |
215 | 215 | { |
216 | 216 | $config = $this->context->getConfig(); |
217 | - $config->set( 'controller/jobs/catalog/import/csv/container/type', 'Zip' ); |
|
218 | - $config->set( 'controller/jobs/catalog/import/csv/location', 'tmp/import.zip' ); |
|
219 | - $config->set( 'controller/jobs/catalog/import/csv/backup', 'tmp/notexist/import.zip' ); |
|
217 | + $config->set('controller/jobs/catalog/import/csv/container/type', 'Zip'); |
|
218 | + $config->set('controller/jobs/catalog/import/csv/location', 'tmp/import.zip'); |
|
219 | + $config->set('controller/jobs/catalog/import/csv/backup', 'tmp/notexist/import.zip'); |
|
220 | 220 | |
221 | - if( copy( __DIR__ . '/_testfiles/import.zip', 'tmp/import.zip' ) === false ) { |
|
222 | - throw new \RuntimeException( 'Unable to copy test file' ); |
|
221 | + if (copy(__DIR__ . '/_testfiles/import.zip', 'tmp/import.zip') === false) { |
|
222 | + throw new \RuntimeException('Unable to copy test file'); |
|
223 | 223 | } |
224 | 224 | |
225 | - $this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
225 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
226 | 226 | $this->object->run(); |
227 | 227 | } |
228 | 228 | |
229 | 229 | |
230 | - protected function delete( \Aimeos\MShop\Catalog\Item\Iface $tree, array $domains = [] ) |
|
230 | + protected function delete(\Aimeos\MShop\Catalog\Item\Iface $tree, array $domains = []) |
|
231 | 231 | { |
232 | - $catalogManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager( $this->context ); |
|
232 | + $catalogManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager($this->context); |
|
233 | 233 | |
234 | - foreach( $domains as $domain ) |
|
234 | + foreach ($domains as $domain) |
|
235 | 235 | { |
236 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, $domain ); |
|
236 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, $domain); |
|
237 | 237 | |
238 | - foreach( $tree->getListItems( $domain ) as $listItem ) { |
|
239 | - $manager->deleteItem( $listItem->getRefItem()->getId() ); |
|
238 | + foreach ($tree->getListItems($domain) as $listItem) { |
|
239 | + $manager->deleteItem($listItem->getRefItem()->getId()); |
|
240 | 240 | } |
241 | 241 | } |
242 | 242 | |
243 | - foreach( $tree->getChildren() as $node ) { |
|
244 | - $this->delete( $node, $domains ); |
|
243 | + foreach ($tree->getChildren() as $node) { |
|
244 | + $this->delete($node, $domains); |
|
245 | 245 | } |
246 | 246 | |
247 | - $catalogManager->deleteItem( $tree->getId() ); |
|
247 | + $catalogManager->deleteItem($tree->getId()); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | |
251 | - protected function get( $catcode, array $domains = [] ) |
|
251 | + protected function get($catcode, array $domains = []) |
|
252 | 252 | { |
253 | - $manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager( $this->context ); |
|
254 | - $root = $manager->findItem( $catcode ); |
|
253 | + $manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager($this->context); |
|
254 | + $root = $manager->findItem($catcode); |
|
255 | 255 | |
256 | - return $manager->getTree( $root->getId(), $domains, \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE ); |
|
256 | + return $manager->getTree($root->getId(), $domains, \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE); |
|
257 | 257 | } |
258 | 258 | } |
259 | 259 | \ No newline at end of file |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @param string|null $name Name of the controller or "Standard" if null |
30 | 30 | * @return \Aimeos\Controller\Jobs\Iface New controller object |
31 | 31 | */ |
32 | - public static function createController( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $name = null ) |
|
32 | + public static function createController(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $name = null) |
|
33 | 33 | { |
34 | 34 | /** controller/jobs/catalog/import/csv/name |
35 | 35 | * Class name of the used catalog suggestions scheduler controller implementation |
@@ -64,20 +64,20 @@ discard block |
||
64 | 64 | * @since 2018.04 |
65 | 65 | * @category Developer |
66 | 66 | */ |
67 | - if ( $name === null ) { |
|
67 | + if ($name === null) { |
|
68 | 68 | $name = $context->getConfig()->get('controller/jobs/catalog/import/csv/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\\Jobs\\Catalog\\Import\\Csv\\' . $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 | 77 | $iface = '\\Aimeos\\Controller\\Jobs\\Iface'; |
78 | 78 | $classname = '\\Aimeos\\Controller\\Jobs\\Catalog\\Import\\Csv\\' . $name; |
79 | 79 | |
80 | - $controller = self::createControllerBase( $context, $aimeos, $classname, $iface ); |
|
80 | + $controller = self::createControllerBase($context, $aimeos, $classname, $iface); |
|
81 | 81 | |
82 | 82 | /** controller/jobs/catalog/import/csv/decorators/excludes |
83 | 83 | * Excludes decorators added by the "common" option from the catalog import CSV job controller |
@@ -154,6 +154,6 @@ discard block |
||
154 | 154 | * @see controller/jobs/catalog/import/csv/decorators/excludes |
155 | 155 | * @see controller/jobs/catalog/import/csv/decorators/global |
156 | 156 | */ |
157 | - return self::addControllerDecorators( $context, $aimeos, $controller, 'catalog/import/csv' ); |
|
157 | + return self::addControllerDecorators($context, $aimeos, $controller, 'catalog/import/csv'); |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | \ No newline at end of file |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function getName() |
30 | 30 | { |
31 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Catalog import CSV' ); |
|
31 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Catalog import CSV'); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function getDescription() |
41 | 41 | { |
42 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Imports new and updates existing categories from CSV files' ); |
|
42 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Imports new and updates existing categories from CSV files'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $context = $this->getContext(); |
55 | 55 | $config = $context->getConfig(); |
56 | 56 | $logger = $context->getLogger(); |
57 | - $domains = array( 'media', 'text' ); |
|
57 | + $domains = array('media', 'text'); |
|
58 | 58 | $mappings = $this->getDefaultMapping(); |
59 | 59 | |
60 | 60 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @see controller/common/catalog/import/csv/converter |
75 | 75 | * @see controller/common/catalog/import/csv/max-size |
76 | 76 | */ |
77 | - $domains = $config->get( 'controller/common/catalog/import/csv/domains', $domains ); |
|
77 | + $domains = $config->get('controller/common/catalog/import/csv/domains', $domains); |
|
78 | 78 | |
79 | 79 | /** controller/jobs/catalog/import/csv/domains |
80 | 80 | * List of item domain names that should be retrieved along with the catalog items |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @see controller/jobs/catalog/import/csv/backup |
95 | 95 | * @see controller/common/catalog/import/csv/max-size |
96 | 96 | */ |
97 | - $domains = $config->get( 'controller/jobs/catalog/import/csv/domains', $domains ); |
|
97 | + $domains = $config->get('controller/jobs/catalog/import/csv/domains', $domains); |
|
98 | 98 | |
99 | 99 | |
100 | 100 | /** controller/common/catalog/import/csv/mapping |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * @see controller/common/catalog/import/csv/converter |
123 | 123 | * @see controller/common/catalog/import/csv/max-size |
124 | 124 | */ |
125 | - $mappings = $config->get( 'controller/common/catalog/import/csv/mapping', $mappings ); |
|
125 | + $mappings = $config->get('controller/common/catalog/import/csv/mapping', $mappings); |
|
126 | 126 | |
127 | 127 | /** controller/jobs/catalog/import/csv/mapping |
128 | 128 | * List of mappings between the position in the CSV file and item keys |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @see controller/jobs/catalog/import/csv/backup |
143 | 143 | * @see controller/common/catalog/import/csv/max-size |
144 | 144 | */ |
145 | - $mappings = $config->get( 'controller/jobs/catalog/import/csv/mapping', $mappings ); |
|
145 | + $mappings = $config->get('controller/jobs/catalog/import/csv/mapping', $mappings); |
|
146 | 146 | |
147 | 147 | |
148 | 148 | /** controller/common/catalog/import/csv/converter |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | * @see controller/common/catalog/import/csv/mapping |
185 | 185 | * @see controller/common/catalog/import/csv/max-size |
186 | 186 | */ |
187 | - $converters = $config->get( 'controller/common/catalog/import/csv/converter', [] ); |
|
187 | + $converters = $config->get('controller/common/catalog/import/csv/converter', []); |
|
188 | 188 | |
189 | 189 | /** controller/jobs/catalog/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 |
||
204 | 204 | * @see controller/jobs/catalog/import/csv/backup |
205 | 205 | * @see controller/common/catalog/import/csv/max-size |
206 | 206 | */ |
207 | - $converters = $config->get( 'controller/jobs/catalog/import/csv/converter', $converters ); |
|
207 | + $converters = $config->get('controller/jobs/catalog/import/csv/converter', $converters); |
|
208 | 208 | |
209 | 209 | |
210 | 210 | /** controller/common/catalog/import/csv/max-size |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * @see controller/common/catalog/import/csv/mapping |
225 | 225 | * @see controller/common/catalog/import/csv/converter |
226 | 226 | */ |
227 | - $maxcnt = (int) $config->get( 'controller/common/catalog/import/csv/max-size', 1000 ); |
|
227 | + $maxcnt = (int) $config->get('controller/common/catalog/import/csv/max-size', 1000); |
|
228 | 228 | |
229 | 229 | |
230 | 230 | /** controller/jobs/catalog/import/csv/skip-lines |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * @see controller/jobs/catalog/import/csv/backup |
247 | 247 | * @see controller/common/catalog/import/csv/max-size |
248 | 248 | */ |
249 | - $skiplines = (int) $config->get( 'controller/jobs/catalog/import/csv/skip-lines', 0 ); |
|
249 | + $skiplines = (int) $config->get('controller/jobs/catalog/import/csv/skip-lines', 0); |
|
250 | 250 | |
251 | 251 | |
252 | 252 | /** controller/jobs/catalog/import/csv/strict |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @see controller/jobs/catalog/import/csv/backup |
271 | 271 | * @see controller/common/catalog/import/csv/max-size |
272 | 272 | */ |
273 | - $strict = (bool) $config->get( 'controller/jobs/catalog/import/csv/strict', true ); |
|
273 | + $strict = (bool) $config->get('controller/jobs/catalog/import/csv/strict', true); |
|
274 | 274 | |
275 | 275 | |
276 | 276 | /** controller/jobs/catalog/import/csv/backup |
@@ -303,75 +303,75 @@ discard block |
||
303 | 303 | * @see controller/jobs/catalog/import/csv/strict |
304 | 304 | * @see controller/common/catalog/import/csv/max-size |
305 | 305 | */ |
306 | - $backup = $config->get( 'controller/jobs/catalog/import/csv/backup' ); |
|
306 | + $backup = $config->get('controller/jobs/catalog/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 ); |
|
323 | - $catalogMap = $this->getCatalogMap( $domains ); |
|
320 | + $codePos = $this->getCodePosition($mappings['item']); |
|
321 | + $convlist = $this->getConverterList($converters); |
|
322 | + $processor = $this->getProcessors($procMappings); |
|
323 | + $catalogMap = $this->getCatalogMap($domains); |
|
324 | 324 | $container = $this->getContainer(); |
325 | 325 | $path = $container->getName(); |
326 | 326 | |
327 | 327 | |
328 | - $msg = sprintf( 'Started catalog import from "%1$s" (%2$s)', $path, __CLASS__ ); |
|
329 | - $logger->log( $msg, \Aimeos\MW\Logger\Base::NOTICE ); |
|
328 | + $msg = sprintf('Started catalog import from "%1$s" (%2$s)', $path, __CLASS__); |
|
329 | + $logger->log($msg, \Aimeos\MW\Logger\Base::NOTICE); |
|
330 | 330 | |
331 | - foreach( $container as $content ) |
|
331 | + foreach ($container as $content) |
|
332 | 332 | { |
333 | 333 | $name = $content->getName(); |
334 | 334 | |
335 | - for( $i = 0; $i < $skiplines; $i++ ) { |
|
335 | + for ($i = 0; $i < $skiplines; $i++) { |
|
336 | 336 | $content->next(); |
337 | 337 | } |
338 | 338 | |
339 | - while( ( $data = $this->getData( $content, $maxcnt, $codePos ) ) !== [] ) |
|
339 | + while (($data = $this->getData($content, $maxcnt, $codePos)) !== []) |
|
340 | 340 | { |
341 | - $data = $this->convertData( $convlist, $data ); |
|
342 | - $errcnt = $this->import( $catalogMap, $data, $mappings['item'], $processor, $strict ); |
|
343 | - $chunkcnt = count( $data ); |
|
341 | + $data = $this->convertData($convlist, $data); |
|
342 | + $errcnt = $this->import($catalogMap, $data, $mappings['item'], $processor, $strict); |
|
343 | + $chunkcnt = count($data); |
|
344 | 344 | |
345 | 345 | $msg = 'Imported catalog lines from "%1$s": %2$d/%3$d (%4$s)'; |
346 | - $logger->log( sprintf( $msg, $name, $chunkcnt - $errcnt, $chunkcnt, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE ); |
|
346 | + $logger->log(sprintf($msg, $name, $chunkcnt - $errcnt, $chunkcnt, __CLASS__), \Aimeos\MW\Logger\Base::NOTICE); |
|
347 | 347 | |
348 | 348 | $errors += $errcnt; |
349 | 349 | $total += $chunkcnt; |
350 | - unset( $data ); |
|
350 | + unset($data); |
|
351 | 351 | } |
352 | 352 | } |
353 | 353 | |
354 | 354 | $container->close(); |
355 | 355 | } |
356 | - catch( \Exception $e ) |
|
356 | + catch (\Exception $e) |
|
357 | 357 | { |
358 | - $logger->log( 'Catalog import error: ' . $e->getMessage() ); |
|
359 | - $logger->log( $e->getTraceAsString() ); |
|
358 | + $logger->log('Catalog import error: ' . $e->getMessage()); |
|
359 | + $logger->log($e->getTraceAsString()); |
|
360 | 360 | |
361 | - throw new \Aimeos\Controller\Jobs\Exception( $e->getMessage() ); |
|
361 | + throw new \Aimeos\Controller\Jobs\Exception($e->getMessage()); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | $msg = 'Finished catalog import from "%1$s": %2$d successful, %3$s errors, %4$s total (%5$s)'; |
365 | - $logger->log( sprintf( $msg, $path, $total - $errors, $errors, $total, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE ); |
|
365 | + $logger->log(sprintf($msg, $path, $total - $errors, $errors, $total, __CLASS__), \Aimeos\MW\Logger\Base::NOTICE); |
|
366 | 366 | |
367 | - if( $errors > 0 ) |
|
367 | + if ($errors > 0) |
|
368 | 368 | { |
369 | - $msg = sprintf( 'Invalid catalog lines in "%1$s": %2$d/%3$d', $path, $errors, $total ); |
|
370 | - throw new \Aimeos\Controller\Jobs\Exception( $msg ); |
|
369 | + $msg = sprintf('Invalid catalog lines in "%1$s": %2$d/%3$d', $path, $errors, $total); |
|
370 | + throw new \Aimeos\Controller\Jobs\Exception($msg); |
|
371 | 371 | } |
372 | 372 | |
373 | - if( !empty( $backup ) && @rename( $path, strftime( $backup ) ) === false ) { |
|
374 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Unable to move imported file' ) ); |
|
373 | + if (!empty($backup) && @rename($path, strftime($backup)) === false) { |
|
374 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('Unable to move imported file')); |
|
375 | 375 | } |
376 | 376 | } |
377 | 377 | |
@@ -383,16 +383,16 @@ discard block |
||
383 | 383 | * @return integer Position of the "catalog.code" column |
384 | 384 | * @throws \Aimeos\Controller\Jobs\Exception If no mapping for "catalog.code" is found |
385 | 385 | */ |
386 | - protected function getCodePosition( array $mapping ) |
|
386 | + protected function getCodePosition(array $mapping) |
|
387 | 387 | { |
388 | - foreach( $mapping as $pos => $key ) |
|
388 | + foreach ($mapping as $pos => $key) |
|
389 | 389 | { |
390 | - if( $key === 'catalog.code' ) { |
|
390 | + if ($key === 'catalog.code') { |
|
391 | 391 | return $pos; |
392 | 392 | } |
393 | 393 | } |
394 | 394 | |
395 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'No "catalog.code" column in CSV mapping found' ) ); |
|
395 | + throw new \Aimeos\Controller\Jobs\Exception(sprintf('No "catalog.code" column in CSV mapping found')); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | * @see controller/jobs/catalog/import/csv/container/content |
428 | 428 | * @see controller/jobs/catalog/import/csv/container/options |
429 | 429 | */ |
430 | - $location = $config->get( 'controller/jobs/catalog/import/csv/location', '.' ); |
|
430 | + $location = $config->get('controller/jobs/catalog/import/csv/location', '.'); |
|
431 | 431 | |
432 | 432 | /** controller/jobs/catalog/import/csv/container/type |
433 | 433 | * Nave of the container type to read the data from |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | * @see controller/jobs/catalog/import/csv/container/content |
451 | 451 | * @see controller/jobs/catalog/import/csv/container/options |
452 | 452 | */ |
453 | - $container = $config->get( 'controller/jobs/catalog/import/csv/container/type', 'Directory' ); |
|
453 | + $container = $config->get('controller/jobs/catalog/import/csv/container/type', 'Directory'); |
|
454 | 454 | |
455 | 455 | /** controller/jobs/catalog/import/csv/container/content |
456 | 456 | * Name of the content type inside the container to read the data from |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | * @see controller/jobs/catalog/import/csv/container/type |
472 | 472 | * @see controller/jobs/catalog/import/csv/container/options |
473 | 473 | */ |
474 | - $content = $config->get( 'controller/jobs/catalog/import/csv/container/content', 'CSV' ); |
|
474 | + $content = $config->get('controller/jobs/catalog/import/csv/container/content', 'CSV'); |
|
475 | 475 | |
476 | 476 | /** controller/jobs/catalog/import/csv/container/options |
477 | 477 | * List of file container options for the catalog import files |
@@ -489,9 +489,9 @@ discard block |
||
489 | 489 | * @see controller/jobs/catalog/import/csv/container/content |
490 | 490 | * @see controller/jobs/catalog/import/csv/container/type |
491 | 491 | */ |
492 | - $options = $config->get( 'controller/jobs/catalog/import/csv/container/options', [] ); |
|
492 | + $options = $config->get('controller/jobs/catalog/import/csv/container/options', []); |
|
493 | 493 | |
494 | - return \Aimeos\MW\Container\Factory::getContainer( $location, $container, $content, $options ); |
|
494 | + return \Aimeos\MW\Container\Factory::getContainer($location, $container, $content, $options); |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | |
@@ -501,13 +501,13 @@ discard block |
||
501 | 501 | * @param array $domains List of domain names whose items should be fetched too |
502 | 502 | * @return array Associative list of catalog codes as keys and items implementing \Aimeos\MShop\Catalog\Item\Iface as values |
503 | 503 | */ |
504 | - protected function getCatalogMap( array $domains ) |
|
504 | + protected function getCatalogMap(array $domains) |
|
505 | 505 | { |
506 | 506 | $map = []; |
507 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog' ); |
|
508 | - $search = $manager->createSearch()->setSlice( 0, 0x7fffffff ); |
|
507 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog'); |
|
508 | + $search = $manager->createSearch()->setSlice(0, 0x7fffffff); |
|
509 | 509 | |
510 | - foreach( $manager->searchItems( $search, $domains ) as $item ) { |
|
510 | + foreach ($manager->searchItems($search, $domains) as $item) { |
|
511 | 511 | $map[$item->getCode()] = $item; |
512 | 512 | } |
513 | 513 | |
@@ -523,21 +523,21 @@ discard block |
||
523 | 523 | * @param string $code Catalog item code of the parent category |
524 | 524 | * @return string|null ID of the parent category or null for top level nodes |
525 | 525 | */ |
526 | - protected function getParentId( array $catalogMap, array $map, $code ) |
|
526 | + protected function getParentId(array $catalogMap, array $map, $code) |
|
527 | 527 | { |
528 | - if( !isset( $map['catalog.parent'] ) ) |
|
528 | + if (!isset($map['catalog.parent'])) |
|
529 | 529 | { |
530 | - $msg = sprintf( 'Required column "%1$s" not found for code "%2$s"', 'catalog.parent', $code ); |
|
531 | - throw new \Aimeos\Controller\Jobs\Exception( $msg ); |
|
530 | + $msg = sprintf('Required column "%1$s" not found for code "%2$s"', 'catalog.parent', $code); |
|
531 | + throw new \Aimeos\Controller\Jobs\Exception($msg); |
|
532 | 532 | } |
533 | 533 | |
534 | - if( $map['catalog.parent'] != '' && !isset( $catalogMap[$map['catalog.parent']] ) ) |
|
534 | + if ($map['catalog.parent'] != '' && !isset($catalogMap[$map['catalog.parent']])) |
|
535 | 535 | { |
536 | - $msg = sprintf( 'Parent node for code "%1$s" not found', $map['catalog.parent'] ); |
|
537 | - throw new \Aimeos\Controller\Jobs\Exception( $msg ); |
|
536 | + $msg = sprintf('Parent node for code "%1$s" not found', $map['catalog.parent']); |
|
537 | + throw new \Aimeos\Controller\Jobs\Exception($msg); |
|
538 | 538 | } |
539 | 539 | |
540 | - return ( $map['catalog.parent'] != '' ? $catalogMap[$map['catalog.parent']]->getId() : null ); |
|
540 | + return ($map['catalog.parent'] != '' ? $catalogMap[$map['catalog.parent']]->getId() : null); |
|
541 | 541 | } |
542 | 542 | |
543 | 543 | |
@@ -552,61 +552,61 @@ discard block |
||
552 | 552 | * @return integer Number of catalogs that couldn't be imported |
553 | 553 | * @throws \Aimeos\Controller\Jobs\Exception |
554 | 554 | */ |
555 | - protected function import( array &$catalogMap, array $data, array $mapping, |
|
556 | - \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $processor, $strict ) |
|
555 | + protected function import(array &$catalogMap, array $data, array $mapping, |
|
556 | + \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $processor, $strict) |
|
557 | 557 | { |
558 | 558 | $errors = 0; |
559 | 559 | $context = $this->getContext(); |
560 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'catalog' ); |
|
560 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'catalog'); |
|
561 | 561 | |
562 | - foreach( $data as $code => $list ) |
|
562 | + foreach ($data as $code => $list) |
|
563 | 563 | { |
564 | 564 | $manager->begin(); |
565 | 565 | |
566 | 566 | try |
567 | 567 | { |
568 | - if( isset( $catalogMap[$code] ) ) { |
|
568 | + if (isset($catalogMap[$code])) { |
|
569 | 569 | $catalogItem = $catalogMap[$code]; |
570 | 570 | } else { |
571 | 571 | $catalogItem = $manager->createItem(); |
572 | 572 | } |
573 | 573 | |
574 | - $map = $this->getMappedChunk( $list, $mapping ); |
|
574 | + $map = $this->getMappedChunk($list, $mapping); |
|
575 | 575 | |
576 | - if( isset( $map[0] ) ) |
|
576 | + if (isset($map[0])) |
|
577 | 577 | { |
578 | 578 | $map = $map[0]; // there can only be one chunk for the base catalog data |
579 | - $parentid = $this->getParentId( $catalogMap, $map, $code ); |
|
580 | - $catalogItem->fromArray( $this->addItemDefaults( $map ) ); |
|
579 | + $parentid = $this->getParentId($catalogMap, $map, $code); |
|
580 | + $catalogItem->fromArray($this->addItemDefaults($map)); |
|
581 | 581 | |
582 | - if( isset( $catalogMap[$code] ) ) |
|
582 | + if (isset($catalogMap[$code])) |
|
583 | 583 | { |
584 | - $manager->moveItem( $catalogItem->getId(), $catalogItem->getParentId(), $parentid ); |
|
585 | - $catalogItem = $manager->saveItem( $catalogItem ); |
|
584 | + $manager->moveItem($catalogItem->getId(), $catalogItem->getParentId(), $parentid); |
|
585 | + $catalogItem = $manager->saveItem($catalogItem); |
|
586 | 586 | } |
587 | 587 | else |
588 | 588 | { |
589 | - $catalogItem = $manager->insertItem( $catalogItem, $parentid ); |
|
589 | + $catalogItem = $manager->insertItem($catalogItem, $parentid); |
|
590 | 590 | } |
591 | 591 | |
592 | - $list = $processor->process( $catalogItem, $list ); |
|
592 | + $list = $processor->process($catalogItem, $list); |
|
593 | 593 | $catalogMap[$code] = $catalogItem; |
594 | 594 | } |
595 | 595 | |
596 | 596 | $manager->commit(); |
597 | 597 | } |
598 | - catch( \Exception $e ) |
|
598 | + catch (\Exception $e) |
|
599 | 599 | { |
600 | 600 | $manager->rollback(); |
601 | 601 | |
602 | - $msg = sprintf( 'Unable to import catalog with code "%1$s": %2$s', $code, $e->getMessage() ); |
|
603 | - $context->getLogger()->log( $msg ); |
|
602 | + $msg = sprintf('Unable to import catalog with code "%1$s": %2$s', $code, $e->getMessage()); |
|
603 | + $context->getLogger()->log($msg); |
|
604 | 604 | |
605 | 605 | $errors++; |
606 | 606 | } |
607 | 607 | |
608 | - if( $strict && !empty( $list ) ) { |
|
609 | - $context->getLogger()->log( 'Not imported: ' . print_r( $list, true ) ); |
|
608 | + if ($strict && !empty($list)) { |
|
609 | + $context->getLogger()->log('Not imported: ' . print_r($list, true)); |
|
610 | 610 | } |
611 | 611 | } |
612 | 612 | |
@@ -620,9 +620,9 @@ discard block |
||
620 | 620 | * @param array $list Associative list of domain item keys and their values, e.g. "catalog.status" => 1 |
621 | 621 | * @return array Given associative list enriched by default values if they were not already set |
622 | 622 | */ |
623 | - protected function addItemDefaults( array $list ) |
|
623 | + protected function addItemDefaults(array $list) |
|
624 | 624 | { |
625 | - if( !isset( $list['catalog.status'] ) ) { |
|
625 | + if (!isset($list['catalog.status'])) { |
|
626 | 626 | $list['catalog.status'] = 1; |
627 | 627 | } |
628 | 628 |
@@ -40,28 +40,28 @@ |
||
40 | 40 | * @param \Aimeos\MShop\Order\Item\Base\Iface $order Full subscription with associated items |
41 | 41 | * @return array Two dimensional associative list of subscription data representing the lines in CSV |
42 | 42 | */ |
43 | - public function process( \Aimeos\MShop\Subscription\Item\Iface $subscription, \Aimeos\MShop\Order\Item\Base\Iface $order ) |
|
43 | + public function process(\Aimeos\MShop\Subscription\Item\Iface $subscription, \Aimeos\MShop\Order\Item\Base\Iface $order) |
|
44 | 44 | { |
45 | 45 | $result = []; |
46 | 46 | $addresses = $order->getAddresses(); |
47 | 47 | |
48 | - krsort( $addresses ); |
|
48 | + krsort($addresses); |
|
49 | 49 | |
50 | - foreach( $addresses as $item ) |
|
50 | + foreach ($addresses as $item) |
|
51 | 51 | { |
52 | 52 | $data = []; |
53 | 53 | $list = $item->toArray(); |
54 | 54 | |
55 | - foreach( $this->getMapping() as $pos => $key ) |
|
55 | + foreach ($this->getMapping() as $pos => $key) |
|
56 | 56 | { |
57 | - if( array_key_exists( $key, $list ) ) { |
|
57 | + if (array_key_exists($key, $list)) { |
|
58 | 58 | $data[$pos] = $list[$key]; |
59 | 59 | } else { |
60 | 60 | $data[$pos] = ''; |
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
64 | - ksort( $data ); |
|
64 | + ksort($data); |
|
65 | 65 | $result[] = $data; |
66 | 66 | } |
67 | 67 |
@@ -40,24 +40,24 @@ discard block |
||
40 | 40 | * @param \Aimeos\MShop\Order\Item\Base\Iface $order Full order with associated items |
41 | 41 | * @return array Two dimensional associative list of order data representing the lines in CSV |
42 | 42 | */ |
43 | - public function process( \Aimeos\MShop\Subscription\Item\Iface $subscription, \Aimeos\MShop\Order\Item\Base\Iface $order ) |
|
43 | + public function process(\Aimeos\MShop\Subscription\Item\Iface $subscription, \Aimeos\MShop\Order\Item\Base\Iface $order) |
|
44 | 44 | { |
45 | 45 | $result = []; |
46 | 46 | |
47 | - foreach( $order->getProducts() as $item ) |
|
47 | + foreach ($order->getProducts() as $item) |
|
48 | 48 | { |
49 | - if( $subscription->getOrderProductId() != $item->getId() ) { |
|
49 | + if ($subscription->getOrderProductId() != $item->getId()) { |
|
50 | 50 | continue; |
51 | 51 | } |
52 | 52 | |
53 | 53 | $data = []; |
54 | 54 | $list = $item->toArray(); |
55 | 55 | |
56 | - foreach( $item->getAttributes() as $attrItem ) |
|
56 | + foreach ($item->getAttributes() as $attrItem) |
|
57 | 57 | { |
58 | - foreach( $attrItem->toArray() as $key => $value ) |
|
58 | + foreach ($attrItem->toArray() as $key => $value) |
|
59 | 59 | { |
60 | - if( isset( $list[$key] ) ) { |
|
60 | + if (isset($list[$key])) { |
|
61 | 61 | $list[$key] .= "\n" . $value; |
62 | 62 | } else { |
63 | 63 | $list[$key] = $value; |
@@ -65,16 +65,16 @@ discard block |
||
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
68 | - foreach( $this->getMapping() as $pos => $key ) |
|
68 | + foreach ($this->getMapping() as $pos => $key) |
|
69 | 69 | { |
70 | - if( array_key_exists( $key, $list ) ) { |
|
70 | + if (array_key_exists($key, $list)) { |
|
71 | 71 | $data[$pos] = $list[$key]; |
72 | 72 | } else { |
73 | 73 | $data[$pos] = ''; |
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
77 | - ksort( $data ); |
|
77 | + ksort($data); |
|
78 | 78 | $result[] = $data; |
79 | 79 | } |
80 | 80 |
@@ -29,7 +29,7 @@ |
||
29 | 29 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object |
30 | 30 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value |
31 | 31 | */ |
32 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping ) |
|
32 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping) |
|
33 | 33 | { |
34 | 34 | $this->context = $context; |
35 | 35 | $this->mapping = $mapping; |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object |
26 | 26 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value |
27 | 27 | */ |
28 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping ); |
|
28 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping); |
|
29 | 29 | |
30 | 30 | |
31 | 31 | /** |
@@ -35,5 +35,5 @@ discard block |
||
35 | 35 | * @param \Aimeos\MShop\Order\Item\Base\Iface $order Full order with associated items |
36 | 36 | * @return array Two dimensional associative list of order data representing the lines in CSV |
37 | 37 | */ |
38 | - public function process( \Aimeos\MShop\Subscription\Item\Iface $subscription, \Aimeos\MShop\Order\Item\Base\Iface $order ); |
|
38 | + public function process(\Aimeos\MShop\Subscription\Item\Iface $subscription, \Aimeos\MShop\Order\Item\Base\Iface $order); |
|
39 | 39 | } |
40 | 40 | \ No newline at end of file |
@@ -40,21 +40,21 @@ |
||
40 | 40 | * @param \Aimeos\MShop\Order\Item\Base\Iface $order Full order with associated items |
41 | 41 | * @return array Two dimensional associative list of subscription data representing the lines in CSV |
42 | 42 | */ |
43 | - public function process( \Aimeos\MShop\Subscription\Item\Iface $subscription, \Aimeos\MShop\Order\Item\Base\Iface $order ) |
|
43 | + public function process(\Aimeos\MShop\Subscription\Item\Iface $subscription, \Aimeos\MShop\Order\Item\Base\Iface $order) |
|
44 | 44 | { |
45 | 45 | $result = []; |
46 | 46 | $list = $subscription->toArray() + $order->toArray(); |
47 | 47 | |
48 | - foreach( $this->getMapping() as $pos => $key ) |
|
48 | + foreach ($this->getMapping() as $pos => $key) |
|
49 | 49 | { |
50 | - if( array_key_exists( $key, $list ) ) { |
|
50 | + if (array_key_exists($key, $list)) { |
|
51 | 51 | $result[$pos] = $list[$key]; |
52 | 52 | } else { |
53 | 53 | $result[$pos] = ''; |
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | - ksort( $result ); |
|
57 | + ksort($result); |
|
58 | 58 | |
59 | 59 | return [$result]; |
60 | 60 | } |