2017-03-30 16:49:48 -04:00
|
|
|
<?php declare(strict_types=1);
|
|
|
|
/**
|
|
|
|
* Hummingbird Anime List Client
|
|
|
|
*
|
|
|
|
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
|
|
|
|
*
|
|
|
|
* PHP version 7
|
|
|
|
*
|
|
|
|
* @package HummingbirdAnimeClient
|
|
|
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
|
|
|
* @copyright 2015 - 2017 Timothy J. Warren
|
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
|
|
|
* @version 4.0
|
|
|
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
|
|
|
*/
|
|
|
|
|
2017-03-08 12:55:49 -05:00
|
|
|
namespace Aviat\AnimeClient\Controller;
|
|
|
|
|
|
|
|
use Aviat\AnimeClient\Controller as BaseController;
|
|
|
|
|
2017-03-27 10:09:45 -04:00
|
|
|
/**
|
|
|
|
* Controller for character description pages
|
|
|
|
*/
|
2017-03-08 12:55:49 -05:00
|
|
|
class Character extends BaseController {
|
|
|
|
|
|
|
|
public function index(string $slug)
|
|
|
|
{
|
|
|
|
$model = $this->container->get('kitsu-model');
|
|
|
|
|
|
|
|
$data = $model->getCharacter($slug);
|
|
|
|
|
2017-03-24 09:08:39 -04:00
|
|
|
if (( ! array_key_exists('data', $data)) || empty($data['data']))
|
2017-03-08 12:55:49 -05:00
|
|
|
{
|
2017-03-24 09:08:39 -04:00
|
|
|
return $this->notFound(
|
2017-03-24 09:58:27 -04:00
|
|
|
$this->formatTitle(
|
|
|
|
'Characters',
|
|
|
|
'Character not found'
|
|
|
|
),
|
2017-03-24 09:08:39 -04:00
|
|
|
'Character Not Found'
|
|
|
|
);
|
2017-03-08 12:55:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
$this->outputHTML('character', [
|
2017-03-24 09:58:27 -04:00
|
|
|
'title' => $this->formatTitle(
|
|
|
|
'Characters',
|
|
|
|
$data['data'][0]['attributes']['name']
|
|
|
|
),
|
2017-03-08 12:55:49 -05:00
|
|
|
'data' => $data['data'][0]['attributes']
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|