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