1111use Magento \Framework \FlagManager ;
1212use Magento \Framework \Stdlib \DateTime \DateTimeFactory ;
1313use Magento \MediaContentSynchronizationApi \Api \SynchronizeIdentitiesInterface ;
14- use Magento \MediaContentSynchronizationApi \Model \SynchronizerIdentitiesPool ;
14+ use Magento \MediaContentSynchronizationApi \Model \SynchronizeIdentitiesPool ;
1515use Psr \Log \LoggerInterface ;
1616
1717/**
1818 * Batch Synchronize content with assets
1919 */
2020class SynchronizeIdentities implements SynchronizeIdentitiesInterface
2121{
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-
3422 /**
3523 * @var LoggerInterface
3624 */
3725 private $ log ;
3826
3927 /**
40- * @var SynchronizerIdentitiesPool
41- */
42- private $ synchronizerIdentitiesPool ;
43-
44- /**
45- * @var RemoveObsoleteContentAsset
28+ * @var SynchronizeIdentitiesPool
4629 */
47- private $ removeObsoleteContent ;
30+ private $ synchronizeIdentitiesPool ;
4831
4932 /**
50- * @param RemoveObsoleteContentAsset $removeObsoleteContent
51- * @param DateTimeFactory $dateFactory
52- * @param FlagManager $flagManager
5333 * @param LoggerInterface $log
54- * @param SynchronizerIdentitiesPool $synchronizerIdentitiesPool
34+ * @param SynchronizeIdentitiesPool $synchronizeIdentitiesPool
5535 */
5636 public function __construct (
57- RemoveObsoleteContentAsset $ removeObsoleteContent ,
58- DateTimeFactory $ dateFactory ,
59- FlagManager $ flagManager ,
6037 LoggerInterface $ log ,
61- SynchronizerIdentitiesPool $ synchronizerIdentitiesPool
38+ SynchronizeIdentitiesPool $ synchronizeIdentitiesPool
6239 ) {
63- $ this ->removeObsoleteContent = $ removeObsoleteContent ;
64- $ this ->dateFactory = $ dateFactory ;
65- $ this ->flagManager = $ flagManager ;
6640 $ this ->log = $ log ;
67- $ this ->synchronizerIdentitiesPool = $ synchronizerIdentitiesPool ;
41+ $ this ->synchronizeIdentitiesPool = $ synchronizeIdentitiesPool ;
6842 }
6943
7044 /**
@@ -74,9 +48,9 @@ public function execute(array $mediaContentIdentities): void
7448 {
7549 $ failed = [];
7650
77- foreach ($ this ->synchronizerIdentitiesPool ->get () as $ name => $ synchronizers ) {
51+ foreach ($ this ->synchronizeIdentitiesPool ->get () as $ name => $ synchronizer ) {
7852 try {
79- $ synchronizers ->execute ($ mediaContentIdentities );
53+ $ synchronizer ->execute ($ mediaContentIdentities );
8054 } catch (\Exception $ exception ) {
8155 $ this ->log ->critical ($ exception );
8256 $ failed [] = $ name ;
@@ -93,17 +67,5 @@ public function execute(array $mediaContentIdentities): void
9367 )
9468 );
9569 }
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 );
10870 }
10971}
0 commit comments