Skip to content

Commit 16f11f7

Browse files
committed
Fix failed static tests
1 parent d5b0ffd commit 16f11f7

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

app/code/Magento/Sitemap/Model/Observer.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Magento\Sitemap\Model;
77

88
use Magento\Store\Model\App\Emulation;
9-
use Magento\Framework\App\ObjectManager;
9+
1010
/**
1111
* Sitemap module observer
1212
*
@@ -71,32 +71,31 @@ class Observer
7171
/**
7272
* @var \Magento\Store\Model\App\Emulation $appEmulation
7373
*/
74-
protected $appEmulation;
74+
private $appEmulation;
7575

7676
/**
7777
* Observer constructor.
78-
* @param Emulation|null $appEmulation
7978
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
8079
* @param ResourceModel\Sitemap\CollectionFactory $collectionFactory
8180
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
8281
* @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder
8382
* @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation
83+
* @param Emulation|null $appEmulation
8484
*/
8585
public function __construct(
86-
Emulation $appEmulation = null,
8786
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
88-
\Magento\Sitemap\Model\ResourceModel\Sitemap\CollectionFactory $collectionFactory,
87+
ResourceModel\Sitemap\CollectionFactory $collectionFactory,
8988
\Magento\Store\Model\StoreManagerInterface $storeManager,
9089
\Magento\Framework\Mail\Template\TransportBuilder $transportBuilder,
91-
\Magento\Framework\Translate\Inline\StateInterface $inlineTranslation
90+
\Magento\Framework\Translate\Inline\StateInterface $inlineTranslation,
91+
Emulation $appEmulation
9292
) {
9393
$this->_scopeConfig = $scopeConfig;
9494
$this->_collectionFactory = $collectionFactory;
9595
$this->_storeManager = $storeManager;
9696
$this->_transportBuilder = $transportBuilder;
9797
$this->inlineTranslation = $inlineTranslation;
98-
$this->appEmulation = $appEmulation ?: ObjectManager::getInstance()
99-
->get(\Magento\Store\Model\App\Emulation::class);
98+
$this->appEmulation = $appEmulation;
10099
}
101100

102101
/**
@@ -124,10 +123,9 @@ public function scheduledGenerateSitemaps()
124123
foreach ($collection as $sitemap) {
125124
/* @var $sitemap \Magento\Sitemap\Model\Sitemap */
126125
try {
127-
128126
$this->appEmulation->startEnvironmentEmulation(
129127
$sitemap->getStoreId(),
130-
\Magento\Framework\App\Area::AREA_FRONTEND,
128+
'frontend',
131129
true
132130
);
133131

@@ -137,7 +135,6 @@ public function scheduledGenerateSitemaps()
137135
} finally {
138136
$this->appEmulation->stopEnvironmentEmulation();
139137
}
140-
141138
}
142139

143140
if ($errors && $this->_scopeConfig->getValue(

0 commit comments

Comments
 (0)