Skip to content

Commit

Permalink
Merge pull request #510 from uu-plathome/feature/main-improve-wp-posts
Browse files Browse the repository at this point in the history
feature サイト閉塞やWordPressのサイトがダウンしている場合に、空配列を返却する対応
  • Loading branch information
H37kouya authored Jan 11, 2025
2 parents 418667d + 5504c49 commit 5960f41
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion api/app/UseCases/Main/WordPress/FetchWordPressPostsUsecase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace App\UseCases\Main\WordPress;

use Exception;
use Illuminate\Support\Carbon;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Http;
Expand All @@ -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');

Expand Down

0 comments on commit 5960f41

Please sign in to comment.