-
+
= $item['manga']['title'] ?>
= ( ! is_null($item['manga']['alternate_title'])) ? " · " . $item['manga']['alternate_title'] : "" ?>
diff --git a/src/Aviat/AnimeClient/Config.php b/src/Aviat/AnimeClient/Config.php
index 90d45bc4..d97c7450 100644
--- a/src/Aviat/AnimeClient/Config.php
+++ b/src/Aviat/AnimeClient/Config.php
@@ -7,6 +7,9 @@ namespace Aviat\AnimeClient;
/**
* Wrapper for configuration values
+ *
+ * @property Database Config $database
+ * @property Menu Config $menus
*/
class Config {
@@ -39,12 +42,12 @@ class Config {
}
/**
- * Getter for config values
+ * Get a config value
*
* @param string $key
* @return mixed
*/
- public function __get($key)
+ public function get($key)
{
if (isset($this->config[$key]))
{
@@ -53,5 +56,18 @@ class Config {
return NULL;
}
+
+ /**
+ * Set a config value
+ *
+ * @param string $key
+ * @param mixed $value
+ * @return Config
+ */
+ public function set($key, $value)
+ {
+ $this->config[$key] = $value;
+ return $this;
+ }
}
// End of config.php
\ No newline at end of file
diff --git a/src/Aviat/AnimeClient/Controller.php b/src/Aviat/AnimeClient/Controller.php
index 340b5a77..95fd6972 100644
--- a/src/Aviat/AnimeClient/Controller.php
+++ b/src/Aviat/AnimeClient/Controller.php
@@ -25,6 +25,12 @@ class Controller {
*/
protected $config;
+ /**
+ * Request object
+ * @var object $request
+ */
+ protected $request;
+
/**
* Response object
* @var object $response
@@ -90,7 +96,7 @@ class Controller {
/**
* Get the string output of a partial template
*
- * @param HTMLView $view
+ * @param HtmlView $view
* @param string $template
* @param array|object $data
* @return string
@@ -110,7 +116,7 @@ class Controller {
$data['route_path'] = ($route) ? $router->get_route()->path : "";
- $template_path = _dir($this->config->__get('view_path'), "{$template}.php");
+ $template_path = _dir($this->config->get('view_path'), "{$template}.php");
if ( ! is_file($template_path))
{
@@ -198,7 +204,6 @@ class Controller {
*/
public function logout()
{
- session_destroy();
$this->response->redirect->seeOther($this->urlGenerator->full_url(''));
}
diff --git a/src/Aviat/AnimeClient/Controller/Anime.php b/src/Aviat/AnimeClient/Controller/Anime.php
index ddce052a..9416fb7a 100644
--- a/src/Aviat/AnimeClient/Controller/Anime.php
+++ b/src/Aviat/AnimeClient/Controller/Anime.php
@@ -57,7 +57,7 @@ class Anime extends BaseController {
{
parent::__construct($container);
- if ($this->config->show_anime_collection === FALSE)
+ if ($this->config->get('show_anime_collection') === FALSE)
{
unset($this->nav_routes['Collection']);
}
@@ -73,6 +73,13 @@ class Anime extends BaseController {
]);
}
+ /**
+ * Show a portion, or all of the anime list
+ *
+ * @param string $type - The section of the list
+ * @param string $view - List or cover view
+ * @return void
+ */
public function index($type = "watching", $view = '')
{
return $this->anime_list($type, $view);
@@ -116,7 +123,7 @@ class Anime extends BaseController {
'completed' => AnimeWatchingStatus::COMPLETED
];
- $title = $this->config->whose_list . "'s Anime List · {$type_title_map[$type]}";
+ $title = $this->config->get('whose_list') . "'s Anime List · {$type_title_map[$type]}";
$view_map = [
'' => 'cover',
diff --git a/src/Aviat/AnimeClient/Controller/Collection.php b/src/Aviat/AnimeClient/Controller/Collection.php
index 0a57d0d9..341bf61d 100644
--- a/src/Aviat/AnimeClient/Controller/Collection.php
+++ b/src/Aviat/AnimeClient/Controller/Collection.php
@@ -58,7 +58,7 @@ class Collection extends BaseController {
{
parent::__construct($container);
- if ($this->config->show_anime_collection === FALSE)
+ if ($this->config->get('show_anime_collection') === FALSE)
{
unset($this->nav_routes['Collection']);
}
@@ -101,7 +101,7 @@ class Collection extends BaseController {
$data = $this->collection_model->get_collection();
$this->outputHTML('collection/' . $view_map[$view], [
- 'title' => $this->config->whose_list . "'s Anime Collection",
+ 'title' => $this->config->get('whose_list') . "'s Anime Collection",
'sections' => $data,
'genres' => $this->collection_model->get_genre_list()
]);
diff --git a/src/Aviat/AnimeClient/Controller/Manga.php b/src/Aviat/AnimeClient/Controller/Manga.php
index 6e86ada3..d49328b6 100644
--- a/src/Aviat/AnimeClient/Controller/Manga.php
+++ b/src/Aviat/AnimeClient/Controller/Manga.php
@@ -58,6 +58,13 @@ class Manga extends Controller {
]);
}
+ /**
+ * Get a section of the manga list
+ *
+ * @param string $status
+ * @param string $view
+ * @return void
+ */
public function index($status = "all", $view = "")
{
return $this->manga_list($status, $view);
@@ -91,7 +98,7 @@ class Manga extends Controller {
'on_hold' => MangaModel::ON_HOLD
];
- $title = $this->config->whose_list . "'s Manga List · {$map[$status]}";
+ $title = $this->config->get('whose_list') . "'s Manga List · {$map[$status]}";
$view_map = [
'' => 'cover',
diff --git a/src/Aviat/AnimeClient/Model.php b/src/Aviat/AnimeClient/Model.php
index 087eb04b..71e201c0 100644
--- a/src/Aviat/AnimeClient/Model.php
+++ b/src/Aviat/AnimeClient/Model.php
@@ -22,7 +22,7 @@ class Model {
/**
* The container object
- * @var Container
+ * @var ContainerInterface
*/
protected $container;
@@ -61,8 +61,9 @@ class Model {
// Failsafe for weird urls
if (strlen($ext) > 3) return $api_path;
+ $img_cache_path = $this->config->get('img_cache_path');
$cached_image = "{$series_slug}.{$ext}";
- $cached_path = "{$this->config->img_cache_path}/{$type}/{$cached_image}";
+ $cached_path = "{$img_cache_path}/{$type}/{$cached_image}";
// Cache the file if it doesn't already exist
if ( ! file_exists($cached_path))
diff --git a/src/Aviat/AnimeClient/Model/Anime.php b/src/Aviat/AnimeClient/Model/Anime.php
index 05cbd53a..201cb0e6 100644
--- a/src/Aviat/AnimeClient/Model/Anime.php
+++ b/src/Aviat/AnimeClient/Model/Anime.php
@@ -47,7 +47,8 @@ class Anime extends API {
*/
public function update($data)
{
- $data['auth_token'] = $_SESSION['hummingbird_anime_token'];
+ // @TODO use Hummingbird Auth class
+ $data['auth_token'] = '';
$result = $this->client->post("libraries/{$data['id']}", [
'body' => $data
@@ -168,7 +169,8 @@ class Anime extends API {
$config['query']['status'] = $status;
}
- $response = $this->client->get("users/{$this->config->hummingbird_username}/library", $config);
+ $username = $this->config->get('hummingbird_username');
+ $response = $this->client->get("users/{$username}/library", $config);
$output = $this->_check_cache($status, $response);
foreach ($output as &$row)
@@ -189,8 +191,8 @@ class Anime extends API {
*/
protected function _check_cache($status, $response)
{
- $cache_file = _dir($this->config->data_cache_path, "anime-{$status}.json");
- $transformed_cache_file = _dir($this->config->data_cache_path, "anime-{$status}-transformed.json");
+ $cache_file = _dir($this->config->get('data_cache_path'), "anime-{$status}.json");
+ $transformed_cache_file = _dir($this->config->get('data_cache_path'), "anime-{$status}-transformed.json");
$cached = json_decode(file_get_contents($cache_file), TRUE);
$api_data = json_decode($response->getBody(), TRUE);
diff --git a/src/Aviat/AnimeClient/Model/DB.php b/src/Aviat/AnimeClient/Model/DB.php
index 365ebbd2..5fa57536 100644
--- a/src/Aviat/AnimeClient/Model/DB.php
+++ b/src/Aviat/AnimeClient/Model/DB.php
@@ -31,7 +31,7 @@ class DB extends BaseModel {
public function __construct(ContainerInterface $container)
{
parent::__construct($container);
- $this->db_config = $this->config->database;
+ $this->db_config = $this->config->get('database');
}
}
// End of BaseDBModel.php
\ No newline at end of file
diff --git a/src/Aviat/AnimeClient/Model/Manga.php b/src/Aviat/AnimeClient/Model/Manga.php
index cfab0783..f9939376 100644
--- a/src/Aviat/AnimeClient/Model/Manga.php
+++ b/src/Aviat/AnimeClient/Model/Manga.php
@@ -48,8 +48,9 @@ class Manga extends API {
$id = $data['id'];
unset($data['id']);
+ // @TODO update with auth key from auth class
$result = $this->client->put("manga_library_entries/{$id}", [
- 'cookies' => ['token' => $_SESSION['hummingbird_anime_token']],
+ 'cookies' => ['token' => ''],
'json' => ['manga_library_entry' => $data]
]);
@@ -92,7 +93,7 @@ class Manga extends API {
$config = [
'query' => [
- 'user_id' => $this->config->hummingbird_username
+ 'user_id' => $this->config->get('hummingbird_username')
],
'allow_redirects' => FALSE
];
@@ -117,8 +118,8 @@ class Manga extends API {
$api_data = json_decode($response->getBody(), TRUE);
if ( ! array_key_exists('manga', $api_data)) return [];
- $cache_file = _dir($this->config->data_cache_path, 'manga.json');
- $transformed_cache_file = _dir($this->config->data_cache_path, 'manga-transformed.json');
+ $cache_file = _dir($this->config->get('data_cache_path'), 'manga.json');
+ $transformed_cache_file = _dir($this->config->get('data_cache_path'), 'manga-transformed.json');
$cached_data = json_decode(file_get_contents($cache_file), TRUE);
diff --git a/src/Aviat/AnimeClient/Router.php b/src/Aviat/AnimeClient/Router.php
index 9b3fd21f..29bf29f1 100644
--- a/src/Aviat/AnimeClient/Router.php
+++ b/src/Aviat/AnimeClient/Router.php
@@ -168,10 +168,7 @@ class Router extends RoutingBase {
*/
public function get_controller()
{
- $error_handler = $this->container->get('error-handler');
$route_type = $this->__get('default_list');
-
- $host = $this->request->server->get("HTTP_HOST");
$request_uri = $this->request->server->get('PATH_INFO');
$path = trim($request_uri, '/');
diff --git a/src/Aviat/AnimeClient/RoutingBase.php b/src/Aviat/AnimeClient/RoutingBase.php
index ac098e8b..e063c594 100644
--- a/src/Aviat/AnimeClient/RoutingBase.php
+++ b/src/Aviat/AnimeClient/RoutingBase.php
@@ -38,7 +38,7 @@ class RoutingBase {
{
$this->container = $container;
$this->config = $container->get('config');
- $this->routes = $this->config->__get('routes');
+ $this->routes = $this->config->get('routes');
}
/**
@@ -49,7 +49,7 @@ class RoutingBase {
*/
public function __get($key)
{
- $routing_config = $this->config->routing;
+ $routing_config = $this->config->get('routing');
if (array_key_exists($key, $routing_config))
{
diff --git a/src/Aviat/Ion/Friend.php b/src/Aviat/Ion/Friend.php
index dbd5ae2f..f479a3cf 100644
--- a/src/Aviat/Ion/Friend.php
+++ b/src/Aviat/Ion/Friend.php
@@ -13,7 +13,16 @@ use BadMethodCallException;
*/
class Friend {
+ /**
+ * Object to create a friend of
+ * @var object
+ */
private $_friend_object_;
+
+ /**
+ * Reflection class of the object
+ * @var object
+ */
private $_reflection_friend_;
/**
diff --git a/tests/AnimeClient/ConfigTest.php b/tests/AnimeClient/ConfigTest.php
index 6b3f9072..4a869e7b 100644
--- a/tests/AnimeClient/ConfigTest.php
+++ b/tests/AnimeClient/ConfigTest.php
@@ -13,15 +13,15 @@ class ConfigTest extends AnimeClient_TestCase {
]);
}
- public function testConfig__get()
+ public function testConfigGet()
{
- $this->assertEquals($this->config->foo, $this->config->__get('foo'));
- $this->assertEquals($this->config->bar, $this->config->__get('bar'));
- $this->assertEquals(NULL, $this->config->baz);
+ $this->assertEquals('bar', $this->config->get('foo'));
+ $this->assertEquals('baz', $this->config->get('bar'));
+ $this->assertNull($this->config->get('baz'));
}
public function testGetNonExistentConfigItem()
{
- $this->assertEquals(NULL, $this->config->foobar);
+ $this->assertNull($this->config->get('foobar'));
}
}
\ No newline at end of file
diff --git a/tests/AnimeClient/RouterTest.php b/tests/AnimeClient/RouterTest.php
index 78ca6c4d..1d0e8e6e 100644
--- a/tests/AnimeClient/RouterTest.php
+++ b/tests/AnimeClient/RouterTest.php
@@ -147,7 +147,7 @@ class RouterTest extends AnimeClient_TestCase {
// Check route setup
- $this->assertEquals($config['routes'], $this->config->routes, "Incorrect route path");
+ $this->assertEquals($config['routes'], $this->config->get('routes'), "Incorrect route path");
$this->assertTrue(is_array($this->router->get_output_routes()));
// Check environment variables
|