23
23
24
24
/**
25
25
* @codeCoverageIgnore
26
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
26
27
*/
27
28
class UpgradeData implements UpgradeDataInterface
28
29
{
@@ -103,6 +104,13 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
103
104
$ setup ->endSetup ();
104
105
}
105
106
107
+ /**
108
+ * Add existing Downloadable Hosts to env.php
109
+ *
110
+ * @param ModuleDataSetupInterface $setup
111
+ * @return void
112
+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
113
+ */
106
114
private function addDownloadableHostsToConfig (ModuleDataSetupInterface $ setup )
107
115
{
108
116
$ customStoreScope = $ this ->scopeResolver ->getScope (Custom::CONFIG_SCOPE_ID );
@@ -121,6 +129,17 @@ private function addDownloadableHostsToConfig(ModuleDataSetupInterface $setup)
121
129
$ this ->addHost ($ scope ->getBaseUrl (UrlInterface::URL_TYPE_MEDIA , true ));
122
130
$ this ->addHost ($ scope ->getBaseUrl (UrlInterface::URL_TYPE_STATIC , false ));
123
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
+ }
124
143
}
125
144
126
145
$ customAdminUrl = $ this ->scopeConfig ->getValue (
@@ -186,6 +205,10 @@ private function addDownloadableHostsToConfig(ModuleDataSetupInterface $setup)
186
205
*/
187
206
private function addHost ($ url )
188
207
{
208
+ if (!is_string ($ url )) {
209
+ return ;
210
+ }
211
+
189
212
$ host = $ this ->uriHandler ->parse ($ url )->getHost ();
190
213
if ($ host && !in_array ($ host , $ this ->whitelist )) {
191
214
$ this ->whitelist [] = $ host ;
0 commit comments