6
6
7
7
namespace Magento \Downloadable \Setup ;
8
8
9
+ use Magento \Framework \Exception \NoSuchEntityException ;
9
10
use Magento \Store \Model \Store ;
10
11
use Zend \Uri \Uri as UriHandler ;
11
12
use Magento \Downloadable \Api \DomainManagerInterface as DomainManager ;
@@ -109,7 +110,6 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
109
110
*
110
111
* @param ModuleDataSetupInterface $setup
111
112
* @return void
112
- * @SuppressWarnings(PHPMD.CyclomaticComplexity)
113
113
*/
114
114
private function addDownloadableHostsToConfig (ModuleDataSetupInterface $ setup )
115
115
{
@@ -118,28 +118,7 @@ private function addDownloadableHostsToConfig(ModuleDataSetupInterface $setup)
118
118
$ allStoreScopes = array_merge ($ storeScopes , [$ customStoreScope ]);
119
119
120
120
foreach ($ allStoreScopes as $ scope ) {
121
- /** @var $scope Store */
122
- $ this ->addHost ($ scope ->getBaseUrl (UrlInterface::URL_TYPE_WEB , false ));
123
- $ this ->addHost ($ scope ->getBaseUrl (UrlInterface::URL_TYPE_WEB , true ));
124
- $ this ->addHost ($ scope ->getBaseUrl (UrlInterface::URL_TYPE_LINK , false ));
125
- $ this ->addHost ($ scope ->getBaseUrl (UrlInterface::URL_TYPE_LINK , true ));
126
- $ this ->addHost ($ scope ->getBaseUrl (UrlInterface::URL_TYPE_DIRECT_LINK , false ));
127
- $ this ->addHost ($ scope ->getBaseUrl (UrlInterface::URL_TYPE_DIRECT_LINK , true ));
128
- $ this ->addHost ($ scope ->getBaseUrl (UrlInterface::URL_TYPE_MEDIA , false ));
129
- $ this ->addHost ($ scope ->getBaseUrl (UrlInterface::URL_TYPE_MEDIA , true ));
130
- $ this ->addHost ($ scope ->getBaseUrl (UrlInterface::URL_TYPE_STATIC , false ));
131
- $ this ->addHost ($ scope ->getBaseUrl (UrlInterface::URL_TYPE_STATIC , true ));
132
-
133
- if ($ website = $ scope ->getWebsite ()) {
134
- $ this ->addHost ($ website ->getConfig (Store::XML_PATH_SECURE_BASE_URL ));
135
- $ this ->addHost ($ website ->getConfig (Store::XML_PATH_UNSECURE_BASE_URL ));
136
- $ this ->addHost ($ website ->getConfig (Store::XML_PATH_SECURE_BASE_LINK_URL ));
137
- $ this ->addHost ($ website ->getConfig (Store::XML_PATH_UNSECURE_BASE_LINK_URL ));
138
- $ this ->addHost ($ website ->getConfig (Store::XML_PATH_SECURE_BASE_MEDIA_URL ));
139
- $ this ->addHost ($ website ->getConfig (Store::XML_PATH_UNSECURE_BASE_MEDIA_URL ));
140
- $ this ->addHost ($ website ->getConfig (Store::XML_PATH_SECURE_BASE_STATIC_URL ));
141
- $ this ->addHost ($ website ->getConfig (Store::XML_PATH_UNSECURE_BASE_STATIC_URL ));
142
- }
121
+ $ this ->addStoreAndWebsiteUrlsFromScope ($ scope );
143
122
}
144
123
145
124
$ customAdminUrl = $ this ->scopeConfig ->getValue (
@@ -198,6 +177,42 @@ private function addDownloadableHostsToConfig(ModuleDataSetupInterface $setup)
198
177
$ this ->domainManager ->addDomains ($ this ->whitelist );
199
178
}
200
179
180
+ /**
181
+ * Add stores and website urls from store scope
182
+ *
183
+ * @param Store $scope
184
+ */
185
+ private function addStoreAndWebsiteUrlsFromScope (Store $ scope )
186
+ {
187
+ $ this ->addHost ($ scope ->getBaseUrl (UrlInterface::URL_TYPE_WEB , false ));
188
+ $ this ->addHost ($ scope ->getBaseUrl (UrlInterface::URL_TYPE_WEB , true ));
189
+ $ this ->addHost ($ scope ->getBaseUrl (UrlInterface::URL_TYPE_LINK , false ));
190
+ $ this ->addHost ($ scope ->getBaseUrl (UrlInterface::URL_TYPE_LINK , true ));
191
+ $ this ->addHost ($ scope ->getBaseUrl (UrlInterface::URL_TYPE_DIRECT_LINK , false ));
192
+ $ this ->addHost ($ scope ->getBaseUrl (UrlInterface::URL_TYPE_DIRECT_LINK , true ));
193
+ $ this ->addHost ($ scope ->getBaseUrl (UrlInterface::URL_TYPE_MEDIA , false ));
194
+ $ this ->addHost ($ scope ->getBaseUrl (UrlInterface::URL_TYPE_MEDIA , true ));
195
+ $ this ->addHost ($ scope ->getBaseUrl (UrlInterface::URL_TYPE_STATIC , false ));
196
+ $ this ->addHost ($ scope ->getBaseUrl (UrlInterface::URL_TYPE_STATIC , true ));
197
+
198
+ try {
199
+ $ website = $ scope ->getWebsite ();
200
+ } catch (NoSuchEntityException $ e ) {
201
+ return ;
202
+ }
203
+
204
+ if ($ website ) {
205
+ $ this ->addHost ($ website ->getConfig (Store::XML_PATH_SECURE_BASE_URL ));
206
+ $ this ->addHost ($ website ->getConfig (Store::XML_PATH_UNSECURE_BASE_URL ));
207
+ $ this ->addHost ($ website ->getConfig (Store::XML_PATH_SECURE_BASE_LINK_URL ));
208
+ $ this ->addHost ($ website ->getConfig (Store::XML_PATH_UNSECURE_BASE_LINK_URL ));
209
+ $ this ->addHost ($ website ->getConfig (Store::XML_PATH_SECURE_BASE_MEDIA_URL ));
210
+ $ this ->addHost ($ website ->getConfig (Store::XML_PATH_UNSECURE_BASE_MEDIA_URL ));
211
+ $ this ->addHost ($ website ->getConfig (Store::XML_PATH_SECURE_BASE_STATIC_URL ));
212
+ $ this ->addHost ($ website ->getConfig (Store::XML_PATH_UNSECURE_BASE_STATIC_URL ));
213
+ }
214
+ }
215
+
201
216
/**
202
217
* Add host to whitelist
203
218
*
0 commit comments