From 5504c49e971ba2146e68c84a02d4eccbf19e9472 Mon Sep 17 00:00:00 2001 From: H37kouya Date: Mon, 30 Dec 2024 08:43:45 +0900 Subject: [PATCH] =?UTF-8?q?feature=20=E3=82=B5=E3=82=A4=E3=83=88=E9=96=89?= =?UTF-8?q?=E5=A1=9E=E3=82=84WordPress=E3=81=AE=E3=82=B5=E3=82=A4=E3=83=88?= =?UTF-8?q?=E3=81=8C=E3=83=80=E3=82=A6=E3=83=B3=E3=81=97=E3=81=A6=E3=81=84?= =?UTF-8?q?=E3=82=8B=E5=A0=B4=E5=90=88=E3=81=AB=E3=80=81=E7=A9=BA=E9=85=8D?= =?UTF-8?q?=E5=88=97=E3=82=92=E8=BF=94=E5=8D=B4=E3=81=99=E3=82=8B=E5=AF=BE?= =?UTF-8?q?=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WordPress/FetchWordPressPostsUsecase.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/api/app/UseCases/Main/WordPress/FetchWordPressPostsUsecase.php b/api/app/UseCases/Main/WordPress/FetchWordPressPostsUsecase.php index 6f93459e..cad813be 100644 --- a/api/app/UseCases/Main/WordPress/FetchWordPressPostsUsecase.php +++ b/api/app/UseCases/Main/WordPress/FetchWordPressPostsUsecase.php @@ -4,6 +4,7 @@ namespace App\UseCases\Main\WordPress; +use Exception; use Illuminate\Support\Carbon; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Http; @@ -15,10 +16,24 @@ final class FetchWordPressPostsUsecase const MAX_FETCH_NUMBER = 4; + public function invoke(string $wpUrl, ?string $tagsTaxonomy) : array + { + // サイト閉塞やWordPressのサイトがダウンしている場合に、空配列を返却する。 + try { + return $this->getWordPressPosts($wpUrl, $tagsTaxonomy); + } catch (Exception $e) { + return [ + 'postsNotTags' => [], + 'postsExistTags' => [], + 'medias' => [], + ]; + } + } + /** * 最新のWordPressの記事を6件取得する. */ - public function invoke(string $wpUrl, ?string $tagsTaxonomy): array + public function getWordPressPosts(string $wpUrl, ?string $tagsTaxonomy): array { Log::debug('FetchUuYellArticlesUsecase args none');