Fix relative logo URL not showing up

This commit is contained in:
dece 2023-05-13 02:22:11 +02:00
parent bae2f78f3f
commit cb21eafa43

View file

@ -14,6 +14,7 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class FeedService
{
protected string $baseFeedUrl;
protected string $baseImageUrl;
public function __construct(
protected EntityManagerInterface $entityManager,
@ -21,11 +22,13 @@ class FeedService
UrlGeneratorInterface $urlGenerator,
)
{
$this->baseFeedUrl = $urlGenerator->generate(
$rootUrl = $urlGenerator->generate(
'app_index',
[],
UrlGeneratorInterface::ABSOLUTE_URL
) . Constants::FILES_BASE_PATH;
);
$this->baseFeedUrl = $rootUrl . Constants::FILES_BASE_PATH;
$this->baseImageUrl = $rootUrl . Constants::IMAGES_BASE_PATH;
}
public const DOCUMENT_VERSION = '2.0';
@ -43,11 +46,14 @@ class FeedService
$titleElement->appendChild(new DOMText($podcast->getName()));
$channelElement->appendChild(new DOMElement('description', $podcast->getDescription()));
$channelElement->appendChild(new DOMElement('link', $podcast->getWebsite()));
$logoFilename = $podcast->getLogoFilename();
if ($logoFilename !== null) {
$imageElement = new DOMElement('image');
$channelElement->appendChild($imageElement);
$imageElement->appendChild(new DOMElement('url', $podcast->getLogoUrl()));
$imageElement->appendChild(new DOMElement('url', $this->baseImageUrl . $logoFilename));
$imageElement->appendChild(new DOMElement('title', 'logo'));
$imageElement->appendChild(new DOMElement('link', $podcast->getWebsite()));
}
$episodes = $this->entityManager->createQuery(
'SELECT e FROM App\Entity\Episode e'