From 032ff64a1da11297c1d5acee8358a4275db3522a Mon Sep 17 00:00:00 2001 From: Nathan Boiron Date: Mon, 15 Jul 2024 12:09:50 +0200 Subject: [PATCH] Gestion des articles sans url --- .../Controller/Planete/ArticlesController.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sources/AppBundle/Controller/Planete/ArticlesController.php b/sources/AppBundle/Controller/Planete/ArticlesController.php index 6432b9987..fcf3aa11a 100644 --- a/sources/AppBundle/Controller/Planete/ArticlesController.php +++ b/sources/AppBundle/Controller/Planete/ArticlesController.php @@ -62,13 +62,19 @@ public function __invoke(Request $request): Response private function getArticleUrl(DisplayableFeedArticle $article): string { - if (substr($article->getUrl(), 0, 4) !== 'http') { + $url = $article->getUrl(); + + if ($url === null) { + return ''; + } + + if (substr($url, 0, 4) !== 'http') { $feedUrl = rtrim($article->getFeedUrl(), '/'); - $articleUrl = ltrim($article->getUrl(), '/'); + $articleUrl = ltrim($url, '/'); return implode('/', [$feedUrl, $articleUrl]); } - return $article->getUrl(); + return $url; } }