@@ -97,8 +97,7 @@ |
||
97 | 97 | $item->setDateNext( date_create( $item->getTimeCreated() )->add( $interval )->format( 'Y-m-d' ) ); |
98 | 98 | |
99 | 99 | $manager->saveItem( $item ); |
100 | - } |
|
101 | - catch( \Exception $e ) |
|
100 | + } catch( \Exception $e ) |
|
102 | 101 | { |
103 | 102 | $msg = 'Unable to process subscription with ID "%1$S": %2$s'; |
104 | 103 | $logger->log( sprintf( $msg, $item->getId(), $e->getMessage() ) ); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function getName() |
30 | 30 | { |
31 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Subscription process start' ); |
|
31 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Subscription process start'); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function getDescription() |
41 | 41 | { |
42 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Process subscriptions initially' ); |
|
42 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Process subscriptions initially'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -65,50 +65,50 @@ discard block |
||
65 | 65 | * @since 2018.04 |
66 | 66 | * @category Developer |
67 | 67 | */ |
68 | - $names = (array) $config->get( 'controller/common/subscription/process/processors', [] ); |
|
68 | + $names = (array) $config->get('controller/common/subscription/process/processors', []); |
|
69 | 69 | |
70 | - $processors = $this->getProcessors( $names ); |
|
71 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'subscription' ); |
|
70 | + $processors = $this->getProcessors($names); |
|
71 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'subscription'); |
|
72 | 72 | |
73 | - $search = $manager->createSearch( true ); |
|
73 | + $search = $manager->createSearch(true); |
|
74 | 74 | $expr = [ |
75 | - $search->compare( '==', 'subscription.datenext', null ), |
|
75 | + $search->compare('==', 'subscription.datenext', null), |
|
76 | 76 | $search->getConditions(), |
77 | 77 | ]; |
78 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
79 | - $search->setSortations( [$search->sort( '+', 'subscription.id' )] ); |
|
78 | + $search->setConditions($search->combine('&&', $expr)); |
|
79 | + $search->setSortations([$search->sort('+', 'subscription.id')]); |
|
80 | 80 | |
81 | 81 | $start = 0; |
82 | 82 | |
83 | 83 | do |
84 | 84 | { |
85 | - $search->setSlice( $start, 100 ); |
|
86 | - $items = $manager->searchItems( $search ); |
|
85 | + $search->setSlice($start, 100); |
|
86 | + $items = $manager->searchItems($search); |
|
87 | 87 | |
88 | - foreach( $items as $item ) |
|
88 | + foreach ($items as $item) |
|
89 | 89 | { |
90 | 90 | try |
91 | 91 | { |
92 | - foreach( $processors as $processor ) { |
|
93 | - $processor->begin( $item ); |
|
92 | + foreach ($processors as $processor) { |
|
93 | + $processor->begin($item); |
|
94 | 94 | } |
95 | 95 | |
96 | - $interval = new \DateInterval( $item->getInterval() ); |
|
97 | - $item->setDateNext( date_create( $item->getTimeCreated() )->add( $interval )->format( 'Y-m-d' ) ); |
|
96 | + $interval = new \DateInterval($item->getInterval()); |
|
97 | + $item->setDateNext(date_create($item->getTimeCreated())->add($interval)->format('Y-m-d')); |
|
98 | 98 | |
99 | - $manager->saveItem( $item ); |
|
99 | + $manager->saveItem($item); |
|
100 | 100 | } |
101 | - catch( \Exception $e ) |
|
101 | + catch (\Exception $e) |
|
102 | 102 | { |
103 | 103 | $msg = 'Unable to process subscription with ID "%1$S": %2$s'; |
104 | - $logger->log( sprintf( $msg, $item->getId(), $e->getMessage() ) ); |
|
105 | - $logger->log( $e->getTraceAsString() ); |
|
104 | + $logger->log(sprintf($msg, $item->getId(), $e->getMessage())); |
|
105 | + $logger->log($e->getTraceAsString()); |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
109 | - $count = count( $items ); |
|
109 | + $count = count($items); |
|
110 | 110 | $start += $count; |
111 | 111 | } |
112 | - while( $count === $search->getSliceSize() ); |
|
112 | + while ($count === $search->getSliceSize()); |
|
113 | 113 | } |
114 | 114 | } |
@@ -12,13 +12,13 @@ discard block |
||
12 | 12 | { |
13 | 13 | protected function setUp() |
14 | 14 | { |
15 | - \Aimeos\MShop\Factory::setCache( true ); |
|
15 | + \Aimeos\MShop\Factory::setCache(true); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | |
19 | 19 | protected function tearDown() |
20 | 20 | { |
21 | - \Aimeos\MShop\Factory::setCache( false ); |
|
21 | + \Aimeos\MShop\Factory::setCache(false); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | |
@@ -26,29 +26,29 @@ discard block |
||
26 | 26 | { |
27 | 27 | $context = \TestHelperCntl::getContext(); |
28 | 28 | |
29 | - $context->getConfig()->set( 'controller/common/subscription/process/processor/cgroup/groupids', ['1', '2'] ); |
|
29 | + $context->getConfig()->set('controller/common/subscription/process/processor/cgroup/groupids', ['1', '2']); |
|
30 | 30 | |
31 | - $fcn = function( $subject ){ |
|
31 | + $fcn = function($subject) { |
|
32 | 32 | return $subject->getGroups() === ['1', '2']; |
33 | 33 | }; |
34 | 34 | |
35 | - $customerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Customer\\Manager\\Standard' ) |
|
36 | - ->setConstructorArgs( [$context] ) |
|
37 | - ->setMethods( ['getItem', 'saveItem'] ) |
|
35 | + $customerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Customer\\Manager\\Standard') |
|
36 | + ->setConstructorArgs([$context]) |
|
37 | + ->setMethods(['getItem', 'saveItem']) |
|
38 | 38 | ->getMock(); |
39 | 39 | |
40 | - \Aimeos\MShop\Factory::injectManager( $context, 'customer', $customerStub ); |
|
40 | + \Aimeos\MShop\Factory::injectManager($context, 'customer', $customerStub); |
|
41 | 41 | |
42 | 42 | $customerItem = $customerStub->createItem(); |
43 | 43 | |
44 | - $customerStub->expects( $this->once() )->method( 'getItem' ) |
|
45 | - ->will( $this->returnValue( $customerItem ) ); |
|
44 | + $customerStub->expects($this->once())->method('getItem') |
|
45 | + ->will($this->returnValue($customerItem)); |
|
46 | 46 | |
47 | - $customerStub->expects( $this->once() )->method( 'saveItem' ) |
|
48 | - ->with( $this->callback( $fcn ) ); |
|
47 | + $customerStub->expects($this->once())->method('saveItem') |
|
48 | + ->with($this->callback($fcn)); |
|
49 | 49 | |
50 | - $object = new \Aimeos\Controller\Common\Subscription\Process\Processor\Cgroup\Standard( $context ); |
|
51 | - $object->begin( $this->getSubscription( $context ) ); |
|
50 | + $object = new \Aimeos\Controller\Common\Subscription\Process\Processor\Cgroup\Standard($context); |
|
51 | + $object->begin($this->getSubscription($context)); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
@@ -56,45 +56,45 @@ discard block |
||
56 | 56 | { |
57 | 57 | $context = \TestHelperCntl::getContext(); |
58 | 58 | |
59 | - $context->getConfig()->set( 'controller/common/subscription/process/processor/cgroup/groupids', ['1', '2'] ); |
|
59 | + $context->getConfig()->set('controller/common/subscription/process/processor/cgroup/groupids', ['1', '2']); |
|
60 | 60 | |
61 | - $fcn = function( $subject ){ |
|
61 | + $fcn = function($subject) { |
|
62 | 62 | return $subject->getGroups() === []; |
63 | 63 | }; |
64 | 64 | |
65 | - $customerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Customer\\Manager\\Standard' ) |
|
66 | - ->setConstructorArgs( [$context] ) |
|
67 | - ->setMethods( ['getItem', 'saveItem'] ) |
|
65 | + $customerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Customer\\Manager\\Standard') |
|
66 | + ->setConstructorArgs([$context]) |
|
67 | + ->setMethods(['getItem', 'saveItem']) |
|
68 | 68 | ->getMock(); |
69 | 69 | |
70 | - \Aimeos\MShop\Factory::injectManager( $context, 'customer', $customerStub ); |
|
70 | + \Aimeos\MShop\Factory::injectManager($context, 'customer', $customerStub); |
|
71 | 71 | |
72 | - $customerItem = $customerStub->createItem()->setGroups( ['1', '2'] ); |
|
72 | + $customerItem = $customerStub->createItem()->setGroups(['1', '2']); |
|
73 | 73 | |
74 | - $customerStub->expects( $this->once() )->method( 'getItem' ) |
|
75 | - ->will( $this->returnValue( $customerItem ) ); |
|
74 | + $customerStub->expects($this->once())->method('getItem') |
|
75 | + ->will($this->returnValue($customerItem)); |
|
76 | 76 | |
77 | - $customerStub->expects( $this->once() )->method( 'saveItem' ) |
|
78 | - ->with( $this->callback( $fcn ) ); |
|
77 | + $customerStub->expects($this->once())->method('saveItem') |
|
78 | + ->with($this->callback($fcn)); |
|
79 | 79 | |
80 | - $object = new \Aimeos\Controller\Common\Subscription\Process\Processor\Cgroup\Standard( $context ); |
|
81 | - $object->end( $this->getSubscription( $context ) ); |
|
80 | + $object = new \Aimeos\Controller\Common\Subscription\Process\Processor\Cgroup\Standard($context); |
|
81 | + $object->end($this->getSubscription($context)); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | |
85 | - protected function getSubscription( $context ) |
|
85 | + protected function getSubscription($context) |
|
86 | 86 | { |
87 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'subscription' ); |
|
87 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'subscription'); |
|
88 | 88 | |
89 | 89 | $search = $manager->createSearch(); |
90 | - $search->setConditions( $search->compare( '==', 'subscription.dateend', '2010-01-01' ) ); |
|
90 | + $search->setConditions($search->compare('==', 'subscription.dateend', '2010-01-01')); |
|
91 | 91 | |
92 | - $items = $manager->searchItems( $search ); |
|
92 | + $items = $manager->searchItems($search); |
|
93 | 93 | |
94 | - if( ( $item = reset( $items ) ) !== false ) { |
|
94 | + if (($item = reset($items)) !== false) { |
|
95 | 95 | return $item; |
96 | 96 | } |
97 | 97 | |
98 | - throw new \Exception( 'No subscription item found' ); |
|
98 | + throw new \Exception('No subscription item found'); |
|
99 | 99 | } |
100 | 100 | } |
@@ -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/subscription/process/end/name |
35 | 35 | * Class name of the used subscription 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/subscription/process/end/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\\Subscription\\Process\\End\\' . $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\\Subscription\\Process\\End\\' . $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/subscription/process/end/decorators/excludes |
83 | 83 | * Excludes decorators added by the "common" option from the subscription process CSV job controller |
@@ -154,6 +154,6 @@ discard block |
||
154 | 154 | * @see controller/jobs/subscription/process/end/decorators/excludes |
155 | 155 | * @see controller/jobs/subscription/process/end/decorators/global |
156 | 156 | */ |
157 | - return self::addControllerDecorators( $context, $aimeos, $controller, 'subscription/process/end' ); |
|
157 | + return self::addControllerDecorators($context, $aimeos, $controller, 'subscription/process/end'); |
|
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', 'Subscription process end' ); |
|
31 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Subscription process end'); |
|
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', 'Terminates expired subscriptions' ); |
|
42 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Terminates expired subscriptions'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -65,48 +65,48 @@ discard block |
||
65 | 65 | * @since 2018.04 |
66 | 66 | * @category Developer |
67 | 67 | */ |
68 | - $names = (array) $config->get( 'controller/common/subscription/process/processors', [] ); |
|
68 | + $names = (array) $config->get('controller/common/subscription/process/processors', []); |
|
69 | 69 | |
70 | - $processors = $this->getProcessors( $names ); |
|
71 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'subscription' ); |
|
70 | + $processors = $this->getProcessors($names); |
|
71 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'subscription'); |
|
72 | 72 | |
73 | - $search = $manager->createSearch( true ); |
|
73 | + $search = $manager->createSearch(true); |
|
74 | 74 | $expr = [ |
75 | - $search->compare( '<', 'subscription.dateend', date( 'Y-m-d' ) ), |
|
75 | + $search->compare('<', 'subscription.dateend', date('Y-m-d')), |
|
76 | 76 | $search->getConditions(), |
77 | 77 | ]; |
78 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
79 | - $search->setSortations( [$search->sort( '+', 'subscription.id' )] ); |
|
78 | + $search->setConditions($search->combine('&&', $expr)); |
|
79 | + $search->setSortations([$search->sort('+', 'subscription.id')]); |
|
80 | 80 | |
81 | 81 | $start = 0; |
82 | 82 | |
83 | 83 | do |
84 | 84 | { |
85 | - $search->setSlice( $start, 100 ); |
|
86 | - $items = $manager->searchItems( $search ); |
|
85 | + $search->setSlice($start, 100); |
|
86 | + $items = $manager->searchItems($search); |
|
87 | 87 | |
88 | - foreach( $items as $item ) |
|
88 | + foreach ($items as $item) |
|
89 | 89 | { |
90 | 90 | try |
91 | 91 | { |
92 | - foreach( $processors as $processor ) { |
|
93 | - $processor->end( $item ); |
|
92 | + foreach ($processors as $processor) { |
|
93 | + $processor->end($item); |
|
94 | 94 | } |
95 | 95 | |
96 | - $item->setStatus( 0 ); |
|
97 | - $manager->saveItem( $item ); |
|
96 | + $item->setStatus(0); |
|
97 | + $manager->saveItem($item); |
|
98 | 98 | } |
99 | - catch( \Exception $e ) |
|
99 | + catch (\Exception $e) |
|
100 | 100 | { |
101 | 101 | $msg = 'Unable to process subscription with ID "%1$S": %2$s'; |
102 | - $logger->log( sprintf( $msg, $item->getId(), $e->getMessage() ) ); |
|
103 | - $logger->log( $e->getTraceAsString() ); |
|
102 | + $logger->log(sprintf($msg, $item->getId(), $e->getMessage())); |
|
103 | + $logger->log($e->getTraceAsString()); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | - $count = count( $items ); |
|
107 | + $count = count($items); |
|
108 | 108 | $start += $count; |
109 | 109 | } |
110 | - while( $count === $search->getSliceSize() ); |
|
110 | + while ($count === $search->getSliceSize()); |
|
111 | 111 | } |
112 | 112 | } |
@@ -95,8 +95,7 @@ |
||
95 | 95 | |
96 | 96 | $item->setStatus( 0 ); |
97 | 97 | $manager->saveItem( $item ); |
98 | - } |
|
99 | - catch( \Exception $e ) |
|
98 | + } catch( \Exception $e ) |
|
100 | 99 | { |
101 | 100 | $msg = 'Unable to process subscription with ID "%1$S": %2$s'; |
102 | 101 | $logger->log( sprintf( $msg, $item->getId(), $e->getMessage() ) ); |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | $context = \TestHelperJobs::getContext(); |
17 | 17 | $aimeos = \TestHelperJobs::getAimeos(); |
18 | 18 | |
19 | - $obj = \Aimeos\Controller\Jobs\Subscription\Process\End\Factory::createController( $context, $aimeos ); |
|
20 | - $this->assertInstanceOf( '\\Aimeos\\Controller\\Jobs\\Iface', $obj ); |
|
19 | + $obj = \Aimeos\Controller\Jobs\Subscription\Process\End\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\Subscription\Process\End\Factory::createController( $context, $aimeos, 'Wrong$$$Name' ); |
|
29 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
30 | + \Aimeos\Controller\Jobs\Subscription\Process\End\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\Subscription\Process\End\Factory::createController( $context, $aimeos, 'WrongClass' ); |
|
39 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
40 | + \Aimeos\Controller\Jobs\Subscription\Process\End\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\Subscription\Process\End\Factory::createController( $context, $aimeos, 'Factory' ); |
|
49 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
50 | + \Aimeos\Controller\Jobs\Subscription\Process\End\Factory::createController($context, $aimeos, 'Factory'); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | } |
@@ -20,49 +20,49 @@ discard block |
||
20 | 20 | $aimeos = \TestHelperJobs::getAimeos(); |
21 | 21 | $this->context = \TestHelperJobs::getContext(); |
22 | 22 | |
23 | - $this->object = new \Aimeos\Controller\Jobs\Subscription\Process\End\Standard( $this->context, $aimeos ); |
|
23 | + $this->object = new \Aimeos\Controller\Jobs\Subscription\Process\End\Standard($this->context, $aimeos); |
|
24 | 24 | |
25 | - \Aimeos\MShop\Factory::setCache( true ); |
|
25 | + \Aimeos\MShop\Factory::setCache(true); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
29 | 29 | protected function tearDown() |
30 | 30 | { |
31 | - \Aimeos\MShop\Factory::setCache( false ); |
|
31 | + \Aimeos\MShop\Factory::setCache(false); |
|
32 | 32 | \Aimeos\MShop\Factory::clear(); |
33 | 33 | |
34 | - unset( $this->object, $this->context ); |
|
34 | + unset($this->object, $this->context); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
38 | 38 | public function testGetName() |
39 | 39 | { |
40 | - $this->assertEquals( 'Subscription process end', $this->object->getName() ); |
|
40 | + $this->assertEquals('Subscription process end', $this->object->getName()); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
44 | 44 | public function testGetDescription() |
45 | 45 | { |
46 | - $this->assertEquals( 'Terminates expired subscriptions', $this->object->getDescription() ); |
|
46 | + $this->assertEquals('Terminates expired subscriptions', $this->object->getDescription()); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | |
50 | 50 | public function testRun() |
51 | 51 | { |
52 | - $this->context->getConfig()->set( 'controller/common/subscription/process/processors', ['cgroup'] ); |
|
52 | + $this->context->getConfig()->set('controller/common/subscription/process/processors', ['cgroup']); |
|
53 | 53 | $item = $this->getSubscription(); |
54 | 54 | |
55 | - $managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Subscription\\Manager\\Standard' ) |
|
56 | - ->setConstructorArgs( [$this->context] ) |
|
57 | - ->setMethods( ['searchItems', 'saveItem'] ) |
|
55 | + $managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Subscription\\Manager\\Standard') |
|
56 | + ->setConstructorArgs([$this->context]) |
|
57 | + ->setMethods(['searchItems', 'saveItem']) |
|
58 | 58 | ->getMock(); |
59 | 59 | |
60 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'subscription', $managerStub ); |
|
60 | + \Aimeos\MShop\Factory::injectManager($this->context, 'subscription', $managerStub); |
|
61 | 61 | |
62 | - $managerStub->expects( $this->once() )->method( 'searchItems' ) |
|
63 | - ->will( $this->returnValue( [$item] ) ); |
|
62 | + $managerStub->expects($this->once())->method('searchItems') |
|
63 | + ->will($this->returnValue([$item])); |
|
64 | 64 | |
65 | - $managerStub->expects( $this->once() )->method( 'saveItem' ); |
|
65 | + $managerStub->expects($this->once())->method('saveItem'); |
|
66 | 66 | |
67 | 67 | $this->object->run(); |
68 | 68 | } |
@@ -70,20 +70,20 @@ discard block |
||
70 | 70 | |
71 | 71 | public function testRunException() |
72 | 72 | { |
73 | - $this->context->getConfig()->set( 'controller/common/subscription/process/processors', ['cgroup'] ); |
|
74 | - $this->context->getConfig()->set( 'controller/common/subscription/process/processor/cgroup/groupids', ['1'] ); |
|
73 | + $this->context->getConfig()->set('controller/common/subscription/process/processors', ['cgroup']); |
|
74 | + $this->context->getConfig()->set('controller/common/subscription/process/processor/cgroup/groupids', ['1']); |
|
75 | 75 | |
76 | - $managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Subscription\\Manager\\Standard' ) |
|
77 | - ->setConstructorArgs( [$this->context] ) |
|
78 | - ->setMethods( ['searchItems', 'saveItem'] ) |
|
76 | + $managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Subscription\\Manager\\Standard') |
|
77 | + ->setConstructorArgs([$this->context]) |
|
78 | + ->setMethods(['searchItems', 'saveItem']) |
|
79 | 79 | ->getMock(); |
80 | 80 | |
81 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'subscription', $managerStub ); |
|
81 | + \Aimeos\MShop\Factory::injectManager($this->context, 'subscription', $managerStub); |
|
82 | 82 | |
83 | - $managerStub->expects( $this->once() )->method( 'searchItems' ) |
|
84 | - ->will( $this->returnValue( [$managerStub->createItem()] ) ); |
|
83 | + $managerStub->expects($this->once())->method('searchItems') |
|
84 | + ->will($this->returnValue([$managerStub->createItem()])); |
|
85 | 85 | |
86 | - $managerStub->expects( $this->never() )->method( 'saveItem' ); |
|
86 | + $managerStub->expects($this->never())->method('saveItem'); |
|
87 | 87 | |
88 | 88 | $this->object->run(); |
89 | 89 | } |
@@ -91,17 +91,17 @@ discard block |
||
91 | 91 | |
92 | 92 | protected function getSubscription() |
93 | 93 | { |
94 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'subscription' ); |
|
94 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'subscription'); |
|
95 | 95 | |
96 | 96 | $search = $manager->createSearch(); |
97 | - $search->setConditions( $search->compare( '==', 'subscription.dateend', '2010-01-01' ) ); |
|
97 | + $search->setConditions($search->compare('==', 'subscription.dateend', '2010-01-01')); |
|
98 | 98 | |
99 | - $items = $manager->searchItems( $search ); |
|
99 | + $items = $manager->searchItems($search); |
|
100 | 100 | |
101 | - if( ( $item = reset( $items ) ) !== false ) { |
|
101 | + if (($item = reset($items)) !== false) { |
|
102 | 102 | return $item; |
103 | 103 | } |
104 | 104 | |
105 | - throw new \Exception( 'No subscription item found' ); |
|
105 | + throw new \Exception('No subscription item found'); |
|
106 | 106 | } |
107 | 107 | } |
@@ -20,49 +20,49 @@ discard block |
||
20 | 20 | $aimeos = \TestHelperJobs::getAimeos(); |
21 | 21 | $this->context = \TestHelperJobs::getContext(); |
22 | 22 | |
23 | - $this->object = new \Aimeos\Controller\Jobs\Subscription\Process\Begin\Standard( $this->context, $aimeos ); |
|
23 | + $this->object = new \Aimeos\Controller\Jobs\Subscription\Process\Begin\Standard($this->context, $aimeos); |
|
24 | 24 | |
25 | - \Aimeos\MShop\Factory::setCache( true ); |
|
25 | + \Aimeos\MShop\Factory::setCache(true); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
29 | 29 | protected function tearDown() |
30 | 30 | { |
31 | - \Aimeos\MShop\Factory::setCache( false ); |
|
31 | + \Aimeos\MShop\Factory::setCache(false); |
|
32 | 32 | \Aimeos\MShop\Factory::clear(); |
33 | 33 | |
34 | - unset( $this->object, $this->context ); |
|
34 | + unset($this->object, $this->context); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
38 | 38 | public function testGetName() |
39 | 39 | { |
40 | - $this->assertEquals( 'Subscription process start', $this->object->getName() ); |
|
40 | + $this->assertEquals('Subscription process start', $this->object->getName()); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
44 | 44 | public function testGetDescription() |
45 | 45 | { |
46 | - $this->assertEquals( 'Process subscriptions initially', $this->object->getDescription() ); |
|
46 | + $this->assertEquals('Process subscriptions initially', $this->object->getDescription()); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | |
50 | 50 | public function testRun() |
51 | 51 | { |
52 | - $this->context->getConfig()->set( 'controller/common/subscription/process/processors', ['cgroup'] ); |
|
52 | + $this->context->getConfig()->set('controller/common/subscription/process/processors', ['cgroup']); |
|
53 | 53 | $item = $this->getSubscription(); |
54 | 54 | |
55 | - $managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Subscription\\Manager\\Standard' ) |
|
56 | - ->setConstructorArgs( [$this->context] ) |
|
57 | - ->setMethods( ['searchItems', 'saveItem'] ) |
|
55 | + $managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Subscription\\Manager\\Standard') |
|
56 | + ->setConstructorArgs([$this->context]) |
|
57 | + ->setMethods(['searchItems', 'saveItem']) |
|
58 | 58 | ->getMock(); |
59 | 59 | |
60 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'subscription', $managerStub ); |
|
60 | + \Aimeos\MShop\Factory::injectManager($this->context, 'subscription', $managerStub); |
|
61 | 61 | |
62 | - $managerStub->expects( $this->once() )->method( 'searchItems' ) |
|
63 | - ->will( $this->returnValue( [$item] ) ); |
|
62 | + $managerStub->expects($this->once())->method('searchItems') |
|
63 | + ->will($this->returnValue([$item])); |
|
64 | 64 | |
65 | - $managerStub->expects( $this->once() )->method( 'saveItem' ); |
|
65 | + $managerStub->expects($this->once())->method('saveItem'); |
|
66 | 66 | |
67 | 67 | $this->object->run(); |
68 | 68 | } |
@@ -70,20 +70,20 @@ discard block |
||
70 | 70 | |
71 | 71 | public function testRunException() |
72 | 72 | { |
73 | - $this->context->getConfig()->set( 'controller/common/subscription/process/processors', ['cgroup'] ); |
|
74 | - $this->context->getConfig()->set( 'controller/common/subscription/process/processor/cgroup/groupids', ['1'] ); |
|
73 | + $this->context->getConfig()->set('controller/common/subscription/process/processors', ['cgroup']); |
|
74 | + $this->context->getConfig()->set('controller/common/subscription/process/processor/cgroup/groupids', ['1']); |
|
75 | 75 | |
76 | - $managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Subscription\\Manager\\Standard' ) |
|
77 | - ->setConstructorArgs( [$this->context] ) |
|
78 | - ->setMethods( ['searchItems', 'saveItem'] ) |
|
76 | + $managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Subscription\\Manager\\Standard') |
|
77 | + ->setConstructorArgs([$this->context]) |
|
78 | + ->setMethods(['searchItems', 'saveItem']) |
|
79 | 79 | ->getMock(); |
80 | 80 | |
81 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'subscription', $managerStub ); |
|
81 | + \Aimeos\MShop\Factory::injectManager($this->context, 'subscription', $managerStub); |
|
82 | 82 | |
83 | - $managerStub->expects( $this->once() )->method( 'searchItems' ) |
|
84 | - ->will( $this->returnValue( [$managerStub->createItem()] ) ); |
|
83 | + $managerStub->expects($this->once())->method('searchItems') |
|
84 | + ->will($this->returnValue([$managerStub->createItem()])); |
|
85 | 85 | |
86 | - $managerStub->expects( $this->never() )->method( 'saveItem' ); |
|
86 | + $managerStub->expects($this->never())->method('saveItem'); |
|
87 | 87 | |
88 | 88 | $this->object->run(); |
89 | 89 | } |
@@ -91,17 +91,17 @@ discard block |
||
91 | 91 | |
92 | 92 | protected function getSubscription() |
93 | 93 | { |
94 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'subscription' ); |
|
94 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'subscription'); |
|
95 | 95 | |
96 | 96 | $search = $manager->createSearch(); |
97 | - $search->setConditions( $search->compare( '==', 'subscription.dateend', '2010-01-01' ) ); |
|
97 | + $search->setConditions($search->compare('==', 'subscription.dateend', '2010-01-01')); |
|
98 | 98 | |
99 | - $items = $manager->searchItems( $search ); |
|
99 | + $items = $manager->searchItems($search); |
|
100 | 100 | |
101 | - if( ( $item = reset( $items ) ) !== false ) { |
|
101 | + if (($item = reset($items)) !== false) { |
|
102 | 102 | return $item; |
103 | 103 | } |
104 | 104 | |
105 | - throw new \Exception( 'No subscription item found' ); |
|
105 | + throw new \Exception('No subscription item found'); |
|
106 | 106 | } |
107 | 107 | } |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | $context = \TestHelperJobs::getContext(); |
17 | 17 | $aimeos = \TestHelperJobs::getAimeos(); |
18 | 18 | |
19 | - $obj = \Aimeos\Controller\Jobs\Subscription\Process\Renew\Factory::createController( $context, $aimeos ); |
|
20 | - $this->assertInstanceOf( '\\Aimeos\\Controller\\Jobs\\Iface', $obj ); |
|
19 | + $obj = \Aimeos\Controller\Jobs\Subscription\Process\Renew\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\Subscription\Process\Renew\Factory::createController( $context, $aimeos, 'Wrong$$$Name' ); |
|
29 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
30 | + \Aimeos\Controller\Jobs\Subscription\Process\Renew\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\Subscription\Process\Renew\Factory::createController( $context, $aimeos, 'WrongClass' ); |
|
39 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
40 | + \Aimeos\Controller\Jobs\Subscription\Process\Renew\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\Subscription\Process\Renew\Factory::createController( $context, $aimeos, 'Factory' ); |
|
49 | + $this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception'); |
|
50 | + \Aimeos\Controller\Jobs\Subscription\Process\Renew\Factory::createController($context, $aimeos, 'Factory'); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | } |
@@ -97,8 +97,7 @@ discard block |
||
97 | 97 | $item->setDateNext( date_create( $item->getTimeCreated() )->add( $interval )->format( 'Y-m-d' ) ); |
98 | 98 | |
99 | 99 | $manager->saveItem( $item ); |
100 | - } |
|
101 | - catch( \Exception $e ) |
|
100 | + } catch( \Exception $e ) |
|
102 | 101 | { |
103 | 102 | $msg = 'Unable to process subscription with ID "%1$S": %2$s'; |
104 | 103 | $logger->log( sprintf( $msg, $item->getId(), $e->getMessage() ) ); |
@@ -141,8 +140,7 @@ discard block |
||
141 | 140 | |
142 | 141 | $context->setUserId( $baseItem->getCustomerId() ); |
143 | 142 | $context->setGroupIds( $customerItem->getGroups() ); |
144 | - } |
|
145 | - catch( \Exception $e ) {} // Subscription without account |
|
143 | + } catch( \Exception $e ) {} // Subscription without account |
|
146 | 144 | |
147 | 145 | return $context; |
148 | 146 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function getName() |
30 | 30 | { |
31 | - return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Subscription process renew' ); |
|
31 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Subscription process renew'); |
|
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', 'Renews subscriptions at next date' ); |
|
42 | + return $this->getContext()->getI18n()->dt('controller/jobs', 'Renews subscriptions at next date'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -54,62 +54,62 @@ discard block |
||
54 | 54 | $config = $context->getConfig(); |
55 | 55 | $logger = $context->getLogger(); |
56 | 56 | |
57 | - $names = (array) $config->get( 'controller/common/subscription/process/processors', [] ); |
|
57 | + $names = (array) $config->get('controller/common/subscription/process/processors', []); |
|
58 | 58 | |
59 | - $date = date( 'Y-m-d' ); |
|
60 | - $processors = $this->getProcessors( $names ); |
|
61 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'subscription' ); |
|
59 | + $date = date('Y-m-d'); |
|
60 | + $processors = $this->getProcessors($names); |
|
61 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'subscription'); |
|
62 | 62 | |
63 | - $search = $manager->createSearch( true ); |
|
63 | + $search = $manager->createSearch(true); |
|
64 | 64 | $expr = [ |
65 | - $search->compare( '<=', 'subscription.datenext', $date ), |
|
66 | - $search->combine( '||', [ |
|
67 | - $search->compare( '==', 'subscription.dateend', null ), |
|
68 | - $search->compare( '>', 'subscription.dateend', $date ), |
|
69 | - ] ), |
|
65 | + $search->compare('<=', 'subscription.datenext', $date), |
|
66 | + $search->combine('||', [ |
|
67 | + $search->compare('==', 'subscription.dateend', null), |
|
68 | + $search->compare('>', 'subscription.dateend', $date), |
|
69 | + ]), |
|
70 | 70 | $search->getConditions(), |
71 | 71 | ]; |
72 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
73 | - $search->setSortations( [$search->sort( '+', 'subscription.id' )] ); |
|
72 | + $search->setConditions($search->combine('&&', $expr)); |
|
73 | + $search->setSortations([$search->sort('+', 'subscription.id')]); |
|
74 | 74 | |
75 | 75 | $start = 0; |
76 | 76 | |
77 | 77 | do |
78 | 78 | { |
79 | - $search->setSlice( $start, 100 ); |
|
80 | - $items = $manager->searchItems( $search ); |
|
79 | + $search->setSlice($start, 100); |
|
80 | + $items = $manager->searchItems($search); |
|
81 | 81 | |
82 | - foreach( $items as $item ) |
|
82 | + foreach ($items as $item) |
|
83 | 83 | { |
84 | 84 | try |
85 | 85 | { |
86 | - $context = $this->createContext( $item->getOrderBaseId() ); |
|
87 | - $newOrder = $this->createOrderBase( $context, $item ); |
|
88 | - $newInvoice = $this->createOrderInvoice( $context, $newOrder ); |
|
86 | + $context = $this->createContext($item->getOrderBaseId()); |
|
87 | + $newOrder = $this->createOrderBase($context, $item); |
|
88 | + $newInvoice = $this->createOrderInvoice($context, $newOrder); |
|
89 | 89 | |
90 | - $this->createPayment( $context, $newOrder, $newInvoice ); |
|
90 | + $this->createPayment($context, $newOrder, $newInvoice); |
|
91 | 91 | |
92 | - foreach( $processors as $processor ) { |
|
93 | - $processor->renew( $item, $newInvoice ); |
|
92 | + foreach ($processors as $processor) { |
|
93 | + $processor->renew($item, $newInvoice); |
|
94 | 94 | } |
95 | 95 | |
96 | - $interval = new \DateInterval( $item->getInterval() ); |
|
97 | - $item->setDateNext( date_create( $item->getTimeCreated() )->add( $interval )->format( 'Y-m-d' ) ); |
|
96 | + $interval = new \DateInterval($item->getInterval()); |
|
97 | + $item->setDateNext(date_create($item->getTimeCreated())->add($interval)->format('Y-m-d')); |
|
98 | 98 | |
99 | - $manager->saveItem( $item ); |
|
99 | + $manager->saveItem($item); |
|
100 | 100 | } |
101 | - catch( \Exception $e ) |
|
101 | + catch (\Exception $e) |
|
102 | 102 | { |
103 | 103 | $msg = 'Unable to process subscription with ID "%1$S": %2$s'; |
104 | - $logger->log( sprintf( $msg, $item->getId(), $e->getMessage() ) ); |
|
105 | - $logger->log( $e->getTraceAsString() ); |
|
104 | + $logger->log(sprintf($msg, $item->getId(), $e->getMessage())); |
|
105 | + $logger->log($e->getTraceAsString()); |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
109 | - $count = count( $items ); |
|
109 | + $count = count($items); |
|
110 | 110 | $start += $count; |
111 | 111 | } |
112 | - while( $count === $search->getSliceSize() ); |
|
112 | + while ($count === $search->getSliceSize()); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | |
@@ -119,30 +119,30 @@ discard block |
||
119 | 119 | * @param string $baseId Unique order base ID |
120 | 120 | * @return \Aimeos\MShop\Context\Item\Iface New context object |
121 | 121 | */ |
122 | - protected function createContext( $baseId ) |
|
122 | + protected function createContext($baseId) |
|
123 | 123 | { |
124 | 124 | $context = clone $this->getContext(); |
125 | 125 | |
126 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' ); |
|
127 | - $baseItem = $manager->getItem( $baseId ); |
|
126 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'order/base'); |
|
127 | + $baseItem = $manager->getItem($baseId); |
|
128 | 128 | |
129 | 129 | $locale = $baseItem->getLocale(); |
130 | 130 | $level = \Aimeos\MShop\Locale\Manager\Base::SITE_ALL; |
131 | 131 | |
132 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'locale' ); |
|
133 | - $locale = $manager->bootstrap( $baseItem->getSiteCode(), $locale->getLanguageId(), $locale->getCurrencyId(), false, $level ); |
|
132 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'locale'); |
|
133 | + $locale = $manager->bootstrap($baseItem->getSiteCode(), $locale->getLanguageId(), $locale->getCurrencyId(), false, $level); |
|
134 | 134 | |
135 | - $context->setLocale( $locale ); |
|
135 | + $context->setLocale($locale); |
|
136 | 136 | |
137 | 137 | try |
138 | 138 | { |
139 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer' ); |
|
140 | - $customerItem = $manager->getItem( $baseItem->getCustomerId(), ['customer/group'] ); |
|
139 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer'); |
|
140 | + $customerItem = $manager->getItem($baseItem->getCustomerId(), ['customer/group']); |
|
141 | 141 | |
142 | - $context->setUserId( $baseItem->getCustomerId() ); |
|
143 | - $context->setGroupIds( $customerItem->getGroups() ); |
|
142 | + $context->setUserId($baseItem->getCustomerId()); |
|
143 | + $context->setGroupIds($customerItem->getGroups()); |
|
144 | 144 | } |
145 | - catch( \Exception $e ) {} // Subscription without account |
|
145 | + catch (\Exception $e) {} // Subscription without account |
|
146 | 146 | |
147 | 147 | return $context; |
148 | 148 | } |
@@ -155,36 +155,36 @@ discard block |
||
155 | 155 | * @param \Aimeos\MShop\Subscription\Item\Iface $subscription Subscription item with order base ID and order product ID |
156 | 156 | * @return \Aimeos\MShop\Order\Item\Base\Iface Complete order with product, addresses and services saved to the storage |
157 | 157 | */ |
158 | - protected function createOrderBase( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Subscription\Item\Iface $subscription ) |
|
158 | + protected function createOrderBase(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Subscription\Item\Iface $subscription) |
|
159 | 159 | { |
160 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' ); |
|
160 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'order/base'); |
|
161 | 161 | |
162 | - $basket = $manager->load( $subscription->getOrderBaseId() ); |
|
162 | + $basket = $manager->load($subscription->getOrderBaseId()); |
|
163 | 163 | |
164 | 164 | $newBasket = $manager->createItem(); |
165 | - $newBasket->setCustomerId( $basket->getCustomerId() ); |
|
165 | + $newBasket->setCustomerId($basket->getCustomerId()); |
|
166 | 166 | |
167 | - foreach( $basket->getProducts() as $orderProduct ) |
|
167 | + foreach ($basket->getProducts() as $orderProduct) |
|
168 | 168 | { |
169 | - if( $orderProduct->getId() === $subscription->getOrderProductId() ) |
|
169 | + if ($orderProduct->getId() === $subscription->getOrderProductId()) |
|
170 | 170 | { |
171 | - $orderProduct->setId( null ); |
|
172 | - $newBasket->addProduct( $orderProduct ); |
|
171 | + $orderProduct->setId(null); |
|
172 | + $newBasket->addProduct($orderProduct); |
|
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
176 | - foreach( $basket->getAddresses() as $type => $orderAddress ) { |
|
177 | - $newBasket->setAddress( $orderAddress, $type ); |
|
176 | + foreach ($basket->getAddresses() as $type => $orderAddress) { |
|
177 | + $newBasket->setAddress($orderAddress, $type); |
|
178 | 178 | } |
179 | 179 | |
180 | - foreach( $basket->getServices() as $type => $orderServices ) |
|
180 | + foreach ($basket->getServices() as $type => $orderServices) |
|
181 | 181 | { |
182 | - foreach( $orderServices as $orderService ) { |
|
183 | - $newBasket->addService( $orderService, $type ); |
|
182 | + foreach ($orderServices as $orderService) { |
|
183 | + $newBasket->addService($orderService, $type); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
187 | - return $manager->store( $newBasket ); |
|
187 | + return $manager->store($newBasket); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | |
@@ -195,15 +195,15 @@ discard block |
||
195 | 195 | * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Complete order with product, addresses and services saved to the storage |
196 | 196 | * @return \Aimeos\MShop\Order\Item\Iface New invoice item associated to the order saved to the storage |
197 | 197 | */ |
198 | - protected function createOrderInvoice( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket ) |
|
198 | + protected function createOrderInvoice(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket) |
|
199 | 199 | { |
200 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'order' ); |
|
200 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'order'); |
|
201 | 201 | |
202 | 202 | $item = $manager->createItem(); |
203 | - $item->setBaseId( $basket->getId() ); |
|
204 | - $item->setType( 'subscription' ); |
|
203 | + $item->setBaseId($basket->getId()); |
|
204 | + $item->setType('subscription'); |
|
205 | 205 | |
206 | - return $manager->saveItem( $item ); |
|
206 | + return $manager->saveItem($item); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | |
@@ -214,17 +214,17 @@ discard block |
||
214 | 214 | * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Complete order with product, addresses and services |
215 | 215 | * @param \Aimeos\MShop\Order\Item\Iface New invoice item associated to the order |
216 | 216 | */ |
217 | - protected function createPayment( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket, |
|
218 | - \Aimeos\MShop\Order\Item\Iface $invoice ) |
|
217 | + protected function createPayment(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket, |
|
218 | + \Aimeos\MShop\Order\Item\Iface $invoice) |
|
219 | 219 | { |
220 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'service' ); |
|
220 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'service'); |
|
221 | 221 | |
222 | - foreach( $basket->getService( \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT ) as $service ) |
|
222 | + foreach ($basket->getService(\Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT) as $service) |
|
223 | 223 | { |
224 | - $item = $manager->getItem( $service->getServiceId() ); |
|
225 | - $provider = $manager->getProvider( $item, 'payment' ); |
|
224 | + $item = $manager->getItem($service->getServiceId()); |
|
225 | + $provider = $manager->getProvider($item, 'payment'); |
|
226 | 226 | |
227 | - $provider->repay( $invoice ); |
|
227 | + $provider->repay($invoice); |
|
228 | 228 | } |
229 | 229 | } |
230 | 230 | } |