From 16f11f760b89bb240ce2f6948214da5775695d92 Mon Sep 17 00:00:00 2001 From: NazarKlovanych Date: Fri, 7 Dec 2018 14:11:16 +0200 Subject: [PATCH] Fix failed static tests --- app/code/Magento/Sitemap/Model/Observer.php | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/app/code/Magento/Sitemap/Model/Observer.php b/app/code/Magento/Sitemap/Model/Observer.php index 54b36ddaa278b..62d7a5ab124e5 100644 --- a/app/code/Magento/Sitemap/Model/Observer.php +++ b/app/code/Magento/Sitemap/Model/Observer.php @@ -6,7 +6,7 @@ namespace Magento\Sitemap\Model; use Magento\Store\Model\App\Emulation; -use Magento\Framework\App\ObjectManager; + /** * Sitemap module observer * @@ -71,32 +71,31 @@ class Observer /** * @var \Magento\Store\Model\App\Emulation $appEmulation */ - protected $appEmulation; + private $appEmulation; /** * Observer constructor. - * @param Emulation|null $appEmulation * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param ResourceModel\Sitemap\CollectionFactory $collectionFactory * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder * @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation + * @param Emulation|null $appEmulation */ public function __construct( - Emulation $appEmulation = null, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Sitemap\Model\ResourceModel\Sitemap\CollectionFactory $collectionFactory, + ResourceModel\Sitemap\CollectionFactory $collectionFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, - \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation + \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation, + Emulation $appEmulation ) { $this->_scopeConfig = $scopeConfig; $this->_collectionFactory = $collectionFactory; $this->_storeManager = $storeManager; $this->_transportBuilder = $transportBuilder; $this->inlineTranslation = $inlineTranslation; - $this->appEmulation = $appEmulation ?: ObjectManager::getInstance() - ->get(\Magento\Store\Model\App\Emulation::class); + $this->appEmulation = $appEmulation; } /** @@ -124,10 +123,9 @@ public function scheduledGenerateSitemaps() foreach ($collection as $sitemap) { /* @var $sitemap \Magento\Sitemap\Model\Sitemap */ try { - $this->appEmulation->startEnvironmentEmulation( $sitemap->getStoreId(), - \Magento\Framework\App\Area::AREA_FRONTEND, + 'frontend', true ); @@ -137,7 +135,6 @@ public function scheduledGenerateSitemaps() } finally { $this->appEmulation->stopEnvironmentEmulation(); } - } if ($errors && $this->_scopeConfig->getValue(