develop #23

Manually merged
timw4mail merged 7 commits from develop into master 2019-08-16 10:39:59 -04:00
5 changed files with 65 additions and 29 deletions
Showing only changes of commit 27160bda9a - Show all commits

View File

@ -299,28 +299,40 @@ final class Anime extends BaseController {
*/ */
public function details(string $animeId): void public function details(string $animeId): void
{ {
$data = $this->model->getAnime($animeId); try
{
$data = $this->model->getAnime($animeId);
if (empty($data)) if ($data->isEmpty())
{
$this->notFound(
$this->config->get('whose_list') .
"'s Anime List · Anime · " .
'Anime not found',
'Anime Not Found'
);
return;
}
$this->outputHTML('anime/details', [
'title' => $this->formatTitle(
$this->config->get('whose_list') . "'s Anime List",
'Anime',
$data->title
),
'data' => $data,
]);
}
catch (\TypeError $e)
{ {
$this->notFound( $this->notFound(
$this->config->get('whose_list') . $this->config->get('whose_list') .
"'s Anime List · Anime · " . "'s Anime List · Anime · " .
'Anime not found', 'Anime not found',
'Anime Not Found' 'Anime Not Found'
); );
return;
} }
$this->outputHTML('anime/details', [
'title' => $this->formatTitle(
$this->config->get('whose_list') . "'s Anime List",
'Anime',
$data->title
),
'data' => $data,
]);
} }
/** /**

View File

@ -304,7 +304,7 @@ final class Manga extends Controller {
$staff = []; $staff = [];
$characters = []; $characters = [];
if (empty($data)) if ($data->isEmpty())
{ {
$this->notFound( $this->notFound(
$this->config->get('whose_list') . $this->config->get('whose_list') .

View File

@ -166,7 +166,7 @@ class Anime extends API {
$requester = new ParallelAPIRequest(); $requester = new ParallelAPIRequest();
$requester->addRequest($this->kitsuModel->createListItem($data), 'kitsu'); $requester->addRequest($this->kitsuModel->createListItem($data), 'kitsu');
if ($data['mal_id'] !== null && $this->anilistEnabled) if ($this->anilistEnabled && $data['mal_id'] !== null)
{ {
$requester->addRequest($this->anilistModel->createListItem($data, 'ANIME'), 'anilist'); $requester->addRequest($this->anilistModel->createListItem($data, 'ANIME'), 'anilist');
} }
@ -187,9 +187,7 @@ class Anime extends API {
$requester = new ParallelAPIRequest(); $requester = new ParallelAPIRequest();
$requester->addRequest($this->kitsuModel->incrementListItem($data), 'kitsu'); $requester->addRequest($this->kitsuModel->incrementListItem($data), 'kitsu');
$array = $data->toArray(); if ($this->anilistEnabled && $data['mal_id'] !== null)
if ($array['mal_id'] !== null && $this->anilistEnabled)
{ {
$requester->addRequest($this->anilistModel->incrementListItem($data, 'ANIME'), 'anilist'); $requester->addRequest($this->anilistModel->incrementListItem($data, 'ANIME'), 'anilist');
} }
@ -216,9 +214,7 @@ class Anime extends API {
$requester = new ParallelAPIRequest(); $requester = new ParallelAPIRequest();
$requester->addRequest($this->kitsuModel->updateListItem($data), 'kitsu'); $requester->addRequest($this->kitsuModel->updateListItem($data), 'kitsu');
$array = $data->toArray(); if ($this->anilistEnabled && $data['mal_id'] !== null)
if ($array['mal_id'] !== null && $this->anilistEnabled)
{ {
$requester->addRequest($this->anilistModel->updateListItem($data, 'ANIME'), 'anilist'); $requester->addRequest($this->anilistModel->updateListItem($data, 'ANIME'), 'anilist');
} }
@ -246,7 +242,7 @@ class Anime extends API {
$requester = new ParallelAPIRequest(); $requester = new ParallelAPIRequest();
$requester->addRequest($this->kitsuModel->deleteListItem($id), 'kitsu'); $requester->addRequest($this->kitsuModel->deleteListItem($id), 'kitsu');
if ($malId !== null && $this->anilistEnabled) if ($this->anilistEnabled && $malId !== null)
{ {
$requester->addRequest($this->anilistModel->deleteListItem($malId, 'ANIME'), 'anilist'); $requester->addRequest($this->anilistModel->deleteListItem($malId, 'ANIME'), 'anilist');
} }

View File

@ -136,7 +136,7 @@ class Manga extends API {
$requester = new ParallelAPIRequest(); $requester = new ParallelAPIRequest();
$requester->addRequest($this->kitsuModel->createListItem($data), 'kitsu'); $requester->addRequest($this->kitsuModel->createListItem($data), 'kitsu');
if (array_key_exists('mal_id', $data) && $this->anilistEnabled) if ($this->anilistEnabled && array_key_exists('mal_id', $data))
{ {
$requester->addRequest($this->anilistModel->createListItem($data, 'MANGA'), 'anilist'); $requester->addRequest($this->anilistModel->createListItem($data, 'MANGA'), 'anilist');
} }
@ -159,7 +159,7 @@ class Manga extends API {
$array = $data->toArray(); $array = $data->toArray();
if (array_key_exists('mal_id', $array) && $this->anilistEnabled) if ($this->anilistEnabled && array_key_exists('mal_id', $array))
{ {
$requester->addRequest($this->anilistModel->updateListItem($data, 'MANGA'), 'anilist'); $requester->addRequest($this->anilistModel->updateListItem($data, 'MANGA'), 'anilist');
} }
@ -187,7 +187,7 @@ class Manga extends API {
$array = $data->toArray(); $array = $data->toArray();
if (array_key_exists('mal_id', $array) && $this->anilistEnabled) if ($this->anilistEnabled && array_key_exists('mal_id', $array))
{ {
$requester->addRequest($this->anilistModel->incrementListItem($data, 'MANGA'), 'anilist'); $requester->addRequest($this->anilistModel->incrementListItem($data, 'MANGA'), 'anilist');
} }
@ -214,7 +214,7 @@ class Manga extends API {
$requester = new ParallelAPIRequest(); $requester = new ParallelAPIRequest();
$requester->addRequest($this->kitsuModel->deleteListItem($id), 'kitsu'); $requester->addRequest($this->kitsuModel->deleteListItem($id), 'kitsu');
if ($malId !== null && $this->anilistEnabled) if ($this->anilistEnabled && $malId !== null)
{ {
$requester->addRequest($this->anilistModel->deleteListItem($malId, 'MANGA'), 'anilist'); $requester->addRequest($this->anilistModel->deleteListItem($malId, 'MANGA'), 'anilist');
} }

View File

@ -108,6 +108,16 @@ abstract class AbstractType implements ArrayAccess {
throw new UndefinedPropertyException("Trying to get undefined property: '$name'"); throw new UndefinedPropertyException("Trying to get undefined property: '$name'");
} }
/**
* Create a string representation of the object for debugging
*
* @return string
*/
public function __toString(): string
{
return print_r($this, TRUE);
}
/** /**
* Implementing ArrayAccess * Implementing ArrayAccess
* *
@ -180,4 +190,22 @@ abstract class AbstractType implements ArrayAccess {
return $output; return $output;
} }
}
/**
* Determine whether the type has any properties set
*
* @return bool
*/
public function isEmpty(): bool
{
foreach ($this as $key => $value)
{
if ( ! empty($value))
{
return FALSE;
}
}
return TRUE;
}
}