11
11
use Magento \Framework \FlagManager ;
12
12
use Magento \Framework \Stdlib \DateTime \DateTimeFactory ;
13
13
use Magento \MediaContentSynchronizationApi \Api \SynchronizeIdentitiesInterface ;
14
- use Magento \MediaContentSynchronizationApi \Model \SynchronizerIdentitiesPool ;
14
+ use Magento \MediaContentSynchronizationApi \Model \SynchronizeIdentitiesPool ;
15
15
use Psr \Log \LoggerInterface ;
16
16
17
17
/**
18
18
* Batch Synchronize content with assets
19
19
*/
20
20
class SynchronizeIdentities implements SynchronizeIdentitiesInterface
21
21
{
22
- private const LAST_EXECUTION_TIME_CODE = 'media_content_last_execution ' ;
23
-
24
- /**
25
- * @var DateTimeFactory
26
- */
27
- private $ dateFactory ;
28
-
29
- /**
30
- * @var FlagManager
31
- */
32
- private $ flagManager ;
33
-
34
22
/**
35
23
* @var LoggerInterface
36
24
*/
37
25
private $ log ;
38
26
39
27
/**
40
- * @var SynchronizerIdentitiesPool
41
- */
42
- private $ synchronizerIdentitiesPool ;
43
-
44
- /**
45
- * @var RemoveObsoleteContentAsset
28
+ * @var SynchronizeIdentitiesPool
46
29
*/
47
- private $ removeObsoleteContent ;
30
+ private $ synchronizeIdentitiesPool ;
48
31
49
32
/**
50
- * @param RemoveObsoleteContentAsset $removeObsoleteContent
51
- * @param DateTimeFactory $dateFactory
52
- * @param FlagManager $flagManager
53
33
* @param LoggerInterface $log
54
- * @param SynchronizerIdentitiesPool $synchronizerIdentitiesPool
34
+ * @param SynchronizeIdentitiesPool $synchronizeIdentitiesPool
55
35
*/
56
36
public function __construct (
57
- RemoveObsoleteContentAsset $ removeObsoleteContent ,
58
- DateTimeFactory $ dateFactory ,
59
- FlagManager $ flagManager ,
60
37
LoggerInterface $ log ,
61
- SynchronizerIdentitiesPool $ synchronizerIdentitiesPool
38
+ SynchronizeIdentitiesPool $ synchronizeIdentitiesPool
62
39
) {
63
- $ this ->removeObsoleteContent = $ removeObsoleteContent ;
64
- $ this ->dateFactory = $ dateFactory ;
65
- $ this ->flagManager = $ flagManager ;
66
40
$ this ->log = $ log ;
67
- $ this ->synchronizerIdentitiesPool = $ synchronizerIdentitiesPool ;
41
+ $ this ->synchronizeIdentitiesPool = $ synchronizeIdentitiesPool ;
68
42
}
69
43
70
44
/**
@@ -74,9 +48,9 @@ public function execute(array $mediaContentIdentities): void
74
48
{
75
49
$ failed = [];
76
50
77
- foreach ($ this ->synchronizerIdentitiesPool ->get () as $ name => $ synchronizers ) {
51
+ foreach ($ this ->synchronizeIdentitiesPool ->get () as $ name => $ synchronizer ) {
78
52
try {
79
- $ synchronizers ->execute ($ mediaContentIdentities );
53
+ $ synchronizer ->execute ($ mediaContentIdentities );
80
54
} catch (\Exception $ exception ) {
81
55
$ this ->log ->critical ($ exception );
82
56
$ failed [] = $ name ;
@@ -93,17 +67,5 @@ public function execute(array $mediaContentIdentities): void
93
67
)
94
68
);
95
69
}
96
-
97
- $ this ->setLastExecutionTime ();
98
- $ this ->removeObsoleteContent ->execute ();
99
- }
100
-
101
- /**
102
- * Set last synchronizer execution time
103
- */
104
- private function setLastExecutionTime (): void
105
- {
106
- $ currentTime = $ this ->dateFactory ->create ()->gmtDate ();
107
- $ this ->flagManager ->saveFlag (self ::LAST_EXECUTION_TIME_CODE , $ currentTime );
108
70
}
109
71
}
0 commit comments