Skip to content

Commit c4bc58e

Browse files
committed
MC-17701: Downloadable Product links
1 parent f8f141e commit c4bc58e

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

app/code/Magento/Downloadable/Setup/UpgradeData.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
/**
2525
* @codeCoverageIgnore
26+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2627
*/
2728
class UpgradeData implements UpgradeDataInterface
2829
{
@@ -103,6 +104,13 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
103104
$setup->endSetup();
104105
}
105106

107+
/**
108+
* Add existing Downloadable Hosts to env.php
109+
*
110+
* @param ModuleDataSetupInterface $setup
111+
* @return void
112+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
113+
*/
106114
private function addDownloadableHostsToConfig(ModuleDataSetupInterface $setup)
107115
{
108116
$customStoreScope = $this->scopeResolver->getScope(Custom::CONFIG_SCOPE_ID);
@@ -121,6 +129,17 @@ private function addDownloadableHostsToConfig(ModuleDataSetupInterface $setup)
121129
$this->addHost($scope->getBaseUrl(UrlInterface::URL_TYPE_MEDIA, true));
122130
$this->addHost($scope->getBaseUrl(UrlInterface::URL_TYPE_STATIC, false));
123131
$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+
}
124143
}
125144

126145
$customAdminUrl = $this->scopeConfig->getValue(
@@ -186,6 +205,10 @@ private function addDownloadableHostsToConfig(ModuleDataSetupInterface $setup)
186205
*/
187206
private function addHost($url)
188207
{
208+
if (!is_string($url)) {
209+
return;
210+
}
211+
189212
$host = $this->uriHandler->parse($url)->getHost();
190213
if ($host && !in_array($host, $this->whitelist)) {
191214
$this->whitelist[] = $host;

0 commit comments

Comments
 (0)