Version 5.1 - All the GraphQL #32
@ -1,4 +1,4 @@
|
|||||||
<main>
|
<main>
|
||||||
<h1>404</h1>
|
<h1>404</h1>
|
||||||
<h2>Page Not Found</h2>
|
<h2><?= $message ?></h2>
|
||||||
</main>
|
</main>
|
||||||
|
@ -196,8 +196,13 @@ class Model {
|
|||||||
*/
|
*/
|
||||||
public function getAnime(string $slug): array
|
public function getAnime(string $slug): array
|
||||||
{
|
{
|
||||||
// @TODO catch non-existent anime
|
|
||||||
$baseData = $this->getRawMediaData('anime', $slug);
|
$baseData = $this->getRawMediaData('anime', $slug);
|
||||||
|
|
||||||
|
if (empty($baseData))
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
$transformed = $this->animeTransformer->transform($baseData);
|
$transformed = $this->animeTransformer->transform($baseData);
|
||||||
$transformed['included'] = $baseData['included'];
|
$transformed['included'] = $baseData['included'];
|
||||||
return $transformed;
|
return $transformed;
|
||||||
@ -657,6 +662,12 @@ class Model {
|
|||||||
];
|
];
|
||||||
|
|
||||||
$data = $this->getRequest($type, $options);
|
$data = $this->getRequest($type, $options);
|
||||||
|
|
||||||
|
if (empty($data['data']))
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
$baseData = $data['data'][0]['attributes'];
|
$baseData = $data['data'][0]['attributes'];
|
||||||
$baseData['included'] = $data['included'];
|
$baseData['included'] = $data['included'];
|
||||||
return $baseData;
|
return $baseData;
|
||||||
|
@ -263,6 +263,16 @@ class Anime extends BaseController {
|
|||||||
$data = $this->model->getAnime($animeId);
|
$data = $this->model->getAnime($animeId);
|
||||||
$characters = [];
|
$characters = [];
|
||||||
|
|
||||||
|
if (empty($data))
|
||||||
|
{
|
||||||
|
return $this->notFound(
|
||||||
|
$this->config->get('whose_list') .
|
||||||
|
"'s Anime List · Anime · " .
|
||||||
|
'Anime not found',
|
||||||
|
'Anime Not Found'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
foreach($data['included'] as $included)
|
foreach($data['included'] as $included)
|
||||||
{
|
{
|
||||||
if ($included['type'] === 'characters')
|
if ($included['type'] === 'characters')
|
||||||
|
@ -26,9 +26,14 @@ class Character extends BaseController {
|
|||||||
|
|
||||||
$data = $model->getCharacter($slug);
|
$data = $model->getCharacter($slug);
|
||||||
|
|
||||||
if ( ! array_key_exists('data', $data))
|
if (( ! array_key_exists('data', $data)) || empty($data['data']))
|
||||||
{
|
{
|
||||||
return $this->notFound();
|
return $this->notFound(
|
||||||
|
$this->config->get('whose_list') .
|
||||||
|
"'s Anime List · Characters · " .
|
||||||
|
'Character not found',
|
||||||
|
'Character Not Found'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// $this->outputJSON($data);
|
// $this->outputJSON($data);
|
||||||
|
@ -234,10 +234,14 @@ trait ControllerTrait {
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function notFound()
|
public function notFound(
|
||||||
|
string $title = 'Sorry, page not found',
|
||||||
|
string $message = 'Page Not Found'
|
||||||
|
)
|
||||||
{
|
{
|
||||||
$this->outputHTML('404', [
|
$this->outputHTML('404', [
|
||||||
'title' => 'Sorry, page not found'
|
'title' => $title,
|
||||||
|
'message' => $message,
|
||||||
], NULL, 404);
|
], NULL, 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user