diff --git a/build/phpunit.xml b/build/phpunit.xml
index 537121c8..f5f4ce1e 100644
--- a/build/phpunit.xml
+++ b/build/phpunit.xml
@@ -20,7 +20,7 @@
-
+
diff --git a/src/API/Kitsu/Transformer/AnimeListTransformer.php b/src/API/Kitsu/Transformer/AnimeListTransformer.php
index 4d49fef5..5f29b9b8 100644
--- a/src/API/Kitsu/Transformer/AnimeListTransformer.php
+++ b/src/API/Kitsu/Transformer/AnimeListTransformer.php
@@ -72,7 +72,7 @@ final class AnimeListTransformer extends AbstractTransformer {
}
}
- $streamingLinks = (array_key_exists('streamingLinks', $anime['relationships']))
+ $streamingLinks = array_key_exists('streamingLinks', $anime['relationships'])
? Kitsu::parseListItemStreamingLinks($included, $animeId)
: [];
diff --git a/src/Controller.php b/src/Controller.php
index 5dc3c1e3..08b117ef 100644
--- a/src/Controller.php
+++ b/src/Controller.php
@@ -79,11 +79,7 @@ class Controller {
* Common data to be sent to views
* @var array
*/
- protected $baseData = [
- 'url_type' => 'anime',
- 'other_type' => 'manga',
- 'menu_name' => ''
- ];
+ protected $baseData = [];
/**
* Controller constructor.
@@ -95,46 +91,29 @@ class Controller {
public function __construct(ContainerInterface $container)
{
$this->setContainer($container);
+
$auraUrlGenerator = $container->get('aura-router')->getGenerator();
+ $session = $container->get('session');
$urlGenerator = $container->get('url-generator');
+
$this->cache = $container->get('cache');
$this->config = $container->get('config');
$this->request = $container->get('request');
$this->response = $container->get('response');
-
- $this->baseData = array_merge($this->baseData, [
- 'url' => $auraUrlGenerator,
- 'urlGenerator' => $urlGenerator,
- 'auth' => $container->get('auth'),
- 'config' => $this->config
- ]);
-
+ $this->session = $session->getSegment(SESSION_SEGMENT);
$this->url = $auraUrlGenerator;
$this->urlGenerator = $urlGenerator;
- $session = $container->get('session');
- $this->session = $session->getSegment(SESSION_SEGMENT);
-
- // Set a 'previous' flash value for better redirects
- $serverParams = $this->request->getServerParams();
- if (array_key_exists('HTTP_REFERER', $serverParams) && false === stripos($serverParams['HTTP_REFERER'], 'login'))
- {
- $this->session->setFlash('previous', $serverParams['HTTP_REFERER']);
- }
-
- // Set a message box if available
- $this->baseData['message'] = $this->session->getFlash('message');
- }
-
- /**
- * Redirect to the previous page
- *
- * @return void
- */
- public function redirectToPrevious(): void
- {
- $previous = $this->session->getFlash('previous');
- $this->redirect($previous, 303);
+ $this->baseData = [
+ 'auth' => $container->get('auth'),
+ 'config' => $this->config,
+ 'menu_name' => '',
+ 'message' => $this->session->getFlash('message'), // Get message box data if it exists
+ 'other_type' => 'manga',
+ 'url' => $auraUrlGenerator,
+ 'url_type' => 'anime',
+ 'urlGenerator' => $urlGenerator,
+ ];
}
/**
@@ -159,7 +138,7 @@ class Controller {
// Don't attempt to set the redirect url if
// the page is one of the form type pages,
- // and the previous page is also a form type page_segments
+ // and the previous page is also a form type
if ($doubleFormPage || $isLoginPage)
{
return;
@@ -178,6 +157,8 @@ class Controller {
/**
* Redirect to the url previously set in the session
*
+ * If one is not set, redirect to default url
+ *
* @throws InvalidArgumentException
* @throws \Aviat\Ion\Di\Exception\ContainerException
* @throws \Aviat\Ion\Di\Exception\NotFoundException
@@ -185,16 +166,10 @@ class Controller {
*/
public function sessionRedirect(): void
{
- $target = $this->session->get('redirect_url');
- if (empty($target))
- {
- $this->notFound();
- }
- else
- {
- $this->redirect($target, 303);
- $this->session->set('redirect_url', NULL);
- }
+ $target = $this->session->get('redirect_url') ?? '/';
+
+ $this->redirect($target, 303);
+ $this->session->set('redirect_url', NULL);
}
/**
@@ -218,7 +193,7 @@ class Controller {
}
$route = $router->getRoute();
- $data['route_path'] = $route ? $router->getRoute()->path : '';
+ $data['route_path'] = $route !== FALSE ? $route->path : '';
$templatePath = _dir($this->config->get('view_path'), "{$template}.php");
@@ -275,7 +250,7 @@ class Controller {
public function notFound(
string $title = 'Sorry, page not found',
string $message = 'Page Not Found'
- ): void
+ ): void
{
$this->outputHTML('404', [
'title' => $title,
@@ -408,7 +383,6 @@ class Controller {
(new JsonView($this->container))
->setStatusCode($code)
->setOutput($data);
- // ->send();
exit();
}
@@ -421,8 +395,8 @@ class Controller {
*/
protected function redirect(string $url, int $code): void
{
- $http = new HttpView($this->container);
- $http->redirect($url, $code);
+ (new HttpView($this->container))->redirect($url, $code);
+ exit();
}
}
// End of BaseController.php
\ No newline at end of file
diff --git a/src/Controller/Anime.php b/src/Controller/Anime.php
index 8b5adecb..9bce1426 100644
--- a/src/Controller/Anime.php
+++ b/src/Controller/Anime.php
@@ -28,6 +28,7 @@ use Aviat\Ion\Json;
* Controller for Anime-related pages
*/
final class Anime extends BaseController {
+
/**
* The anime list model
* @var \Aviat\AnimeClient\Model\Anime $model
@@ -49,12 +50,9 @@ final class Anime extends BaseController {
$this->baseData = array_merge($this->baseData, [
'menu_name' => 'anime_list',
- 'url_type' => 'anime',
'other_type' => 'manga',
- 'config' => $this->config,
+ 'url_type' => 'anime',
]);
-
- $this->cache = $container->get('cache');
}
/**
diff --git a/src/Controller/AnimeCollection.php b/src/Controller/AnimeCollection.php
index cdb3e487..ea2b45b5 100644
--- a/src/Controller/AnimeCollection.php
+++ b/src/Controller/AnimeCollection.php
@@ -56,9 +56,8 @@ final class AnimeCollection extends BaseController {
$this->baseData = array_merge($this->baseData, [
'collection_type' => 'anime',
'menu_name' => 'collection',
- 'url_type' => 'anime',
'other_type' => 'manga',
- 'config' => $this->config,
+ 'url_type' => 'anime',
]);
}
diff --git a/src/Controller/Images.php b/src/Controller/Images.php
index 25858566..a9ad4344 100644
--- a/src/Controller/Images.php
+++ b/src/Controller/Images.php
@@ -131,8 +131,6 @@ final class Images extends BaseController {
$data = wait($response->getBody());
-
-
[$origWidth] = getimagesizefromstring($data);
$gdImg = imagecreatefromstring($data);
$resizedImg = imagescale($gdImg, $width ?? $origWidth);
diff --git a/src/Controller/Manga.php b/src/Controller/Manga.php
index 72465489..8d1b81be 100644
--- a/src/Controller/Manga.php
+++ b/src/Controller/Manga.php
@@ -29,8 +29,6 @@ use Aviat\Ion\{Json, StringWrapper};
*/
final class Manga extends Controller {
- use StringWrapper;
-
/**
* The manga model
* @var MangaModel $model
@@ -51,9 +49,8 @@ final class Manga extends Controller {
$this->model = $container->get('manga-model');
$this->baseData = array_merge($this->baseData, [
'menu_name' => 'manga_list',
- 'config' => $this->config,
+ 'other_type' => 'anime',
'url_type' => 'manga',
- 'other_type' => 'anime'
]);
}
diff --git a/src/Controller/MangaCollection.php b/src/Controller/MangaCollection.php
index 47ad0ef6..73a8cf44 100644
--- a/src/Controller/MangaCollection.php
+++ b/src/Controller/MangaCollection.php
@@ -57,9 +57,8 @@ final class MangaCollection extends BaseController {
$this->baseData = array_merge($this->baseData, [
'collection_type' => 'manga',
'menu_name' => 'manga-collection',
- 'url_type' => 'manga',
'other_type' => 'anime',
- 'config' => $this->config,
+ 'url_type' => 'manga',
]);
}
diff --git a/src/Controller/Settings.php b/src/Controller/Settings.php
index c8360e41..225d05b1 100644
--- a/src/Controller/Settings.php
+++ b/src/Controller/Settings.php
@@ -23,6 +23,7 @@ use Aviat\Ion\Di\ContainerInterface;
* Controller for user settings
*/
final class Settings extends BaseController {
+
/**
* @var \Aviat\AnimeClient\API\Anilist\Model
*/
@@ -144,13 +145,9 @@ final class Settings extends BaseController {
$saved = $this->settingsModel->saveSettingsFile($newSettings);
- if ($saved)
- {
- $this->setFlashMessage('Linked Anilist Account', 'success');
- } else
- {
- $this->setFlashMessage('Error Linking Anilist Account', 'error');
- }
+ $saved
+ ? $this->setFlashMessage('Linked Anilist Account', 'success')
+ : $this->setFlashMessage('Error Linking Anilist Account', 'error');
$this->redirect($this->url->generate('settings'), 303);
}
diff --git a/src/Helper/Form.php b/src/Helper/Form.php
index 244030ab..efe099bf 100644
--- a/src/Helper/Form.php
+++ b/src/Helper/Form.php
@@ -20,14 +20,14 @@ use Aviat\AnimeClient\FormGenerator;
use Aviat\Ion\Di\ContainerAware;
/**
- * MenuGenerator helper wrapper
+ * FormGenerator helper wrapper
*/
final class Form {
use ContainerAware;
/**
- * Create the html for the selected menu
+ * Create the html for the specified form
*
* @param string $name
* @param array $form
@@ -38,4 +38,3 @@ final class Form {
return (new FormGenerator($this->container))->generate($name, $form);
}
}
-// End of Menu.php
\ No newline at end of file