Small code consistency update
This commit is contained in:
parent
bd4cfaafe1
commit
cf1c55782f
@ -373,8 +373,6 @@ final class Model {
|
||||
}
|
||||
|
||||
return $this->animeTransformer->transform($baseData);
|
||||
// $transformed['included'] = JsonAPI::organizeIncluded($baseData['included']);
|
||||
// return $transformed;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -614,9 +612,7 @@ final class Model {
|
||||
return new MangaPage([]);
|
||||
}
|
||||
|
||||
$transformed = $this->mangaTransformer->transform($baseData);
|
||||
$transformed['included'] = JsonAPI::organizeIncluded($baseData['included']);
|
||||
return $transformed;
|
||||
return $this->mangaTransformer->transform($baseData);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
namespace Aviat\AnimeClient\API\Kitsu\Transformer;
|
||||
|
||||
use Aviat\AnimeClient\API\JsonAPI;
|
||||
use Aviat\AnimeClient\Types\MangaPage;
|
||||
use Aviat\Ion\Transformer\AbstractTransformer;
|
||||
|
||||
@ -35,31 +36,33 @@ final class MangaTransformer extends AbstractTransformer {
|
||||
{
|
||||
$genres = [];
|
||||
|
||||
foreach($item['included'] as $included)
|
||||
{
|
||||
if ($included['type'] === 'categories')
|
||||
{
|
||||
$genres[] = $included['attributes']['title'];
|
||||
}
|
||||
}
|
||||
$item['included'] = JsonAPI::organizeIncluded($item['included']);
|
||||
|
||||
if (array_key_exists('categories', $item['included']))
|
||||
{
|
||||
foreach ($item['included']['categories'] as $cat)
|
||||
{
|
||||
$genres[] = $cat['attributes']['title'];
|
||||
}
|
||||
sort($genres);
|
||||
}
|
||||
|
||||
$title = $item['canonicalTitle'];
|
||||
$rawTitles = array_values($item['titles']);
|
||||
$titles = array_unique(array_diff($rawTitles, [$title]));
|
||||
|
||||
return new MangaPage([
|
||||
'chapter_count' => $this->count($item['chapterCount']),
|
||||
'cover_image' => $item['posterImage']['small'],
|
||||
'genres' => $genres,
|
||||
'id' => $item['id'],
|
||||
'included' => $item['included'],
|
||||
'manga_type' => $item['mangaType'],
|
||||
'synopsis' => $item['synopsis'],
|
||||
'title' => $title,
|
||||
'titles' => $titles,
|
||||
'cover_image' => $item['posterImage']['small'],
|
||||
'manga_type' => $item['mangaType'],
|
||||
'chapter_count' => $this->count($item['chapterCount']),
|
||||
'volume_count' => $this->count($item['volumeCount']),
|
||||
'synopsis' => $item['synopsis'],
|
||||
'url' => "https://kitsu.io/manga/{$item['slug']}",
|
||||
'genres' => $genres,
|
||||
'volume_count' => $this->count($item['volumeCount']),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,68 @@
|
||||
array (
|
||||
),
|
||||
'id' => '20286',
|
||||
'included' =>
|
||||
array (
|
||||
'genres' =>
|
||||
array (
|
||||
3 =>
|
||||
array (
|
||||
'attributes' =>
|
||||
array (
|
||||
'name' => 'Comedy',
|
||||
'slug' => 'comedy',
|
||||
'description' => NULL,
|
||||
),
|
||||
),
|
||||
24 =>
|
||||
array (
|
||||
'attributes' =>
|
||||
array (
|
||||
'name' => 'School',
|
||||
'slug' => 'school',
|
||||
'description' => NULL,
|
||||
),
|
||||
),
|
||||
16 =>
|
||||
array (
|
||||
'attributes' =>
|
||||
array (
|
||||
'name' => 'Slice of Life',
|
||||
'slug' => 'slice-of-life',
|
||||
'description' => '',
|
||||
),
|
||||
),
|
||||
14 =>
|
||||
array (
|
||||
'attributes' =>
|
||||
array (
|
||||
'name' => 'Romance',
|
||||
'slug' => 'romance',
|
||||
'description' => '',
|
||||
),
|
||||
),
|
||||
18 =>
|
||||
array (
|
||||
'attributes' =>
|
||||
array (
|
||||
'name' => 'Thriller',
|
||||
'slug' => 'thriller',
|
||||
'description' => NULL,
|
||||
),
|
||||
),
|
||||
),
|
||||
'mappings' =>
|
||||
array (
|
||||
48014 =>
|
||||
array (
|
||||
'attributes' =>
|
||||
array (
|
||||
'externalSite' => 'myanimelist/manga',
|
||||
'externalId' => '26769',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'manga_type' => 'manga',
|
||||
'synopsis' => 'Usa, a high-school student aspiring to begin a bachelor lifestyle, moves into a new apartment only to discover that he not only shares a room with a perverted roommate that has an obsession for underaged girls, but also that another girl, Ritsu, a love-at-first-sight, is living in the same building as well!
|
||||
(Source: Kirei Cake)',
|
||||
|
Loading…
Reference in New Issue
Block a user