Skip to content

Commit

Permalink
Fix missing items in podcast feed
Browse files Browse the repository at this point in the history
  • Loading branch information
stefansl committed Aug 22, 2024
1 parent c20fd09 commit f97e72b
Showing 1 changed file with 19 additions and 27 deletions.
46 changes: 19 additions & 27 deletions src/NewsPodcasts.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ protected static function generateFiles($arrFeed): void
return;
}

$strType = 'generatePodcastFeed';

$strLink = $arrFeed['feedBase'] ?: Environment::get('base');
$strFile = $arrFeed['feedName'];

Expand Down Expand Up @@ -243,34 +241,27 @@ protected static function generateFiles($arrFeed): void
}

// Get the jumpTo URL
if (!isset($arrUrls[$jumpTo])) {
$objParent = PageModel::findWithDetails($jumpTo);

// A jumpTo page is set but does no longer exist (see #5781)
if (null === $objParent) {
$arrUrls[$jumpTo] = false;
} else {
$objUrlGenerator = System::getContainer()->get('contao.routing.url_generator');
$strUrl = $objUrlGenerator->generate(
($objParent->alias ?: $objParent->id) . '/{items}',
[
'items' => 'example',
'_domain' => $objParent->domain,
'_ssl' => (bool) $objParent->rootUseSSL,
],
UrlGeneratorInterface::ABSOLUTE_URL
);
}
}

// Skip the event if it requires a jumpTo URL but there is none
if (null === ($arrUrls[$jumpTo] ?? null) && 'default' === $objPodcasts->source) {
$objParent = PageModel::findWithDetails($jumpTo);
// A jumpTo page is set but does no longer exist (see #5781)
if ($objParent === null)
{
continue;
}

$objUrlGenerator = System::getContainer()->get('contao.routing.url_generator');
$arrUrls[$jumpTo] = $objUrlGenerator->generate(
($objParent->alias ?: $objParent->id) . '/{items}',
[
'items' => $objPodcasts->alias,
'_domain' => $objParent->domain,
'_ssl' => (bool) $objParent->rootUseSSL,
],
UrlGeneratorInterface::ABSOLUTE_URL
);

$strUrl = $arrUrls[$jumpTo];
$objItem = new \FeedItem();

$objItem = new \FeedItem();
$objItem->id = (int) $objPodcasts->id;
$objItem->guid = (int) $objPodcasts->id;
$objItem->alias = $objPodcasts->alias;
Expand All @@ -285,7 +276,7 @@ protected static function generateFiles($arrFeed): void
$objItem->image = self::generateEpisodeImage($objPodcasts->singleSRC);
}

$objItem->link = $strLink . sprintf(
$objItem->link = sprintf(
$strUrl,
(('' !== $objPodcasts->alias && !$GLOBALS['TL_CONFIG']['disableAlias']) ? $objPodcasts->alias : $objPodcasts->id)
);
Expand Down Expand Up @@ -343,6 +334,7 @@ protected static function generateFiles($arrFeed): void
}
}


$objFeed->addItem($objItem);
}
}
Expand All @@ -355,7 +347,7 @@ protected static function generateFiles($arrFeed): void
File::putContent(
$shareDir . $strFile . '.xml',
// replace insert tags
$parser->replace((string) $objFeed->$strType())
$parser->replace((string) $objFeed->generatePodcastFeed())
);
}

Expand Down

0 comments on commit f97e72b

Please sign in to comment.