Commit bf7a6857 authored by Stefan Busemann's avatar Stefan Busemann
Browse files

Merge branch 'task/use-full-url-for-distribution-images' into 'develop'

[BUGFIX] Use full url to the distribution images in XML file

See merge request !658
parents e5f1bab7 f99256b3
Pipeline #11530 passed with stages
in 11 minutes and 27 seconds
......@@ -16,6 +16,8 @@ use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use T3o\Ter\Api\Configuration;
use T3o\Ter\Exception\InternalServerErrorException;
use TYPO3\CMS\Core\Resource\ResourceFactory;
use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
......@@ -117,6 +119,7 @@ class ExtensionIndexService implements LoggerAwareInterface
$dom = new \DOMDocument('1.0', 'utf-8');
$dom->formatOutput = true;
$extensionsObj = $dom->appendChild(new \DOMElement('extensions'));
$distributionBaseUrl = $this->getDistributionBaseUrl();
// Create the nested XML structure:
foreach ($extensionsAndVersionsArr as $extensionKey => $extensionVersionsArr) {
......@@ -144,10 +147,22 @@ class ExtensionIndexService implements LoggerAwareInterface
$distributionImage = $prefixDistributionFilePath . 'Distribution.png';
$distributionWelcomeImage = $prefixDistributionFilePath . 'DistributionWelcome.png';
if (is_file($this->basePath . $distributionImage)) {
$versionObj->appendChild(new \DOMElement('distributionImage', $this->xmlentities($distributionImage)));
$distributionImageUrl = $distributionBaseUrl . $distributionImage;
$versionObj->appendChild(
new \DOMElement(
'distributionImage',
$this->xmlentities($distributionImageUrl)
)
);
}
if (is_file($this->basePath . $distributionWelcomeImage)) {
$versionObj->appendChild(new \DOMElement('distributionImageWelcome', $this->xmlentities($distributionWelcomeImage)));
$distributionWelcomeImageUrl = $distributionBaseUrl . $distributionWelcomeImage;
$versionObj->appendChild(
new \DOMElement(
'distributionImageWelcome',
$this->xmlentities($distributionWelcomeImageUrl)
)
);
}
}
$versionObj->appendChild(
......@@ -239,4 +254,15 @@ class ExtensionIndexService implements LoggerAwareInterface
? (string)serialize(json_decode($dependencies, true))
: '';
}
protected function getDistributionBaseUrl(): string
{
return implode(
'',
[
(string)GeneralUtility::makeInstance(SiteFinder::class)->getSiteByIdentifier('extensions')->getBase() . '/',
GeneralUtility::makeInstance(ResourceFactory::class)->getDefaultStorage()->getFolder('ter')->getPublicUrl()
]
);
}
}
......@@ -134,7 +134,18 @@ class ExtensionIndexServiceTest extends UnitTestCase
</extension>
</extensions>
';
$subject = new ExtensionIndexService(Environment::getVarPath() . '/tests-extensions-xml');
$subject = self::getAccessibleMock(
ExtensionIndexService::class,
['getDistributionBaseUrl'],
[Environment::getVarPath() . '/tests-extensions-xml'],
'',
false
);
$subject
->expects(self::once())
->method('getDistributionBaseUrl')
->willReturn('https://ter.local/fileadmin/ter/');
$extensions = [
'acme' => [
'downloads' => 13,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment