6
6
namespace Magento \Sitemap \Model ;
7
7
8
8
use Magento \Store \Model \App \Emulation ;
9
- use Magento \ Framework \ App \ ObjectManager ;
9
+
10
10
/**
11
11
* Sitemap module observer
12
12
*
@@ -71,32 +71,31 @@ class Observer
71
71
/**
72
72
* @var \Magento\Store\Model\App\Emulation $appEmulation
73
73
*/
74
- protected $ appEmulation ;
74
+ private $ appEmulation ;
75
75
76
76
/**
77
77
* Observer constructor.
78
- * @param Emulation|null $appEmulation
79
78
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
80
79
* @param ResourceModel\Sitemap\CollectionFactory $collectionFactory
81
80
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
82
81
* @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder
83
82
* @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation
83
+ * @param Emulation|null $appEmulation
84
84
*/
85
85
public function __construct (
86
- Emulation $ appEmulation = null ,
87
86
\Magento \Framework \App \Config \ScopeConfigInterface $ scopeConfig ,
88
- \ Magento \ Sitemap \ Model \ ResourceModel \Sitemap \CollectionFactory $ collectionFactory ,
87
+ ResourceModel \Sitemap \CollectionFactory $ collectionFactory ,
89
88
\Magento \Store \Model \StoreManagerInterface $ storeManager ,
90
89
\Magento \Framework \Mail \Template \TransportBuilder $ transportBuilder ,
91
- \Magento \Framework \Translate \Inline \StateInterface $ inlineTranslation
90
+ \Magento \Framework \Translate \Inline \StateInterface $ inlineTranslation ,
91
+ Emulation $ appEmulation
92
92
) {
93
93
$ this ->_scopeConfig = $ scopeConfig ;
94
94
$ this ->_collectionFactory = $ collectionFactory ;
95
95
$ this ->_storeManager = $ storeManager ;
96
96
$ this ->_transportBuilder = $ transportBuilder ;
97
97
$ this ->inlineTranslation = $ inlineTranslation ;
98
- $ this ->appEmulation = $ appEmulation ?: ObjectManager::getInstance ()
99
- ->get (\Magento \Store \Model \App \Emulation::class);
98
+ $ this ->appEmulation = $ appEmulation ;
100
99
}
101
100
102
101
/**
@@ -124,10 +123,9 @@ public function scheduledGenerateSitemaps()
124
123
foreach ($ collection as $ sitemap ) {
125
124
/* @var $sitemap \Magento\Sitemap\Model\Sitemap */
126
125
try {
127
-
128
126
$ this ->appEmulation ->startEnvironmentEmulation (
129
127
$ sitemap ->getStoreId (),
130
- \ Magento \ Framework \ App \Area:: AREA_FRONTEND ,
128
+ ' frontend ' ,
131
129
true
132
130
);
133
131
@@ -137,7 +135,6 @@ public function scheduledGenerateSitemaps()
137
135
} finally {
138
136
$ this ->appEmulation ->stopEnvironmentEmulation ();
139
137
}
140
-
141
138
}
142
139
143
140
if ($ errors && $ this ->_scopeConfig ->getValue (
0 commit comments