Small fixes for anime detail pages

This commit is contained in:
Timothy Warren 2020-07-29 20:06:59 -04:00
parent 7c0ea492e1
commit 7dae2dd6eb

View File

@ -34,6 +34,10 @@ final class AnimeTransformer extends AbstractTransformer {
*/ */
public function transform($item): AnimePage public function transform($item): AnimePage
{ {
// TODO: missing GraphQL data:
// * streaming links
// * show type
$base = array_key_exists('findAnimeBySlug', $item['data']) $base = array_key_exists('findAnimeBySlug', $item['data'])
? $item['data']['findAnimeBySlug'] ? $item['data']['findAnimeBySlug']
: $item['data']['findAnimeById']; : $item['data']['findAnimeById'];
@ -65,6 +69,11 @@ final class AnimeTransformer extends AbstractTransformer {
uasort($characters['main'], fn($a, $b) => $a['name'] <=> $b['name']); uasort($characters['main'], fn($a, $b) => $a['name'] <=> $b['name']);
uasort($characters['supporting'], fn($a, $b) => $a['name'] <=> $b['name']); uasort($characters['supporting'], fn($a, $b) => $a['name'] <=> $b['name']);
if (empty($characters['supporting']))
{
unset($characters['supporting']);
}
} }
if (count($base['staff']['nodes']) > 0) if (count($base['staff']['nodes']) > 0)
@ -94,8 +103,7 @@ final class AnimeTransformer extends AbstractTransformer {
ksort($staff); ksort($staff);
} }
// @TODO: Streaming Links return AnimePage::from([
$data = [
'age_rating' => $base['ageRating'], 'age_rating' => $base['ageRating'],
'age_rating_guide' => $base['ageRatingGuide'], 'age_rating_guide' => $base['ageRatingGuide'],
'characters' => $characters, 'characters' => $characters,
@ -116,8 +124,6 @@ final class AnimeTransformer extends AbstractTransformer {
'total_length' => $base['totalLength'], 'total_length' => $base['totalLength'],
'trailer_id' => $base['youtubeTrailerVideoId'], 'trailer_id' => $base['youtubeTrailerVideoId'],
'url' => "https://kitsu.io/anime/{$base['slug']}", 'url' => "https://kitsu.io/anime/{$base['slug']}",
]; ]);
return AnimePage::from($data);
} }
} }