2018-10-19 09:30:27 -04:00
|
|
|
<?php declare(strict_types=1);
|
|
|
|
/**
|
|
|
|
* Hummingbird Anime List Client
|
|
|
|
*
|
|
|
|
* An API client for Kitsu to manage anime and manga watch lists
|
|
|
|
*
|
|
|
|
* PHP version 7.1
|
|
|
|
*
|
|
|
|
* @package HummingbirdAnimeClient
|
|
|
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
|
|
|
* @copyright 2015 - 2018 Timothy J. Warren
|
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
|
|
|
* @version 4.1
|
|
|
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Aviat\AnimeClient\Controller;
|
|
|
|
|
|
|
|
use Aviat\AnimeClient\Controller as BaseController;
|
2018-11-08 11:36:42 -05:00
|
|
|
use Aviat\AnimeClient\API\Kitsu\Transformer\PersonTransformer;
|
|
|
|
|
|
|
|
use Aviat\Ion\Di\ContainerInterface;
|
2018-10-19 09:30:27 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Controller for People pages
|
|
|
|
*/
|
|
|
|
final class People extends BaseController {
|
2018-11-08 11:36:42 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var \Aviat\AnimeClient\API\Kitsu\Model
|
|
|
|
*/
|
|
|
|
private $model;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* People constructor.
|
|
|
|
*
|
|
|
|
* @param ContainerInterface $container
|
|
|
|
* @throws \Aviat\Ion\Di\Exception\ContainerException
|
|
|
|
* @throws \Aviat\Ion\Di\Exception\NotFoundException
|
|
|
|
*/
|
|
|
|
public function __construct(ContainerInterface $container)
|
|
|
|
{
|
|
|
|
parent::__construct($container);
|
|
|
|
$this->model = $container->get('kitsu-model');
|
|
|
|
}
|
|
|
|
|
2018-10-19 09:30:27 -04:00
|
|
|
/**
|
|
|
|
* Show information about a person
|
|
|
|
*
|
|
|
|
* @param string $id
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function index(string $id): void
|
|
|
|
{
|
2018-11-08 11:36:42 -05:00
|
|
|
$rawData = $this->model->getPerson($id);
|
|
|
|
$data = (new PersonTransformer())->transform($rawData)->toArray();
|
2018-10-19 09:30:27 -04:00
|
|
|
|
|
|
|
if (( ! array_key_exists('data', $rawData)) || empty($rawData['data']))
|
|
|
|
{
|
|
|
|
$this->notFound(
|
|
|
|
$this->formatTitle(
|
|
|
|
'People',
|
|
|
|
'Person not found'
|
|
|
|
),
|
|
|
|
'Person Not Found'
|
|
|
|
);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-11-08 11:36:42 -05:00
|
|
|
$this->outputHTML('person/details', [
|
2018-10-19 09:30:27 -04:00
|
|
|
'title' => $this->formatTitle(
|
|
|
|
'People',
|
2018-11-08 11:36:42 -05:00
|
|
|
$data['name']
|
2018-10-19 09:30:27 -04:00
|
|
|
),
|
|
|
|
'data' => $data,
|
2018-11-08 11:36:42 -05:00
|
|
|
]);
|
2018-10-19 09:30:27 -04:00
|
|
|
}
|
|
|
|
}
|