3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+ declare (strict_types=1 );
6
7
7
8
namespace Magento \Downloadable \Observer ;
8
9
9
10
use Magento \Framework \Event \ObserverInterface ;
10
11
11
12
/**
12
- * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
13
+ * Class UpdateLinkPurchasedObserver
14
+ * Assign Downloadable links to customer created after issuing guest order.
13
15
*/
14
16
class UpdateLinkPurchasedObserver implements ObserverInterface
15
17
{
16
18
/**
17
19
* Core store config
18
20
* @var \Magento\Framework\App\Config\ScopeConfigInterface
19
21
*/
20
- protected $ _scopeConfig ;
22
+ private $ scopeConfig ;
21
23
22
24
/**
23
25
* @var \Magento\Downloadable\Model\ResourceModel\Link\Purchased\CollectionFactory
24
26
*/
25
- protected $ _purchasedFactory ;
27
+ private $ purchasedFactory ;
26
28
27
29
/**
28
30
* @var \Magento\Framework\DataObject\Copy
29
31
*/
30
- protected $ _objectCopyService ;
32
+ private $ objectCopyService ;
31
33
32
34
/**
33
35
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
@@ -39,9 +41,9 @@ public function __construct(
39
41
\Magento \Downloadable \Model \ResourceModel \Link \Purchased \CollectionFactory $ purchasedFactory ,
40
42
\Magento \Framework \DataObject \Copy $ objectCopyService
41
43
) {
42
- $ this ->_scopeConfig = $ scopeConfig ;
43
- $ this ->_purchasedFactory = $ purchasedFactory ;
44
- $ this ->_objectCopyService = $ objectCopyService ;
44
+ $ this ->scopeConfig = $ scopeConfig ;
45
+ $ this ->purchasedFactory = $ purchasedFactory ;
46
+ $ this ->objectCopyService = $ objectCopyService ;
45
47
}
46
48
47
49
/**
@@ -58,13 +60,13 @@ public function execute(\Magento\Framework\Event\Observer $observer)
58
60
return $ this ;
59
61
}
60
62
61
- $ purchasedLinks = $ this ->_createPurchasedCollection ()->addFieldToFilter (
63
+ $ purchasedLinks = $ this ->purchasedFactory -> create ()->addFieldToFilter (
62
64
'order_id ' ,
63
65
['eq ' => $ order ->getId ()]
64
66
);
65
67
66
68
foreach ($ purchasedLinks as $ linkPurchased ) {
67
- $ this ->_objectCopyService ->copyFieldsetToTarget (
69
+ $ this ->objectCopyService ->copyFieldsetToTarget (
68
70
\downloadable_sales_copy_order::class,
69
71
'to_downloadable ' ,
70
72
$ order ,
@@ -75,12 +77,4 @@ public function execute(\Magento\Framework\Event\Observer $observer)
75
77
76
78
return $ this ;
77
79
}
78
-
79
- /**
80
- * @return \Magento\Downloadable\Model\ResourceModel\Link\Purchased\Collection
81
- */
82
- protected function _createPurchasedCollection ()
83
- {
84
- return $ this ->_purchasedFactory ->create ();
85
- }
86
80
}
0 commit comments