@@ -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 | } |
@@ -32,8 +32,8 @@ discard block |
||
| 32 | 32 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value |
| 33 | 33 | * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor |
| 34 | 34 | */ |
| 35 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
| 36 | - \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null ) |
|
| 35 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
| 36 | + \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null) |
|
| 37 | 37 | { |
| 38 | 38 | $this->context = $context; |
| 39 | 39 | $this->mapping = $mapping; |
@@ -48,13 +48,13 @@ discard block |
||
| 48 | 48 | * @param integer $pos Computed position of the list item in the associated list of items |
| 49 | 49 | * @return array Given associative list enriched by default values if they were not already set |
| 50 | 50 | */ |
| 51 | - protected function addListItemDefaults( array $list, $pos ) |
|
| 51 | + protected function addListItemDefaults(array $list, $pos) |
|
| 52 | 52 | { |
| 53 | - if( !isset( $list['product.lists.position'] ) ) { |
|
| 53 | + if (!isset($list['product.lists.position'])) { |
|
| 54 | 54 | $list['product.lists.position'] = $pos; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - if( !isset( $list['product.lists.status'] ) ) { |
|
| 57 | + if (!isset($list['product.lists.status'])) { |
|
| 58 | 58 | $list['product.lists.status'] = 1; |
| 59 | 59 | } |
| 60 | 60 | |
@@ -92,8 +92,8 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | protected function getObject() |
| 94 | 94 | { |
| 95 | - if( $this->object === null ) { |
|
| 96 | - throw new \Aimeos\Controller\Jobs\Exception( 'No processor object available' ); |
|
| 95 | + if ($this->object === null) { |
|
| 96 | + throw new \Aimeos\Controller\Jobs\Exception('No processor object available'); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | return $this->object; |
@@ -108,8 +108,8 @@ discard block |
||
| 108 | 108 | * @param mixed $default Default value if key isn't found |
| 109 | 109 | * @param mixed Value for the key in the list of the default value |
| 110 | 110 | */ |
| 111 | - protected function getValue( array $list, $key, $default ) |
|
| 111 | + protected function getValue(array $list, $key, $default) |
|
| 112 | 112 | { |
| 113 | - return ( isset( $list[$key] ) ? $list[$key] : $default ); |
|
| 113 | + return (isset($list[$key]) ? $list[$key] : $default); |
|
| 114 | 114 | } |
| 115 | 115 | } |
@@ -42,12 +42,12 @@ discard block |
||
| 42 | 42 | * @param array $mapping Associative list of field position in CSV as key and domain item key as value |
| 43 | 43 | * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object Decorated processor |
| 44 | 44 | */ |
| 45 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
| 46 | - \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null ) |
|
| 45 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
| 46 | + \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $object = null) |
|
| 47 | 47 | { |
| 48 | - parent::__construct( $context, $mapping, $object ); |
|
| 48 | + parent::__construct($context, $mapping, $object); |
|
| 49 | 49 | |
| 50 | - $this->cache = $this->getCache( 'stocktype' ); |
|
| 50 | + $this->cache = $this->getCache('stocktype'); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | |
@@ -58,53 +58,53 @@ discard block |
||
| 58 | 58 | * @param array $data List of CSV fields with position as key and data as value |
| 59 | 59 | * @return array List of data which hasn't been imported |
| 60 | 60 | */ |
| 61 | - public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data ) |
|
| 61 | + public function process(\Aimeos\MShop\Product\Item\Iface $product, array $data) |
|
| 62 | 62 | { |
| 63 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'stock' ); |
|
| 63 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'stock'); |
|
| 64 | 64 | $manager->begin(); |
| 65 | 65 | |
| 66 | 66 | try |
| 67 | 67 | { |
| 68 | - $map = $this->getMappedChunk( $data, $this->getMapping() ); |
|
| 69 | - $items = $this->getStockItems( $product->getCode() ); |
|
| 68 | + $map = $this->getMappedChunk($data, $this->getMapping()); |
|
| 69 | + $items = $this->getStockItems($product->getCode()); |
|
| 70 | 70 | |
| 71 | - foreach( $map as $pos => $list ) |
|
| 71 | + foreach ($map as $pos => $list) |
|
| 72 | 72 | { |
| 73 | - if( !array_key_exists( 'stock.stocklevel', $list ) ) { |
|
| 73 | + if (!array_key_exists('stock.stocklevel', $list)) { |
|
| 74 | 74 | continue; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - $stockType = ( isset( $list['stock.type'] ) ? $list['stock.type'] : 'default' ); |
|
| 77 | + $stockType = (isset($list['stock.type']) ? $list['stock.type'] : 'default'); |
|
| 78 | 78 | |
| 79 | - if( !isset( $list['stock.typeid'] ) ) { |
|
| 80 | - $list['stock.typeid'] = $this->cache->get( $stockType ); |
|
| 79 | + if (!isset($list['stock.typeid'])) { |
|
| 80 | + $list['stock.typeid'] = $this->cache->get($stockType); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - if( isset( $list['stock.dateback'] ) && $list['stock.dateback'] === '' ) { |
|
| 83 | + if (isset($list['stock.dateback']) && $list['stock.dateback'] === '') { |
|
| 84 | 84 | $list['stock.dateback'] = null; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - if( $list['stock.stocklevel'] === '' ) { |
|
| 87 | + if ($list['stock.stocklevel'] === '') { |
|
| 88 | 88 | $list['stock.stocklevel'] = null; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | $list['stock.productcode'] = $product->getCode(); |
| 92 | 92 | |
| 93 | - if( ( $item = array_pop( $items ) ) === null ) { |
|
| 93 | + if (($item = array_pop($items)) === null) { |
|
| 94 | 94 | $item = $manager->createItem(); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - $item->fromArray( $list ); |
|
| 98 | - $manager->saveItem( $item ); |
|
| 97 | + $item->fromArray($list); |
|
| 98 | + $manager->saveItem($item); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - $manager->deleteItems( array_keys( $items ) ); |
|
| 101 | + $manager->deleteItems(array_keys($items)); |
|
| 102 | 102 | |
| 103 | - $data = $this->getObject()->process( $product, $data ); |
|
| 103 | + $data = $this->getObject()->process($product, $data); |
|
| 104 | 104 | |
| 105 | 105 | $manager->commit(); |
| 106 | 106 | } |
| 107 | - catch( \Exception $e ) |
|
| 107 | + catch (\Exception $e) |
|
| 108 | 108 | { |
| 109 | 109 | $manager->rollback(); |
| 110 | 110 | throw $e; |
@@ -120,13 +120,13 @@ discard block |
||
| 120 | 120 | * @param string $code Unique product code |
| 121 | 121 | * @return \Aimeos\MShop\Stock\Item\Iface[] Associative list of stock items |
| 122 | 122 | */ |
| 123 | - protected function getStockItems( $code ) |
|
| 123 | + protected function getStockItems($code) |
|
| 124 | 124 | { |
| 125 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'stock' ); |
|
| 125 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'stock'); |
|
| 126 | 126 | |
| 127 | 127 | $search = $manager->createSearch(); |
| 128 | - $search->setConditions( $search->compare( '==', 'stock.productcode', $code ) ); |
|
| 128 | + $search->setConditions($search->compare('==', 'stock.productcode', $code)); |
|
| 129 | 129 | |
| 130 | - return $manager->searchItems( $search ); |
|
| 130 | + return $manager->searchItems($search); |
|
| 131 | 131 | } |
| 132 | 132 | } |
@@ -22,12 +22,12 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | protected function setUp() |
| 24 | 24 | { |
| 25 | - \Aimeos\MShop\Factory::setCache( true ); |
|
| 25 | + \Aimeos\MShop\Factory::setCache(true); |
|
| 26 | 26 | |
| 27 | 27 | $this->context = \TestHelperJobs::getContext(); |
| 28 | 28 | $this->aimeos = \TestHelperJobs::getAimeos(); |
| 29 | 29 | |
| 30 | - $this->object = new \Aimeos\Controller\Jobs\Product\Export\Sitemap\Standard( $this->context, $this->aimeos ); |
|
| 30 | + $this->object = new \Aimeos\Controller\Jobs\Product\Export\Sitemap\Standard($this->context, $this->aimeos); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | protected function tearDown() |
| 41 | 41 | { |
| 42 | - \Aimeos\MShop\Factory::setCache( false ); |
|
| 42 | + \Aimeos\MShop\Factory::setCache(false); |
|
| 43 | 43 | \Aimeos\MShop\Factory::clear(); |
| 44 | 44 | |
| 45 | 45 | $this->object = null; |
@@ -48,14 +48,14 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | public function testGetName() |
| 50 | 50 | { |
| 51 | - $this->assertEquals( 'Product site map', $this->object->getName() ); |
|
| 51 | + $this->assertEquals('Product site map', $this->object->getName()); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | |
| 55 | 55 | public function testGetDescription() |
| 56 | 56 | { |
| 57 | 57 | $text = 'Creates a product site map for search engines'; |
| 58 | - $this->assertEquals( $text, $this->object->getDescription() ); |
|
| 58 | + $this->assertEquals($text, $this->object->getDescription()); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | |
@@ -64,22 +64,22 @@ discard block |
||
| 64 | 64 | $this->object->run(); |
| 65 | 65 | |
| 66 | 66 | $ds = DIRECTORY_SEPARATOR; |
| 67 | - $this->assertFileExists( 'tmp' . $ds . 'aimeos-sitemap-1.xml.gz' ); |
|
| 68 | - $this->assertFileExists( 'tmp' . $ds . 'aimeos-sitemap-2.xml.gz' ); |
|
| 69 | - $this->assertFileExists( 'tmp' . $ds . 'aimeos-sitemap-index.xml.gz' ); |
|
| 67 | + $this->assertFileExists('tmp' . $ds . 'aimeos-sitemap-1.xml.gz'); |
|
| 68 | + $this->assertFileExists('tmp' . $ds . 'aimeos-sitemap-2.xml.gz'); |
|
| 69 | + $this->assertFileExists('tmp' . $ds . 'aimeos-sitemap-index.xml.gz'); |
|
| 70 | 70 | |
| 71 | - $file1 = gzread( gzopen( 'tmp' . $ds . 'aimeos-sitemap-1.xml.gz', 'rb' ), 0x1000 ); |
|
| 72 | - $file2 = gzread( gzopen( 'tmp' . $ds . 'aimeos-sitemap-2.xml.gz', 'rb' ), 0x1000 ); |
|
| 73 | - $index = gzread( gzopen( 'tmp' . $ds . 'aimeos-sitemap-index.xml.gz', 'rb' ), 0x1000 ); |
|
| 71 | + $file1 = gzread(gzopen('tmp' . $ds . 'aimeos-sitemap-1.xml.gz', 'rb'), 0x1000); |
|
| 72 | + $file2 = gzread(gzopen('tmp' . $ds . 'aimeos-sitemap-2.xml.gz', 'rb'), 0x1000); |
|
| 73 | + $index = gzread(gzopen('tmp' . $ds . 'aimeos-sitemap-index.xml.gz', 'rb'), 0x1000); |
|
| 74 | 74 | |
| 75 | - unlink( 'tmp' . $ds . 'aimeos-sitemap-1.xml.gz' ); |
|
| 76 | - unlink( 'tmp' . $ds . 'aimeos-sitemap-2.xml.gz' ); |
|
| 77 | - unlink( 'tmp' . $ds . 'aimeos-sitemap-index.xml.gz' ); |
|
| 75 | + unlink('tmp' . $ds . 'aimeos-sitemap-1.xml.gz'); |
|
| 76 | + unlink('tmp' . $ds . 'aimeos-sitemap-2.xml.gz'); |
|
| 77 | + unlink('tmp' . $ds . 'aimeos-sitemap-index.xml.gz'); |
|
| 78 | 78 | |
| 79 | - $this->assertContains( 'Cafe_Noire_Expresso', $file1 ); |
|
| 80 | - $this->assertContains( 'Unittest%3A_Bundle', $file2 ); |
|
| 79 | + $this->assertContains('Cafe_Noire_Expresso', $file1); |
|
| 80 | + $this->assertContains('Unittest%3A_Bundle', $file2); |
|
| 81 | 81 | |
| 82 | - $this->assertContains( 'aimeos-sitemap-1.xml.gz', $index ); |
|
| 83 | - $this->assertContains( 'aimeos-sitemap-2.xml.gz', $index ); |
|
| 82 | + $this->assertContains('aimeos-sitemap-1.xml.gz', $index); |
|
| 83 | + $this->assertContains('aimeos-sitemap-2.xml.gz', $index); |
|
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | \ No newline at end of file |