@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function getName() |
30 | 30 | { |
31 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Product export' ); |
|
31 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Product export'); |
|
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', 'Exports all available products' ); |
|
42 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Exports all available products'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | public function run() |
52 | 52 | { |
53 | 53 | $container = $this->createContainer(); |
54 | - $this->export( $container ); |
|
54 | + $this->export($container); |
|
55 | 55 | $container->close(); |
56 | 56 | } |
57 | 57 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * @param \Aimeos\MW\Container\Content\Iface $content File content object |
63 | 63 | * @param \Aimeos\MShop\Product\Item\Iface[] $items List of product items |
64 | 64 | */ |
65 | - protected function addItems( \Aimeos\MW\Container\Content\Iface $content, array $items ) |
|
65 | + protected function addItems(\Aimeos\MW\Container\Content\Iface $content, array $items) |
|
66 | 66 | { |
67 | 67 | /** controller/jobs/product/export/standard/template-items |
68 | 68 | * Relative path to the XML items template of the product site map job controller. |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | |
95 | 95 | $view->exportItems = $items; |
96 | 96 | |
97 | - $content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) ); |
|
97 | + $content->add($view->render($context->getConfig()->get($tplconf, $default))); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @see controller/jobs/product/export/max-items |
124 | 124 | * @see controller/jobs/product/export/max-query |
125 | 125 | */ |
126 | - $location = $config->get( 'controller/jobs/product/export/location', sys_get_temp_dir() ); |
|
126 | + $location = $config->get('controller/jobs/product/export/location', sys_get_temp_dir()); |
|
127 | 127 | |
128 | 128 | /** controller/jobs/product/export/standard/container/type |
129 | 129 | * List of file container options for the export files |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @see controller/jobs/product/export/max-items |
141 | 141 | * @see controller/jobs/product/export/max-query |
142 | 142 | */ |
143 | - $container = $config->get( 'controller/jobs/product/export/standard/container/type', 'Directory' ); |
|
143 | + $container = $config->get('controller/jobs/product/export/standard/container/type', 'Directory'); |
|
144 | 144 | |
145 | 145 | /** controller/jobs/product/export/standard/container/content |
146 | 146 | * List of file container options for the export files |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @see controller/jobs/product/export/max-items |
158 | 158 | * @see controller/jobs/product/export/max-query |
159 | 159 | */ |
160 | - $content = $config->get( 'controller/jobs/product/export/standard/container/content', 'Binary' ); |
|
160 | + $content = $config->get('controller/jobs/product/export/standard/container/content', 'Binary'); |
|
161 | 161 | |
162 | 162 | /** controller/jobs/product/export/standard/container/options |
163 | 163 | * List of file container options for the export files |
@@ -174,9 +174,9 @@ discard block |
||
174 | 174 | * @see controller/jobs/product/export/max-items |
175 | 175 | * @see controller/jobs/product/export/max-query |
176 | 176 | */ |
177 | - $options = $config->get( 'controller/jobs/product/export/standard/container/options', array() ); |
|
177 | + $options = $config->get('controller/jobs/product/export/standard/container/options', array()); |
|
178 | 178 | |
179 | - return \Aimeos\MW\Container\Factory::getContainer( $location, $container, $content, $options ); |
|
179 | + return \Aimeos\MW\Container\Factory::getContainer($location, $container, $content, $options); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @param integer $filenum New file number |
188 | 188 | * @return \Aimeos\MW\Container\Content\Iface New content object |
189 | 189 | */ |
190 | - protected function createContent( \Aimeos\MW\Container\Iface $container, $filenum ) |
|
190 | + protected function createContent(\Aimeos\MW\Container\Iface $container, $filenum) |
|
191 | 191 | { |
192 | 192 | /** controller/jobs/product/export/standard/template-header |
193 | 193 | * Relative path to the XML site map header template of the product site map job controller. |
@@ -217,9 +217,9 @@ discard block |
||
217 | 217 | $context = $this->getContext(); |
218 | 218 | $view = $context->getView(); |
219 | 219 | |
220 | - $content = $container->create( $this->getFilename( $filenum ) ); |
|
221 | - $content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) ); |
|
222 | - $container->add( $content ); |
|
220 | + $content = $container->create($this->getFilename($filenum)); |
|
221 | + $content->add($view->render($context->getConfig()->get($tplconf, $default))); |
|
222 | + $container->add($content); |
|
223 | 223 | |
224 | 224 | return $content; |
225 | 225 | } |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | * |
231 | 231 | * @param \Aimeos\MW\Container\Content\Iface $content |
232 | 232 | */ |
233 | - protected function closeContent( \Aimeos\MW\Container\Content\Iface $content ) |
|
233 | + protected function closeContent(\Aimeos\MW\Container\Content\Iface $content) |
|
234 | 234 | { |
235 | 235 | /** controller/jobs/product/export/standard/template-footer |
236 | 236 | * Relative path to the XML site map footer template of the product site map job controller. |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | $context = $this->getContext(); |
261 | 261 | $view = $context->getView(); |
262 | 262 | |
263 | - $content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) ); |
|
263 | + $content->add($view->render($context->getConfig()->get($tplconf, $default))); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | |
@@ -270,45 +270,45 @@ discard block |
||
270 | 270 | * @param \Aimeos\MW\Container\Iface $container Container object |
271 | 271 | * @return array List of content (file) names |
272 | 272 | */ |
273 | - protected function export( \Aimeos\MW\Container\Iface $container ) |
|
273 | + protected function export(\Aimeos\MW\Container\Iface $container) |
|
274 | 274 | { |
275 | - $default = array( 'attribute', 'media', 'price', 'product', 'text' ); |
|
275 | + $default = array('attribute', 'media', 'price', 'product', 'text'); |
|
276 | 276 | |
277 | - $domains = $this->getConfig( 'domains', $default ); |
|
278 | - $maxItems = $this->getConfig( 'max-items', 10000 ); |
|
279 | - $maxQuery = $this->getConfig( 'max-query', 1000 ); |
|
277 | + $domains = $this->getConfig('domains', $default); |
|
278 | + $maxItems = $this->getConfig('max-items', 10000); |
|
279 | + $maxQuery = $this->getConfig('max-query', 1000); |
|
280 | 280 | |
281 | 281 | $start = 0; $filenum = 1; |
282 | 282 | $names = array(); |
283 | 283 | |
284 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
284 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
285 | 285 | |
286 | - $search = $productManager->createSearch( true ); |
|
287 | - $search->setSortations( array( $search->sort( '+', 'product.id' ) ) ); |
|
288 | - $search->setSlice( 0, $maxQuery ); |
|
286 | + $search = $productManager->createSearch(true); |
|
287 | + $search->setSortations(array($search->sort('+', 'product.id'))); |
|
288 | + $search->setSlice(0, $maxQuery); |
|
289 | 289 | |
290 | - $content = $this->createContent( $container, $filenum ); |
|
290 | + $content = $this->createContent($container, $filenum); |
|
291 | 291 | $names[] = $content->getResource(); |
292 | 292 | |
293 | 293 | do |
294 | 294 | { |
295 | - $items = $productManager->searchItems( $search, $domains ); |
|
296 | - $this->addItems( $content, $items ); |
|
295 | + $items = $productManager->searchItems($search, $domains); |
|
296 | + $this->addItems($content, $items); |
|
297 | 297 | |
298 | - $count = count( $items ); |
|
298 | + $count = count($items); |
|
299 | 299 | $start += $count; |
300 | - $search->setSlice( $start, $maxQuery ); |
|
300 | + $search->setSlice($start, $maxQuery); |
|
301 | 301 | |
302 | - if( $start + $maxQuery > $maxItems * $filenum ) |
|
302 | + if ($start + $maxQuery > $maxItems * $filenum) |
|
303 | 303 | { |
304 | - $this->closeContent( $content ); |
|
305 | - $content = $this->createContent( $container, ++$filenum ); |
|
304 | + $this->closeContent($content); |
|
305 | + $content = $this->createContent($container, ++$filenum); |
|
306 | 306 | $names[] = $content->getResource(); |
307 | 307 | } |
308 | 308 | } |
309 | - while( $count >= $search->getSliceSize() ); |
|
309 | + while ($count >= $search->getSliceSize()); |
|
310 | 310 | |
311 | - $this->closeContent( $content ); |
|
311 | + $this->closeContent($content); |
|
312 | 312 | |
313 | 313 | return $names; |
314 | 314 | } |
@@ -321,11 +321,11 @@ discard block |
||
321 | 321 | * @param mixed $default Default value if name is unknown |
322 | 322 | * @return mixed Configuration value |
323 | 323 | */ |
324 | - protected function getConfig( $name, $default = null ) |
|
324 | + protected function getConfig($name, $default = null) |
|
325 | 325 | { |
326 | 326 | $config = $this->getContext()->getConfig(); |
327 | 327 | |
328 | - switch( $name ) |
|
328 | + switch ($name) |
|
329 | 329 | { |
330 | 330 | case 'domain': |
331 | 331 | /** controller/jobs/product/export/domains |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | * @see controller/jobs/product/export/max-items |
348 | 348 | * @see controller/jobs/product/export/max-query |
349 | 349 | */ |
350 | - return $config->get( 'controller/jobs/product/export/domains', $default ); |
|
350 | + return $config->get('controller/jobs/product/export/domains', $default); |
|
351 | 351 | |
352 | 352 | case 'max-items': |
353 | 353 | /** controller/jobs/product/export/max-items |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | * @see controller/jobs/product/export/max-query |
370 | 370 | * @see controller/jobs/product/export/domains |
371 | 371 | */ |
372 | - return $config->get( 'controller/jobs/product/export/max-items', $default ); |
|
372 | + return $config->get('controller/jobs/product/export/max-items', $default); |
|
373 | 373 | |
374 | 374 | case 'max-query': |
375 | 375 | /** controller/jobs/product/export/max-query |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | * @see controller/jobs/product/export/max-items |
392 | 392 | * @see controller/jobs/product/export/domains |
393 | 393 | */ |
394 | - return $config->get( 'controller/jobs/product/export/max-query', $default ); |
|
394 | + return $config->get('controller/jobs/product/export/max-query', $default); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | return $default; |
@@ -404,8 +404,8 @@ discard block |
||
404 | 404 | * @param integer $number Current file number |
405 | 405 | * @return string New file name |
406 | 406 | */ |
407 | - protected function getFilename( $number ) |
|
407 | + protected function getFilename($number) |
|
408 | 408 | { |
409 | - return sprintf( 'aimeos-products-%d.xml', $number ); |
|
409 | + return sprintf('aimeos-products-%d.xml', $number); |
|
410 | 410 | } |
411 | 411 | } |
@@ -40,16 +40,16 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object |
42 | 42 | */ |
43 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context ) |
|
43 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context) |
|
44 | 44 | { |
45 | - parent::__construct( $context ); |
|
45 | + parent::__construct($context); |
|
46 | 46 | |
47 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'stock/type' ); |
|
47 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'stock/type'); |
|
48 | 48 | $search = $manager->createSearch(); |
49 | - $search->setSlice( 0, 0x7fffffff ); |
|
49 | + $search->setSlice(0, 0x7fffffff); |
|
50 | 50 | |
51 | - foreach( $manager->searchItems( $search ) as $id => $item ) { |
|
52 | - $this->types[ $item->getCode() ] = $id; |
|
51 | + foreach ($manager->searchItems($search) as $id => $item) { |
|
52 | + $this->types[$item->getCode()] = $id; |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | * @param string|null $type Attribute type |
62 | 62 | * @return string|null Stock type ID or null if not found |
63 | 63 | */ |
64 | - public function get( $code, $type = null ) |
|
64 | + public function get($code, $type = null) |
|
65 | 65 | { |
66 | - if( isset( $this->types[$code] ) ) { |
|
66 | + if (isset($this->types[$code])) { |
|
67 | 67 | return $this->types[$code]; |
68 | 68 | } |
69 | 69 | } |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @param \Aimeos\MShop\Common\Item\Iface $item Stock type object |
76 | 76 | */ |
77 | - public function set( \Aimeos\MShop\Common\Item\Iface $item ) |
|
77 | + public function set(\Aimeos\MShop\Common\Item\Iface $item) |
|
78 | 78 | { |
79 | - $this->types[ $item->getCode() ] = $item->getId(); |
|
79 | + $this->types[$item->getCode()] = $item->getId(); |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | \ No newline at end of file |
@@ -16,43 +16,43 @@ |
||
16 | 16 | |
17 | 17 | protected function setUp() |
18 | 18 | { |
19 | - \Aimeos\MShop\Factory::setCache( true ); |
|
19 | + \Aimeos\MShop\Factory::setCache(true); |
|
20 | 20 | |
21 | 21 | $context = \TestHelperCntl::getContext(); |
22 | - $this->object = new \Aimeos\Controller\Common\Product\Import\Csv\Cache\Stocktype\Standard( $context ); |
|
22 | + $this->object = new \Aimeos\Controller\Common\Product\Import\Csv\Cache\Stocktype\Standard($context); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | |
26 | 26 | protected function tearDown() |
27 | 27 | { |
28 | - \Aimeos\MShop\Factory::setCache( false ); |
|
28 | + \Aimeos\MShop\Factory::setCache(false); |
|
29 | 29 | \Aimeos\MShop\Factory::clear(); |
30 | 30 | } |
31 | 31 | |
32 | 32 | |
33 | 33 | public function testGet() |
34 | 34 | { |
35 | - $result = $this->object->get( 'default' ); |
|
35 | + $result = $this->object->get('default'); |
|
36 | 36 | |
37 | - $this->assertNotEquals( null, $result ); |
|
37 | + $this->assertNotEquals(null, $result); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | |
41 | 41 | public function testGetUnknown() |
42 | 42 | { |
43 | - $this->assertEquals( null, $this->object->get( 'cache-test' ) ); |
|
43 | + $this->assertEquals(null, $this->object->get('cache-test')); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
47 | 47 | public function testSet() |
48 | 48 | { |
49 | - $item = \Aimeos\MShop\Factory::createManager( \TestHelperCntl::getContext(), 'stock/type' )->createItem(); |
|
50 | - $item->setCode( 'cache-test' ); |
|
51 | - $item->setId( 1 ); |
|
49 | + $item = \Aimeos\MShop\Factory::createManager(\TestHelperCntl::getContext(), 'stock/type')->createItem(); |
|
50 | + $item->setCode('cache-test'); |
|
51 | + $item->setId(1); |
|
52 | 52 | |
53 | - $this->object->set( $item ); |
|
54 | - $id = $this->object->get( 'cache-test' ); |
|
53 | + $this->object->set($item); |
|
54 | + $id = $this->object->get('cache-test'); |
|
55 | 55 | |
56 | - $this->assertEquals( $item->getId(), $id ); |
|
56 | + $this->assertEquals($item->getId(), $id); |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | \ 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/media/scale/name |
35 | 35 | * Class name of the used media scale job controller implementation |
@@ -64,20 +64,20 @@ discard block |
||
64 | 64 | * @since 2017.01 |
65 | 65 | * @category Developer |
66 | 66 | */ |
67 | - if( $name === null ) { |
|
68 | - $name = $context->getConfig()->get( 'controller/jobs/media/scale/name', 'Standard' ); |
|
67 | + if ($name === null) { |
|
68 | + $name = $context->getConfig()->get('controller/jobs/media/scale/name', 'Standard'); |
|
69 | 69 | } |
70 | 70 | |
71 | - if( ctype_alnum( $name ) === false ) |
|
71 | + if (ctype_alnum($name) === false) |
|
72 | 72 | { |
73 | - $classname = is_string( $name ) ? '\\Aimeos\\Controller\\Jobs\\Media\\Scale\\' . $name : '<not a string>'; |
|
74 | - throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
73 | + $classname = is_string($name) ? '\\Aimeos\\Controller\\Jobs\\Media\\Scale\\' . $name : '<not a string>'; |
|
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\\Media\\Scale\\' . $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/media/scale/decorators/excludes |
83 | 83 | * Excludes decorators added by the "common" option from the media scale controllers |
@@ -153,6 +153,6 @@ discard block |
||
153 | 153 | * @see controller/jobs/media/scale/decorators/excludes |
154 | 154 | * @see controller/jobs/media/scale/decorators/global |
155 | 155 | */ |
156 | - return self::addControllerDecorators( $context, $aimeos, $controller, 'media/scale' ); |
|
156 | + return self::addControllerDecorators($context, $aimeos, $controller, 'media/scale'); |
|
157 | 157 | } |
158 | 158 | } |
159 | 159 | \ No newline at end of file |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | $context = \TestHelperJobs::getContext(); |
17 | 17 | $aimeos = \TestHelperJobs::getAimeos(); |
18 | 18 | |
19 | - $obj = \Aimeos\Controller\Jobs\Media\Scale\Factory::createController( $context, $aimeos ); |
|
20 | - $this->assertInstanceOf( '\\Aimeos\\Controller\\Jobs\\Iface', $obj ); |
|
19 | + $obj = \Aimeos\Controller\Jobs\Media\Scale\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\Media\Scale\Factory::createController( $context, $aimeos, 'Wrong$$$Name' ); |
|
29 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
30 | + \Aimeos\Controller\Jobs\Media\Scale\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\Media\Scale\Factory::createController( $context, $aimeos, 'WrongClass' ); |
|
39 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
40 | + \Aimeos\Controller\Jobs\Media\Scale\Factory::createController($context, $aimeos, 'WrongClass'); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
@@ -46,8 +46,8 @@ 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\Media\Scale\Factory::createController( $context, $aimeos, 'Factory' ); |
|
49 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
50 | + \Aimeos\Controller\Jobs\Media\Scale\Factory::createController($context, $aimeos, 'Factory'); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function getName() |
30 | 30 | { |
31 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Rescale product images' ); |
|
31 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Rescale product images'); |
|
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', 'Rescales product images to the new sizes' ); |
|
42 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Rescales product images to the new sizes'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -50,33 +50,33 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function run() |
52 | 52 | { |
53 | - $cntl = \Aimeos\Controller\Common\Media\Factory::createController( $this->getContext() ); |
|
54 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'media' ); |
|
53 | + $cntl = \Aimeos\Controller\Common\Media\Factory::createController($this->getContext()); |
|
54 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'media'); |
|
55 | 55 | |
56 | 56 | $search = $manager->createSearch(); |
57 | 57 | $expr = array( |
58 | - $search->compare( '==', 'media.domain', 'product' ), |
|
59 | - $search->compare( '=~', 'media.mimetype', 'image/' ), |
|
58 | + $search->compare('==', 'media.domain', 'product'), |
|
59 | + $search->compare('=~', 'media.mimetype', 'image/'), |
|
60 | 60 | ); |
61 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
62 | - $search->setSortations( array( $search->sort( '+', 'media.id' ) ) ); |
|
61 | + $search->setConditions($search->combine('&&', $expr)); |
|
62 | + $search->setSortations(array($search->sort('+', 'media.id'))); |
|
63 | 63 | |
64 | 64 | $start = 0; |
65 | 65 | |
66 | 66 | do |
67 | 67 | { |
68 | - $search->setSlice( $start ); |
|
69 | - $items = $manager->searchItems( $search ); |
|
68 | + $search->setSlice($start); |
|
69 | + $items = $manager->searchItems($search); |
|
70 | 70 | |
71 | - foreach( $items as $item ) |
|
71 | + foreach ($items as $item) |
|
72 | 72 | { |
73 | - $cntl->scale( $item, 'fs-media' ); |
|
74 | - $manager->saveItem( $item ); |
|
73 | + $cntl->scale($item, 'fs-media'); |
|
74 | + $manager->saveItem($item); |
|
75 | 75 | } |
76 | 76 | |
77 | - $count = count( $items ); |
|
77 | + $count = count($items); |
|
78 | 78 | $start += $count; |
79 | 79 | } |
80 | - while( $count === $search->getSliceSize() ); |
|
80 | + while ($count === $search->getSliceSize()); |
|
81 | 81 | } |
82 | 82 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | $context = \TestHelperJobs::getContext(); |
20 | 20 | $aimeos = \TestHelperJobs::getAimeos(); |
21 | 21 | |
22 | - $this->object = new \Aimeos\Controller\Jobs\Media\Scale\Standard( $context, $aimeos ); |
|
22 | + $this->object = new \Aimeos\Controller\Jobs\Media\Scale\Standard($context, $aimeos); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | |
@@ -31,14 +31,14 @@ discard block |
||
31 | 31 | |
32 | 32 | public function testGetName() |
33 | 33 | { |
34 | - $this->assertEquals( 'Rescale product images', $this->object->getName() ); |
|
34 | + $this->assertEquals('Rescale product images', $this->object->getName()); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
38 | 38 | public function testGetDescription() |
39 | 39 | { |
40 | 40 | $text = 'Rescales product images to the new sizes'; |
41 | - $this->assertEquals( $text, $this->object->getDescription() ); |
|
41 | + $this->assertEquals($text, $this->object->getDescription()); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | |
@@ -49,31 +49,31 @@ discard block |
||
49 | 49 | |
50 | 50 | |
51 | 51 | $name = 'ControllerJobsMediaScaleStandardRun'; |
52 | - $context->getConfig()->set( 'mshop/media/manager/name', $name ); |
|
53 | - $context->getConfig()->set( 'controller/common/media/name', $name ); |
|
52 | + $context->getConfig()->set('mshop/media/manager/name', $name); |
|
53 | + $context->getConfig()->set('controller/common/media/name', $name); |
|
54 | 54 | |
55 | 55 | |
56 | - $managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Media\\Manager\\Standard' ) |
|
57 | - ->setMethods( array( 'saveItem' ) ) |
|
58 | - ->setConstructorArgs( array( $context ) ) |
|
56 | + $managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Media\\Manager\\Standard') |
|
57 | + ->setMethods(array('saveItem')) |
|
58 | + ->setConstructorArgs(array($context)) |
|
59 | 59 | ->getMock(); |
60 | 60 | |
61 | - \Aimeos\MShop\Media\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Media\\Manager\\' . $name, $managerStub ); |
|
61 | + \Aimeos\MShop\Media\Manager\Factory::injectManager('\\Aimeos\\MShop\\Media\\Manager\\' . $name, $managerStub); |
|
62 | 62 | |
63 | - $managerStub->expects( $this->atLeast( 1 ) )->method( 'saveItem' ); |
|
63 | + $managerStub->expects($this->atLeast(1))->method('saveItem'); |
|
64 | 64 | |
65 | 65 | |
66 | - $cntlStub = $this->getMockBuilder( '\\Aimeos\\Controller\\Common\\Media\\Standard' ) |
|
67 | - ->setMethods( array( 'scale' ) ) |
|
68 | - ->setConstructorArgs( array( $context ) ) |
|
66 | + $cntlStub = $this->getMockBuilder('\\Aimeos\\Controller\\Common\\Media\\Standard') |
|
67 | + ->setMethods(array('scale')) |
|
68 | + ->setConstructorArgs(array($context)) |
|
69 | 69 | ->getMock(); |
70 | 70 | |
71 | - \Aimeos\Controller\Common\Media\Factory::injectController( '\\Aimeos\\Controller\\Common\\Media\\' . $name, $cntlStub ); |
|
71 | + \Aimeos\Controller\Common\Media\Factory::injectController('\\Aimeos\\Controller\\Common\\Media\\' . $name, $cntlStub); |
|
72 | 72 | |
73 | - $cntlStub->expects( $this->atLeast( 1 ) )->method( 'scale' ); |
|
73 | + $cntlStub->expects($this->atLeast(1))->method('scale'); |
|
74 | 74 | |
75 | 75 | |
76 | - $object = new \Aimeos\Controller\Jobs\Media\Scale\Standard( $context, $aimeos ); |
|
76 | + $object = new \Aimeos\Controller\Jobs\Media\Scale\Standard($context, $aimeos); |
|
77 | 77 | $object->run(); |
78 | 78 | } |
79 | 79 | } |
@@ -17,16 +17,16 @@ discard block |
||
17 | 17 | |
18 | 18 | protected function setUp() |
19 | 19 | { |
20 | - \Aimeos\MShop\Factory::setCache( true ); |
|
20 | + \Aimeos\MShop\Factory::setCache(true); |
|
21 | 21 | |
22 | 22 | $this->context = \TestHelperCntl::getContext(); |
23 | - $this->endpoint = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done( $this->context, array() ); |
|
23 | + $this->endpoint = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done($this->context, array()); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | |
27 | 27 | protected function tearDown() |
28 | 28 | { |
29 | - \Aimeos\MShop\Factory::setCache( false ); |
|
29 | + \Aimeos\MShop\Factory::setCache(false); |
|
30 | 30 | \Aimeos\MShop\Factory::clear(); |
31 | 31 | } |
32 | 32 | |
@@ -43,21 +43,21 @@ discard block |
||
43 | 43 | 1 => '2000-01-01 00:00:00', |
44 | 44 | ); |
45 | 45 | |
46 | - $product = $this->create( 'job_csv_test' ); |
|
46 | + $product = $this->create('job_csv_test'); |
|
47 | 47 | |
48 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard( $this->context, $mapping, $this->endpoint ); |
|
49 | - $object->process( $product, $data ); |
|
48 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard($this->context, $mapping, $this->endpoint); |
|
49 | + $object->process($product, $data); |
|
50 | 50 | |
51 | - $items = $this->getStockItems( $product->getCode() ); |
|
52 | - $this->delete( $product ); |
|
51 | + $items = $this->getStockItems($product->getCode()); |
|
52 | + $this->delete($product); |
|
53 | 53 | |
54 | 54 | |
55 | - $this->assertEquals( 1, count( $items ) ); |
|
55 | + $this->assertEquals(1, count($items)); |
|
56 | 56 | |
57 | - foreach( $items as $item ) |
|
57 | + foreach ($items as $item) |
|
58 | 58 | { |
59 | - $this->assertEquals( 100, $item->getStocklevel() ); |
|
60 | - $this->assertEquals( '2000-01-01 00:00:00', $item->getDateBack() ); |
|
59 | + $this->assertEquals(100, $item->getStocklevel()); |
|
60 | + $this->assertEquals('2000-01-01 00:00:00', $item->getDateBack()); |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
@@ -78,19 +78,19 @@ discard block |
||
78 | 78 | 3 => '200', |
79 | 79 | ); |
80 | 80 | |
81 | - $product = $this->create( 'job_csv_test' ); |
|
81 | + $product = $this->create('job_csv_test'); |
|
82 | 82 | |
83 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard( $this->context, $mapping, $this->endpoint ); |
|
84 | - $object->process( $product, $data ); |
|
83 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard($this->context, $mapping, $this->endpoint); |
|
84 | + $object->process($product, $data); |
|
85 | 85 | |
86 | - $items = $this->getStockItems( $product->getCode() ); |
|
87 | - $this->delete( $product ); |
|
86 | + $items = $this->getStockItems($product->getCode()); |
|
87 | + $this->delete($product); |
|
88 | 88 | |
89 | 89 | |
90 | - $this->assertEquals( 2, count( $items ) ); |
|
90 | + $this->assertEquals(2, count($items)); |
|
91 | 91 | |
92 | - foreach( $items as $item ) { |
|
93 | - $this->assertEquals( 200, $item->getStocklevel() ); |
|
92 | + foreach ($items as $item) { |
|
93 | + $this->assertEquals(200, $item->getStocklevel()); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
@@ -109,21 +109,21 @@ discard block |
||
109 | 109 | 0 => '20', |
110 | 110 | ); |
111 | 111 | |
112 | - $product = $this->create( 'job_csv_test' ); |
|
112 | + $product = $this->create('job_csv_test'); |
|
113 | 113 | |
114 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard( $this->context, $mapping, $this->endpoint ); |
|
114 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard($this->context, $mapping, $this->endpoint); |
|
115 | 115 | |
116 | - $object->process( $product, $data ); |
|
117 | - $object->process( $product, $dataUpdate ); |
|
116 | + $object->process($product, $data); |
|
117 | + $object->process($product, $dataUpdate); |
|
118 | 118 | |
119 | - $items = $this->getStockItems( $product->getCode() ); |
|
120 | - $this->delete( $product ); |
|
119 | + $items = $this->getStockItems($product->getCode()); |
|
120 | + $this->delete($product); |
|
121 | 121 | |
122 | 122 | |
123 | - $item = reset( $items ); |
|
123 | + $item = reset($items); |
|
124 | 124 | |
125 | - $this->assertEquals( 1, count( $items ) ); |
|
126 | - $this->assertEquals( 20, $item->getStocklevel() ); |
|
125 | + $this->assertEquals(1, count($items)); |
|
126 | + $this->assertEquals(20, $item->getStocklevel()); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | |
@@ -137,19 +137,19 @@ discard block |
||
137 | 137 | 0 => 50, |
138 | 138 | ); |
139 | 139 | |
140 | - $product = $this->create( 'job_csv_test' ); |
|
140 | + $product = $this->create('job_csv_test'); |
|
141 | 141 | |
142 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard( $this->context, $mapping, $this->endpoint ); |
|
143 | - $object->process( $product, $data ); |
|
142 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard($this->context, $mapping, $this->endpoint); |
|
143 | + $object->process($product, $data); |
|
144 | 144 | |
145 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard( $this->context, array(), $this->endpoint ); |
|
146 | - $object->process( $product, array() ); |
|
145 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard($this->context, array(), $this->endpoint); |
|
146 | + $object->process($product, array()); |
|
147 | 147 | |
148 | - $items = $this->getStockItems( $product->getCode() ); |
|
149 | - $this->delete( $product ); |
|
148 | + $items = $this->getStockItems($product->getCode()); |
|
149 | + $this->delete($product); |
|
150 | 150 | |
151 | 151 | |
152 | - $this->assertEquals( 0, count( $items ) ); |
|
152 | + $this->assertEquals(0, count($items)); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | |
@@ -167,20 +167,20 @@ discard block |
||
167 | 167 | 2 => '', |
168 | 168 | ); |
169 | 169 | |
170 | - $product = $this->create( 'job_csv_test' ); |
|
170 | + $product = $this->create('job_csv_test'); |
|
171 | 171 | |
172 | - $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard( $this->context, $mapping, $this->endpoint ); |
|
173 | - $object->process( $product, $data ); |
|
172 | + $object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Stock\Standard($this->context, $mapping, $this->endpoint); |
|
173 | + $object->process($product, $data); |
|
174 | 174 | |
175 | - $items = $this->getStockItems( $product->getCode() ); |
|
176 | - $this->delete( $product ); |
|
175 | + $items = $this->getStockItems($product->getCode()); |
|
176 | + $this->delete($product); |
|
177 | 177 | |
178 | - $this->assertEquals( 1, count( $items ) ); |
|
178 | + $this->assertEquals(1, count($items)); |
|
179 | 179 | |
180 | - foreach( $items as $item ) |
|
180 | + foreach ($items as $item) |
|
181 | 181 | { |
182 | - $this->assertEquals( null, $item->getStocklevel() ); |
|
183 | - $this->assertEquals( null, $item->getDateBack() ); |
|
182 | + $this->assertEquals(null, $item->getStocklevel()); |
|
183 | + $this->assertEquals(null, $item->getDateBack()); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
@@ -188,43 +188,43 @@ discard block |
||
188 | 188 | /** |
189 | 189 | * @param string $code |
190 | 190 | */ |
191 | - protected function create( $code ) |
|
191 | + protected function create($code) |
|
192 | 192 | { |
193 | - $manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context ); |
|
194 | - $typeManager = $manager->getSubManager( 'type' ); |
|
193 | + $manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context); |
|
194 | + $typeManager = $manager->getSubManager('type'); |
|
195 | 195 | |
196 | 196 | $typeSearch = $typeManager->createSearch(); |
197 | - $typeSearch->setConditions( $typeSearch->compare( '==', 'product.type.code', 'default' ) ); |
|
198 | - $typeResult = $typeManager->searchItems( $typeSearch ); |
|
197 | + $typeSearch->setConditions($typeSearch->compare('==', 'product.type.code', 'default')); |
|
198 | + $typeResult = $typeManager->searchItems($typeSearch); |
|
199 | 199 | |
200 | - if( ( $typeItem = reset( $typeResult ) ) === false ) { |
|
201 | - throw new \RuntimeException( 'No product type "default" found' ); |
|
200 | + if (($typeItem = reset($typeResult)) === false) { |
|
201 | + throw new \RuntimeException('No product type "default" found'); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | $item = $manager->createItem(); |
205 | - $item->setTypeid( $typeItem->getId() ); |
|
206 | - $item->setCode( $code ); |
|
205 | + $item->setTypeid($typeItem->getId()); |
|
206 | + $item->setCode($code); |
|
207 | 207 | |
208 | - $manager->saveItem( $item ); |
|
208 | + $manager->saveItem($item); |
|
209 | 209 | |
210 | 210 | return $item; |
211 | 211 | } |
212 | 212 | |
213 | 213 | |
214 | - protected function delete( \Aimeos\MShop\Product\Item\Iface $product ) |
|
214 | + protected function delete(\Aimeos\MShop\Product\Item\Iface $product) |
|
215 | 215 | { |
216 | - $manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context ); |
|
217 | - $manager->deleteItem( $product->getId() ); |
|
216 | + $manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context); |
|
217 | + $manager->deleteItem($product->getId()); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | |
221 | - protected function getStockItems( $code ) |
|
221 | + protected function getStockItems($code) |
|
222 | 222 | { |
223 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'stock' ); |
|
223 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'stock'); |
|
224 | 224 | |
225 | 225 | $search = $manager->createSearch(); |
226 | - $search->setConditions( $search->compare( '==', 'stock.productcode', $code ) ); |
|
226 | + $search->setConditions($search->compare('==', 'stock.productcode', $code)); |
|
227 | 227 | |
228 | - return $manager->searchItems( $search ); |
|
228 | + return $manager->searchItems($search); |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | \ No newline at end of file |
@@ -127,8 +127,7 @@ discard block |
||
127 | 127 | { |
128 | 128 | $listItem = $listMap[$code][ $list['attribute.type'] ]; |
129 | 129 | unset( $listItems[ $listItem->getId() ] ); |
130 | - } |
|
131 | - else |
|
130 | + } else |
|
132 | 131 | { |
133 | 132 | $listItem = $listManager->createItem(); |
134 | 133 | } |
@@ -142,8 +141,7 @@ discard block |
||
142 | 141 | $remaining = $this->getObject()->process( $product, $data ); |
143 | 142 | |
144 | 143 | $manager->commit(); |
145 | - } |
|
146 | - catch( \Exception $e ) |
|
144 | + } catch( \Exception $e ) |
|
147 | 145 | { |
148 | 146 | $manager->rollback(); |
149 | 147 | throw $e; |
@@ -43,10 +43,10 @@ discard block |
||
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 |
||
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,71 +80,71 @@ discard block |
||
80 | 80 | * @param array $data List of CSV fields with position as key and data as value |
81 | 81 | * @return array List of data which hasn't been imported |
82 | 82 | */ |
83 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
83 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
84 | 84 | { |
85 | 85 | $context = $this->getContext(); |
86 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'attribute' ); |
|
87 | - $listManager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists' ); |
|
88 | - $separator = $context->getConfig()->get( 'controller/common/product/import/csv/separator', "\n" ); |
|
86 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'attribute'); |
|
87 | + $listManager = \Aimeos\MShop\Factory::createManager($context, 'product/lists'); |
|
88 | + $separator = $context->getConfig()->get('controller/common/product/import/csv/separator', "\n"); |
|
89 | 89 | |
90 | 90 | $manager->begin(); |
91 | 91 | |
92 | 92 | try |
93 | 93 | { |
94 | 94 | $listMap = array(); |
95 | - $map = $this->getMappedChunk( $data ); |
|
96 | - $listItems = $product->getListItems( 'attribute', $this->listTypes ); |
|
95 | + $map = $this->getMappedChunk($data); |
|
96 | + $listItems = $product->getListItems('attribute', $this->listTypes); |
|
97 | 97 | |
98 | - foreach( $listItems as $listItem ) |
|
98 | + foreach ($listItems as $listItem) |
|
99 | 99 | { |
100 | - if( ( $refItem = $listItem->getRefItem() ) !== null ) { |
|
101 | - $listMap[ $refItem->getCode() ][ $listItem->getType() ] = $listItem; |
|
100 | + if (($refItem = $listItem->getRefItem()) !== null) { |
|
101 | + $listMap[$refItem->getCode()][$listItem->getType()] = $listItem; |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
105 | - foreach( $map as $pos => $list ) |
|
105 | + foreach ($map as $pos => $list) |
|
106 | 106 | { |
107 | - if( $this->checkEntry( $list ) === false ) { |
|
107 | + if ($this->checkEntry($list) === false) { |
|
108 | 108 | continue; |
109 | 109 | } |
110 | 110 | |
111 | - $codes = explode( $separator, $list['attribute.code'] ); |
|
111 | + $codes = explode($separator, $list['attribute.code']); |
|
112 | 112 | |
113 | - foreach( $codes as $code ) |
|
113 | + foreach ($codes as $code) |
|
114 | 114 | { |
115 | - $attrItem = $this->getAttributeItem( $code, $list['attribute.type'] ); |
|
116 | - $attrItem->fromArray( $list ); |
|
117 | - $attrItem->setCode( $code ); |
|
118 | - $manager->saveItem( $attrItem ); |
|
115 | + $attrItem = $this->getAttributeItem($code, $list['attribute.type']); |
|
116 | + $attrItem->fromArray($list); |
|
117 | + $attrItem->setCode($code); |
|
118 | + $manager->saveItem($attrItem); |
|
119 | 119 | |
120 | - $typecode = $this->getValue( $list, 'product.lists.type', 'default' ); |
|
121 | - $list['product.lists.typeid'] = $this->getTypeId( 'product/lists/type', 'attribute', $typecode ); |
|
120 | + $typecode = $this->getValue($list, 'product.lists.type', 'default'); |
|
121 | + $list['product.lists.typeid'] = $this->getTypeId('product/lists/type', 'attribute', $typecode); |
|
122 | 122 | $list['product.lists.refid'] = $attrItem->getId(); |
123 | 123 | $list['product.lists.parentid'] = $product->getId(); |
124 | 124 | $list['product.lists.domain'] = 'attribute'; |
125 | 125 | |
126 | - if( isset( $listMap[$code][$typecode] ) ) |
|
126 | + if (isset($listMap[$code][$typecode])) |
|
127 | 127 | { |
128 | 128 | $listItem = $listMap[$code][$typecode]; |
129 | - unset( $listItems[ $listItem->getId() ] ); |
|
129 | + unset($listItems[$listItem->getId()]); |
|
130 | 130 | } |
131 | 131 | else |
132 | 132 | { |
133 | 133 | $listItem = $listManager->createItem(); |
134 | 134 | } |
135 | 135 | |
136 | - $listItem->fromArray( $this->addListItemDefaults( $list, $pos ) ); |
|
137 | - $listManager->saveItem( $listItem ); |
|
136 | + $listItem->fromArray($this->addListItemDefaults($list, $pos)); |
|
137 | + $listManager->saveItem($listItem); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
141 | - $listManager->deleteItems( array_keys( $listItems ) ); |
|
141 | + $listManager->deleteItems(array_keys($listItems)); |
|
142 | 142 | |
143 | - $remaining = $this->getObject()->process( $product, $data ); |
|
143 | + $remaining = $this->getObject()->process($product, $data); |
|
144 | 144 | |
145 | 145 | $manager->commit(); |
146 | 146 | } |
147 | - catch( \Exception $e ) |
|
147 | + catch (\Exception $e) |
|
148 | 148 | { |
149 | 149 | $manager->rollback(); |
150 | 150 | throw $e; |
@@ -160,11 +160,11 @@ discard block |
||
160 | 160 | * @param array $list Associative list of key/value pairs from the mapped data |
161 | 161 | * @return boolean True if the entry is valid, false if not |
162 | 162 | */ |
163 | - protected function checkEntry( array $list ) |
|
163 | + protected function checkEntry(array $list) |
|
164 | 164 | { |
165 | - if( !isset( $list['attribute.code'] ) || $list['attribute.code'] === '' || $list['attribute.type'] === '' |
|
166 | - || isset( $list['product.lists.type'] ) && $this->listTypes !== null |
|
167 | - && !in_array( $list['product.lists.type'], (array) $this->listTypes ) |
|
165 | + if (!isset($list['attribute.code']) || $list['attribute.code'] === '' || $list['attribute.type'] === '' |
|
166 | + || isset($list['product.lists.type']) && $this->listTypes !== null |
|
167 | + && !in_array($list['product.lists.type'], (array) $this->listTypes) |
|
168 | 168 | ) { |
169 | 169 | return false; |
170 | 170 | } |
@@ -180,22 +180,22 @@ discard block |
||
180 | 180 | * @param string $type Attribute type |
181 | 181 | * @return \Aimeos\MShop\Attribute\Item\Iface Attribute item object |
182 | 182 | */ |
183 | - protected function getAttributeItem( $code, $type ) |
|
183 | + protected function getAttributeItem($code, $type) |
|
184 | 184 | { |
185 | - if( ( $item = $this->cache->get( $code, $type ) ) === null ) |
|
185 | + if (($item = $this->cache->get($code, $type)) === null) |
|
186 | 186 | { |
187 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
187 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
188 | 188 | |
189 | 189 | $item = $manager->createItem(); |
190 | - $item->setTypeId( $this->getTypeId( 'attribute/type', 'product', $type ) ); |
|
191 | - $item->setDomain( 'product' ); |
|
192 | - $item->setLabel( $type . ' ' . $code ); |
|
193 | - $item->setCode( $code ); |
|
194 | - $item->setStatus( 1 ); |
|
190 | + $item->setTypeId($this->getTypeId('attribute/type', 'product', $type)); |
|
191 | + $item->setDomain('product'); |
|
192 | + $item->setLabel($type . ' ' . $code); |
|
193 | + $item->setCode($code); |
|
194 | + $item->setStatus(1); |
|
195 | 195 | |
196 | - $manager->saveItem( $item ); |
|
196 | + $manager->saveItem($item); |
|
197 | 197 | |
198 | - $this->cache->set( $item ); |
|
198 | + $this->cache->set($item); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | return $item; |