9
9
10
10
use Magento \Cron \Model \Schedule ;
11
11
use Magento \Persistent \Model \DeleteExpiredQuoteFactory ;
12
- use Magento \Framework \App \ObjectManager ;
13
12
use Magento \Persistent \Model \SessionFactory ;
14
13
use Magento \Store \Model \ResourceModel \Website \CollectionFactory ;
15
14
@@ -39,17 +38,16 @@ class ClearExpiredCronJobObserver
39
38
/**
40
39
* @param CollectionFactory $websiteCollectionFactory
41
40
* @param SessionFactory $sessionFactory
42
- * @param DeleteExpiredQuoteFactory|null $deleteExpiredQuoteFactory
41
+ * @param DeleteExpiredQuoteFactory $deleteExpiredQuoteFactory
43
42
*/
44
43
public function __construct (
45
44
CollectionFactory $ websiteCollectionFactory ,
46
45
SessionFactory $ sessionFactory ,
47
- DeleteExpiredQuoteFactory $ deleteExpiredQuoteFactory = null
46
+ DeleteExpiredQuoteFactory $ deleteExpiredQuoteFactory
48
47
) {
49
48
$ this ->_websiteCollectionFactory = $ websiteCollectionFactory ;
50
49
$ this ->_sessionFactory = $ sessionFactory ;
51
- $ this ->deleteExpiredQuoteFactory = $ deleteExpiredQuoteFactory ?:
52
- ObjectManager::getInstance ()->get (DeleteExpiredQuoteFactory::class);
50
+ $ this ->deleteExpiredQuoteFactory = $ deleteExpiredQuoteFactory ;
53
51
}
54
52
55
53
/**
@@ -66,9 +64,10 @@ public function execute(Schedule $schedule)
66
64
return $ this ;
67
65
}
68
66
67
+ $ deleteExpiredQuote = $ this ->deleteExpiredQuoteFactory ->create ();
69
68
foreach ($ websiteIds as $ websiteId ) {
70
69
$ this ->_sessionFactory ->create ()->deleteExpired ($ websiteId );
71
- $ this -> deleteExpiredQuoteFactory -> create () ->deleteExpiredQuote ($ websiteId );
70
+ $ deleteExpiredQuote ->deleteExpiredQuote ($ websiteId );
72
71
}
73
72
74
73
return $ this ;
0 commit comments