66
77namespace Magefan \Community \Model ;
88
9- use Magento \ Framework \ Config \ ConfigOptionsListConstants ;
9+ use Magefan \ Community \ Api \ GetModuleVersionInterface ;
1010
1111/**
1212 * Class AdminNotificationFeed
@@ -40,22 +40,28 @@ class AdminNotificationFeed extends \Magento\AdminNotification\Model\Feed
4040 protected $ config ;
4141
4242 /**
43+ * @var GetModuleVersionInterface
44+ */
45+ private $ getModuleVersion ;
46+
47+ /**
48+ * AdminNotificationFeed constructor.
4349 * @param \Magento\Framework\Model\Context $context
4450 * @param \Magento\Framework\Registry $registry
4551 * @param \Magento\Backend\App\ConfigInterface $backendConfig
46- * @param InboxFactory $inboxFactory
52+ * @param \Magento\AdminNotification\Model\ InboxFactory $inboxFactory
4753 * @param \Magento\Backend\Model\Auth\Session $backendAuthSession
4854 * @param \Magento\Framework\Module\ModuleListInterface $moduleList
49- * @param \Magento\Framework\Module\Manager $moduleManager,
55+ * @param \Magento\Framework\Module\Manager $moduleManager
5056 * @param \Magento\Framework\HTTP\Adapter\CurlFactory $curlFactory
5157 * @param \Magento\Framework\App\DeploymentConfig $deploymentConfig
5258 * @param \Magento\Framework\App\ProductMetadataInterface $productMetadata
5359 * @param \Magento\Framework\UrlInterface $urlBuilder
60+ * @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource
61+ * @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
5462 * @param Config $config
55- * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
56- * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
63+ * @param GetModuleVersionInterface $getModuleVersion
5764 * @param array $data
58- * @SuppressWarnings(PHPMD.ExcessiveParameterList)
5965 */
6066 public function __construct (
6167 \Magento \Framework \Model \Context $ context ,
@@ -71,14 +77,16 @@ public function __construct(
7177 \Magento \Framework \UrlInterface $ urlBuilder ,
7278 \Magento \Framework \Model \ResourceModel \AbstractResource $ resource = null ,
7379 \Magento \Framework \Data \Collection \AbstractDb $ resourceCollection = null ,
74- Config $ config = null ,
80+ Config $ config ,
81+ GetModuleVersionInterface $ getModuleVersion ,
7582 array $ data = []
7683 ) {
7784 parent ::__construct ($ context , $ registry , $ backendConfig , $ inboxFactory , $ curlFactory , $ deploymentConfig , $ productMetadata , $ urlBuilder , $ resource , $ resourceCollection , $ data );
7885 $ this ->_backendAuthSession = $ backendAuthSession ;
7986 $ this ->_moduleList = $ moduleList ;
8087 $ this ->_moduleManager = $ moduleManager ;
81- $ this ->config = $ config ?: \Magento \Framework \App \ObjectManager::getInstance ()->get (Config::class);
88+ $ this ->config = $ config ;
89+ $ this ->getModuleVersion = $ getModuleVersion ;
8290 }
8391
8492 /**
@@ -96,9 +104,9 @@ public function getFeedUrl()
96104 $ domain = isset ($ urlInfo ['host ' ]) ? $ urlInfo ['host ' ] : '' ;
97105 $ url = $ this ->_feedUrl . 'domain/ ' . urlencode ($ domain );
98106 $ modulesParams = [];
99- foreach ($ this ->getMagefanModules () as $ key => $ module ) {
100- $ key = str_replace ('Magefan_ ' , '' , $ key );
101- $ modulesParams [] = $ key . ', ' . $ module [ ' setup_version ' ] ;
107+ foreach ($ this ->getMagefanModules () as $ moduleName => $ module ) {
108+ $ key = str_replace ('Magefan_ ' , '' , $ moduleName );
109+ $ modulesParams [] = $ key . ', ' . $ this -> getModuleVersion -> execute ( $ moduleName ) ;
102110 }
103111 if (count ($ modulesParams )) {
104112 $ url .= '/modules/ ' .base64_encode (implode ('; ' , $ modulesParams ));
@@ -113,7 +121,6 @@ public function getFeedUrl()
113121 if (count ($ notificationsParams )) {
114122 $ url .= '/notifications/ ' . base64_encode (implode ('; ' , $ notificationsParams ));
115123 }
116-
117124 return $ url ;
118125 }
119126
@@ -199,7 +206,10 @@ public function getFeedData()
199206 }
200207
201208 if (!$ getNotification ) {
202- return new \SimpleXMLElement ('<?xml version="1.0" encoding="utf-8" ?> ' );
209+ return new \SimpleXMLElement ('<?xml version="1.0" encoding="utf-8" ?>
210+ <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
211+ <channel></channel>
212+ </rss> ' );
203213 }
204214
205215 return parent ::getFeedData ();
0 commit comments