Version 5.1 - All the GraphQL #32
@ -17,6 +17,15 @@ test:7:
|
|||||||
script:
|
script:
|
||||||
- phpunit -c build
|
- phpunit -c build
|
||||||
|
|
||||||
|
test:7.1:
|
||||||
|
before_script:
|
||||||
|
- bash build/docker_install.sh > /dev/null
|
||||||
|
- curl -sS https://getcomposer.org/installer | php
|
||||||
|
- php composer.phar install --no-dev
|
||||||
|
image: php:7.1
|
||||||
|
script:
|
||||||
|
- phpunit -c build
|
||||||
|
|
||||||
test:hhvm:
|
test:hhvm:
|
||||||
before_script:
|
before_script:
|
||||||
- /usr/local/bin/composer self-update
|
- /usr/local/bin/composer self-update
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* Hummingbird Anime Client
|
* Anime List Client
|
||||||
*
|
*
|
||||||
* An API client for Hummingbird to manage anime and manga watch lists
|
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
|
||||||
*
|
*
|
||||||
* PHP version 7
|
* PHP version 7
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package AnimeListClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2016 Timothy J. Warren
|
* @copyright 2015 - 2016 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.1
|
* @version 4.0
|
||||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -19,16 +19,14 @@ namespace Aviat\AnimeClient;
|
|||||||
use Aura\Html\HelperLocatorFactory;
|
use Aura\Html\HelperLocatorFactory;
|
||||||
use Aura\Router\RouterContainer;
|
use Aura\Router\RouterContainer;
|
||||||
use Aura\Session\SessionFactory;
|
use Aura\Session\SessionFactory;
|
||||||
use Monolog\Logger;
|
use Aviat\AnimeClient\API\Kitsu\Auth as KitsuAuth;
|
||||||
use Monolog\Handler\RotatingFileHandler;
|
use Aviat\AnimeClient\Model;
|
||||||
use Zend\Diactoros\ServerRequestFactory;
|
use Aviat\Ion\Cache\CacheManager;
|
||||||
use Zend\Diactoros\Response;
|
|
||||||
|
|
||||||
use Aviat\Ion\Config;
|
use Aviat\Ion\Config;
|
||||||
use Aviat\Ion\Di\Container;
|
use Aviat\Ion\Di\Container;
|
||||||
use Aviat\Ion\Cache\CacheManager;
|
use Monolog\Handler\RotatingFileHandler;
|
||||||
use Aviat\AnimeClient\Auth\HummingbirdAuth;
|
use Monolog\Logger;
|
||||||
use Aviat\AnimeClient\Model;
|
use Zend\Diactoros\{Response, ServerRequestFactory};
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Setup DI container
|
// Setup DI container
|
||||||
@ -115,9 +113,9 @@ return function(array $config_array = []) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Miscellaneous Classes
|
// Miscellaneous Classes
|
||||||
$container->set('auth', function($container) {
|
/* $container->set('auth', function($container) {
|
||||||
return new HummingbirdAuth($container);
|
return new HummingbirdAuth($container);
|
||||||
});
|
}); */
|
||||||
$container->set('url-generator', function($container) {
|
$container->set('url-generator', function($container) {
|
||||||
return new UrlGenerator($container);
|
return new UrlGenerator($container);
|
||||||
});
|
});
|
||||||
|
@ -147,7 +147,7 @@ return [
|
|||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
'cache_purge' => [
|
'cache_purge' => [
|
||||||
'path' => '/cache_purge',
|
'path' => '/cache_purge',
|
||||||
'action' => 'clear_cache',
|
'action' => 'clearCache',
|
||||||
'controller' => AnimeClient::DEFAULT_CONTROLLER_NAMESPACE,
|
'controller' => AnimeClient::DEFAULT_CONTROLLER_NAMESPACE,
|
||||||
'verb' => 'get',
|
'verb' => 'get',
|
||||||
],
|
],
|
||||||
@ -159,7 +159,7 @@ return [
|
|||||||
],
|
],
|
||||||
'login.post' => [
|
'login.post' => [
|
||||||
'path' => '/login',
|
'path' => '/login',
|
||||||
'action' => 'login_action',
|
'action' => 'loginAction',
|
||||||
'controller' => AnimeClient::DEFAULT_CONTROLLER_NAMESPACE,
|
'controller' => AnimeClient::DEFAULT_CONTROLLER_NAMESPACE,
|
||||||
'verb' => 'post',
|
'verb' => 'post',
|
||||||
],
|
],
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace Aviat\AnimeClient ?>
|
<?php declare(strict_types=1); namespace Aviat\AnimeClient; ?>
|
||||||
<h1 class="flex flex-align-end flex-wrap">
|
<h1 class="flex flex-align-end flex-wrap">
|
||||||
<span class="flex-no-wrap grow-1">
|
<span class="flex-no-wrap grow-1">
|
||||||
<?php if(strpos($route_path, 'collection') === FALSE): ?>
|
<?php if(strpos($route_path, 'collection') === FALSE): ?>
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
/**
|
/**
|
||||||
* Hummingbird Anime Client
|
* Anime List Client
|
||||||
*
|
*
|
||||||
* An API client for Hummingbird to manage anime and manga watch lists
|
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
|
||||||
*
|
*
|
||||||
* PHP version 7
|
* PHP version 7
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package AnimeListClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2016 Timothy J. Warren
|
* @copyright 2015 - 2016 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.1
|
* @version 4.0
|
||||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
$animeclient_file_patterns = [
|
$file_patterns = [
|
||||||
'app/config/*.php',
|
|
||||||
'app/bootstrap.php',
|
'app/bootstrap.php',
|
||||||
'src/functions.php',
|
'migrations/*.php',
|
||||||
'src/*.php',
|
'src/**/*.php',
|
||||||
'tests/**/*.php'
|
'tests/**/*.php',
|
||||||
];
|
];
|
||||||
|
|
||||||
if ( ! function_exists('glob_recursive'))
|
if ( ! function_exists('glob_recursive'))
|
||||||
@ -80,16 +80,10 @@ function replace_files(array $files, $template)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($animeclient_file_patterns as $glob)
|
foreach ($file_patterns as $glob)
|
||||||
{
|
{
|
||||||
$files = glob_recursive($glob);
|
$files = glob_recursive($glob);
|
||||||
replace_files($files, '/animeclient_header_comment.txt');
|
replace_files($files, '/header_comment.txt');
|
||||||
}
|
}
|
||||||
$loose_files = [
|
|
||||||
__DIR__ . '/../index.php',
|
|
||||||
__DIR__ . '/../public/css.php',
|
|
||||||
__DIR__ . '/../public/js.php'
|
|
||||||
];
|
|
||||||
replace_files($loose_files, '/animeclient_header_comment.txt');
|
|
||||||
|
|
||||||
echo "Successfully updated headers \n";
|
echo "Successfully updated headers \n";
|
@ -41,5 +41,8 @@
|
|||||||
"henrikbjorn/lurker": "^1.1.0",
|
"henrikbjorn/lurker": "^1.1.0",
|
||||||
"symfony/var-dumper": "^3.1",
|
"symfony/var-dumper": "^3.1",
|
||||||
"squizlabs/php_codesniffer": "^3.0.0@beta"
|
"squizlabs/php_codesniffer": "^3.0.0@beta"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
20
console
20
console
@ -1,6 +1,5 @@
|
|||||||
#!/usr/bin/env php
|
#!/usr/bin/env php
|
||||||
<?php
|
<?php declare(strict_types=1);
|
||||||
use Aviat\AnimeClient\Model;
|
|
||||||
|
|
||||||
if ( ! function_exists('_dir'))
|
if ( ! function_exists('_dir'))
|
||||||
{
|
{
|
||||||
@ -23,23 +22,6 @@ $APP_DIR = __DIR__ . '/app/';
|
|||||||
$SRC_DIR = __DIR__ . '/src/';
|
$SRC_DIR = __DIR__ . '/src/';
|
||||||
$CONF_DIR = realpath("${APP_DIR}/config/");
|
$CONF_DIR = realpath("${APP_DIR}/config/");
|
||||||
|
|
||||||
/**
|
|
||||||
* Set up autoloaders
|
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
spl_autoload_register(function($class) use ($SRC_DIR) {
|
|
||||||
$class_parts = explode('\\', $class);
|
|
||||||
$ns_path = $SRC_DIR . '/' . implode('/', $class_parts) . ".php";
|
|
||||||
|
|
||||||
if (file_exists($ns_path))
|
|
||||||
{
|
|
||||||
require_once($ns_path);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Set up autoloader for third-party dependencies
|
// Set up autoloader for third-party dependencies
|
||||||
require_once realpath(__DIR__ . '/vendor/autoload.php');
|
require_once realpath(__DIR__ . '/vendor/autoload.php');
|
||||||
|
|
||||||
|
@ -13,8 +13,11 @@
|
|||||||
* @version 3.1
|
* @version 3.1
|
||||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
namespace Aviat\AnimeClient;
|
||||||
|
|
||||||
use Aviat\AnimeClient\AnimeClient;
|
use Aviat\AnimeClient\AnimeClient;
|
||||||
use Whoops\Handler\PrettyPageHandler;
|
use Whoops\Handler\PrettyPageHandler;
|
||||||
|
use Whoops\Run;
|
||||||
|
|
||||||
// Work around the silly timezone error
|
// Work around the silly timezone error
|
||||||
$timezone = ini_get('date.timezone');
|
$timezone = ini_get('date.timezone');
|
||||||
@ -44,7 +47,7 @@ require _dir(__DIR__, '/vendor/autoload.php');
|
|||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// Setup error handling
|
// Setup error handling
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
$whoops = new \Whoops\Run();
|
$whoops = new Run();
|
||||||
|
|
||||||
// Set up default handler for general errors
|
// Set up default handler for general errors
|
||||||
$defaultHandler = new PrettyPageHandler();
|
$defaultHandler = new PrettyPageHandler();
|
||||||
@ -63,7 +66,7 @@ $whoops->register();
|
|||||||
require _dir($CONF_DIR, 'base_config.php'); // $base_config
|
require _dir($CONF_DIR, 'base_config.php'); // $base_config
|
||||||
$di = require _dir($APP_DIR, 'bootstrap.php');
|
$di = require _dir($APP_DIR, 'bootstrap.php');
|
||||||
|
|
||||||
$config = AnimeClient::load_toml($CONF_DIR);
|
$config = AnimeClient::loadToml($CONF_DIR);
|
||||||
$config_array = array_merge($base_config, $config);
|
$config_array = array_merge($base_config, $config);
|
||||||
|
|
||||||
$container = $di($config_array);
|
$container = $di($config_array);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
use Phinx\Migration\AbstractMigration;
|
use Phinx\Migration\AbstractMigration;
|
||||||
|
|
||||||
|
@ -26,12 +26,13 @@ define('SRC_DIR', realpath(__DIR__));
|
|||||||
class AnimeClient {
|
class AnimeClient {
|
||||||
|
|
||||||
const HUMMINGBIRD_AUTH_URL = 'https://hummingbird.me/api/v1/users/authenticate';
|
const HUMMINGBIRD_AUTH_URL = 'https://hummingbird.me/api/v1/users/authenticate';
|
||||||
|
const KITSU_AUTH_URL = 'https://kitsu.io/api/oauth/token';
|
||||||
const SESSION_SEGMENT = 'Aviat\AnimeClient\Auth';
|
const SESSION_SEGMENT = 'Aviat\AnimeClient\Auth';
|
||||||
const DEFAULT_CONTROLLER_NAMESPACE = 'Aviat\AnimeClient\Controller';
|
const DEFAULT_CONTROLLER_NAMESPACE = 'Aviat\AnimeClient\Controller';
|
||||||
const DEFAULT_CONTROLLER = 'Aviat\AnimeClient\Controller\Anime';
|
const DEFAULT_CONTROLLER = 'Aviat\AnimeClient\Controller\Anime';
|
||||||
const DEFAULT_CONTROLLER_METHOD = 'index';
|
const DEFAULT_CONTROLLER_METHOD = 'index';
|
||||||
const NOT_FOUND_METHOD = 'not_found';
|
const NOT_FOUND_METHOD = 'notFound';
|
||||||
const ERROR_MESSAGE_METHOD = 'error_page';
|
const ERROR_MESSAGE_METHOD = 'errorPage';
|
||||||
const SRC_DIR = SRC_DIR;
|
const SRC_DIR = SRC_DIR;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -40,7 +41,7 @@ class AnimeClient {
|
|||||||
* @param string $path - Path to load config
|
* @param string $path - Path to load config
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function load_toml($path)
|
public static function loadToml(string $path): array
|
||||||
{
|
{
|
||||||
$output = [];
|
$output = [];
|
||||||
$files = glob("{$path}/*.toml");
|
$files = glob("{$path}/*.toml");
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* Hummingbird Anime Client
|
* Anime List Client
|
||||||
*
|
*
|
||||||
* An API client for Hummingbird to manage anime and manga watch lists
|
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
|
||||||
*
|
*
|
||||||
* PHP version 7
|
* PHP version 7
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package AnimeListClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2016 Timothy J. Warren
|
* @copyright 2015 - 2016 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.1
|
* @version 4.0
|
||||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ class BaseCommand extends Command {
|
|||||||
$CONF_DIR = realpath(__DIR__ . '/../../app/config/');
|
$CONF_DIR = realpath(__DIR__ . '/../../app/config/');
|
||||||
require_once $CONF_DIR . '/base_config.php'; // $base_config
|
require_once $CONF_DIR . '/base_config.php'; // $base_config
|
||||||
|
|
||||||
$config = AnimeClient::load_toml($CONF_DIR);
|
$config = AnimeClient::loadToml($CONF_DIR);
|
||||||
$config_array = array_merge($base_config, $config);
|
$config_array = array_merge($base_config, $config);
|
||||||
|
|
||||||
$di = function ($config_array) {
|
$di = function ($config_array) {
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* Hummingbird Anime Client
|
* Anime List Client
|
||||||
*
|
*
|
||||||
* An API client for Hummingbird to manage anime and manga watch lists
|
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
|
||||||
*
|
*
|
||||||
* PHP version 7
|
* PHP version 7
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package AnimeListClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2016 Timothy J. Warren
|
* @copyright 2015 - 2016 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.1
|
* @version 4.0
|
||||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* Hummingbird Anime Client
|
* Anime List Client
|
||||||
*
|
*
|
||||||
* An API client for Hummingbird to manage anime and manga watch lists
|
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
|
||||||
*
|
*
|
||||||
* PHP version 7
|
* PHP version 7
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package AnimeListClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2016 Timothy J. Warren
|
* @copyright 2015 - 2016 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.1
|
* @version 4.0
|
||||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -16,14 +16,8 @@
|
|||||||
|
|
||||||
namespace Aviat\AnimeClient;
|
namespace Aviat\AnimeClient;
|
||||||
|
|
||||||
use Aviat\Ion\Di\
|
use Aviat\Ion\Di\{ContainerAware, ContainerInterface};
|
||||||
{
|
use Aviat\Ion\View\{HtmlView, HttpView, JsonView};
|
||||||
ContainerAware, ContainerInterface
|
|
||||||
};
|
|
||||||
use Aviat\Ion\View\
|
|
||||||
{
|
|
||||||
HtmlView, HttpView, JsonView
|
|
||||||
};
|
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -103,7 +97,7 @@ class Controller {
|
|||||||
$this->response = $container->get('response');
|
$this->response = $container->get('response');
|
||||||
$this->base_data['url'] = $auraUrlGenerator;
|
$this->base_data['url'] = $auraUrlGenerator;
|
||||||
$this->base_data['urlGenerator'] = $urlGenerator;
|
$this->base_data['urlGenerator'] = $urlGenerator;
|
||||||
$this->base_data['auth'] = $container->get('auth');
|
// $this->base_data['auth'] = $container->get('auth');
|
||||||
$this->base_data['config'] = $this->config;
|
$this->base_data['config'] = $this->config;
|
||||||
$this->urlGenerator = $urlGenerator;
|
$this->urlGenerator = $urlGenerator;
|
||||||
|
|
||||||
@ -189,7 +183,7 @@ class Controller {
|
|||||||
$target = $this->session->get('redirect_url');
|
$target = $this->session->get('redirect_url');
|
||||||
if (empty($target))
|
if (empty($target))
|
||||||
{
|
{
|
||||||
$this->not_found();
|
$this->notFound();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -234,8 +228,8 @@ class Controller {
|
|||||||
$data = array_merge($this->base_data, $data);
|
$data = array_merge($this->base_data, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
$route = $router->get_route();
|
$route = $router->getRoute();
|
||||||
$data['route_path'] = $route ? $router->get_route()->path : '';
|
$data['route_path'] = $route ? $router->getRoute()->path : '';
|
||||||
|
|
||||||
|
|
||||||
$template_path = _dir($this->config->get('view_path'), "{$template}.php");
|
$template_path = _dir($this->config->get('view_path'), "{$template}.php");
|
||||||
@ -301,7 +295,7 @@ class Controller {
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function login_action()
|
public function loginAction()
|
||||||
{
|
{
|
||||||
$auth = $this->container->get('auth');
|
$auth = $this->container->get('auth');
|
||||||
$post = $this->request->getParsedBody();
|
$post = $this->request->getParsedBody();
|
||||||
@ -331,7 +325,7 @@ class Controller {
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function not_found()
|
public function notFound()
|
||||||
{
|
{
|
||||||
$this->outputHTML('404', [
|
$this->outputHTML('404', [
|
||||||
'title' => 'Sorry, page not found'
|
'title' => 'Sorry, page not found'
|
||||||
@ -347,7 +341,7 @@ class Controller {
|
|||||||
* @param string $long_message
|
* @param string $long_message
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function error_page($http_code, $title, $message, $long_message = "")
|
public function errorPage($http_code, $title, $message, $long_message = "")
|
||||||
{
|
{
|
||||||
$this->outputHTML('error', [
|
$this->outputHTML('error', [
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
@ -364,7 +358,7 @@ class Controller {
|
|||||||
* @param string $type
|
* @param string $type
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function set_flash_message($message, $type = "info")
|
public function setFlashMessage($message, $type = "info")
|
||||||
{
|
{
|
||||||
$this->session->setFlash('message', [
|
$this->session->setFlash('message', [
|
||||||
'message_type' => $type,
|
'message_type' => $type,
|
||||||
@ -377,7 +371,7 @@ class Controller {
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function clear_cache()
|
public function clearCache()
|
||||||
{
|
{
|
||||||
$this->cache->purge();
|
$this->cache->purge();
|
||||||
$this->outputHTML('blank', [
|
$this->outputHTML('blank', [
|
||||||
@ -394,7 +388,7 @@ class Controller {
|
|||||||
* @param string $message
|
* @param string $message
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function show_message($view, $type, $message)
|
protected function showMessage($view, $type, $message)
|
||||||
{
|
{
|
||||||
return $this->load_partial($view, 'message', [
|
return $this->load_partial($view, 'message', [
|
||||||
'message_type' => $type,
|
'message_type' => $type,
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* Hummingbird Anime Client
|
* Anime List Client
|
||||||
*
|
*
|
||||||
* An API client for Hummingbird to manage anime and manga watch lists
|
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
|
||||||
*
|
*
|
||||||
* PHP version 7
|
* PHP version 7
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package AnimeListClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2016 Timothy J. Warren
|
* @copyright 2015 - 2016 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.1
|
* @version 4.0
|
||||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\AnimeClient\Controller;
|
namespace Aviat\AnimeClient\Controller;
|
||||||
|
|
||||||
use Aviat\AnimeClient\Controller as BaseController;
|
use Aviat\AnimeClient\Controller as BaseController;
|
||||||
use Aviat\AnimeClient\Hummingbird\Enum\AnimeWatchingStatus;
|
use Aviat\AnimeClient\Kitsu\Enum\AnimeWatchingStatus;
|
||||||
use Aviat\AnimeClient\Hummingbird\Transformer\AnimeListTransformer;
|
use Aviat\AnimeClient\Kitsu\Transformer\AnimeListTransformer;
|
||||||
use Aviat\Ion\Di\ContainerInterface;
|
use Aviat\Ion\Di\ContainerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* Hummingbird Anime Client
|
* Anime List Client
|
||||||
*
|
*
|
||||||
* An API client for Hummingbird to manage anime and manga watch lists
|
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
|
||||||
*
|
*
|
||||||
* PHP version 7
|
* PHP version 7
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package AnimeListClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2016 Timothy J. Warren
|
* @copyright 2015 - 2016 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.1
|
* @version 4.0
|
||||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,34 +1,34 @@
|
|||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* Hummingbird Anime Client
|
* Anime List Client
|
||||||
*
|
*
|
||||||
* An API client for Hummingbird to manage anime and manga watch lists
|
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
|
||||||
*
|
*
|
||||||
* PHP version 7
|
* PHP version 7
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package AnimeListClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2016 Timothy J. Warren
|
* @copyright 2015 - 2016 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.1
|
* @version 4.0
|
||||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\AnimeClient\Controller;
|
namespace Aviat\AnimeClient\Controller;
|
||||||
|
|
||||||
use Aviat\AnimeClient\Controller;
|
use Aviat\AnimeClient\Controller;
|
||||||
use Aviat\AnimeClient\Hummingbird\Enum\MangaReadingStatus;
|
use Aviat\AnimeClient\API\Kitsu\Enum\MangaReadingStatus;
|
||||||
use Aviat\AnimeClient\Hummingbird\Transformer\MangaListTransformer;
|
use Aviat\AnimeClient\API\Kitsu\Transformer\MangaListTransformer;
|
||||||
use Aviat\AnimeClient\Model\Manga as MangaModel;
|
use Aviat\AnimeClient\Model\Manga as MangaModel;
|
||||||
use Aviat\Ion\Di\ContainerInterface;
|
use Aviat\Ion\Di\ContainerInterface;
|
||||||
use Aviat\Ion\Json;
|
use Aviat\Ion\{Json, StringWrapper};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller for manga list
|
* Controller for manga list
|
||||||
*/
|
*/
|
||||||
class Manga extends Controller {
|
class Manga extends Controller {
|
||||||
|
|
||||||
use \Aviat\Ion\StringWrapper;
|
use StringWrapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The manga model
|
* The manga model
|
||||||
|
@ -19,7 +19,6 @@ namespace Aviat\AnimeClient;
|
|||||||
use Aviat\Ion\Di\ContainerInterface;
|
use Aviat\Ion\Di\ContainerInterface;
|
||||||
use Aviat\Ion\Friend;
|
use Aviat\Ion\Friend;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic routing/ dispatch
|
* Basic routing/ dispatch
|
||||||
*/
|
*/
|
||||||
@ -61,7 +60,7 @@ class Dispatcher extends RoutingBase {
|
|||||||
$this->matcher = $container->get('aura-router')->getMatcher();
|
$this->matcher = $container->get('aura-router')->getMatcher();
|
||||||
$this->request = $container->get('request');
|
$this->request = $container->get('request');
|
||||||
|
|
||||||
$this->output_routes = $this->_setup_routes();
|
$this->output_routes = $this->_setupRoutes();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,7 +68,7 @@ class Dispatcher extends RoutingBase {
|
|||||||
*
|
*
|
||||||
* @return object
|
* @return object
|
||||||
*/
|
*/
|
||||||
public function get_route()
|
public function getRoute()
|
||||||
{
|
{
|
||||||
$logger = $this->container->getLogger('default');
|
$logger = $this->container->getLogger('default');
|
||||||
|
|
||||||
@ -89,7 +88,7 @@ class Dispatcher extends RoutingBase {
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function get_output_routes()
|
public function getOutputRoutes()
|
||||||
{
|
{
|
||||||
return $this->output_routes;
|
return $this->output_routes;
|
||||||
}
|
}
|
||||||
@ -107,7 +106,7 @@ class Dispatcher extends RoutingBase {
|
|||||||
|
|
||||||
if (is_null($route))
|
if (is_null($route))
|
||||||
{
|
{
|
||||||
$route = $this->get_route();
|
$route = $this->getRoute();
|
||||||
|
|
||||||
$logger->debug('Dispatcher - Route invoke arguments');
|
$logger->debug('Dispatcher - Route invoke arguments');
|
||||||
$logger->debug(print_r($route, TRUE));
|
$logger->debug(print_r($route, TRUE));
|
||||||
@ -115,23 +114,23 @@ class Dispatcher extends RoutingBase {
|
|||||||
|
|
||||||
if ($route)
|
if ($route)
|
||||||
{
|
{
|
||||||
$parsed = $this->process_route(new Friend($route));
|
$parsed = $this->processRoute(new Friend($route));
|
||||||
$controller_name = $parsed['controller_name'];
|
$controllerName = $parsed['controller_name'];
|
||||||
$action_method = $parsed['action_method'];
|
$actionMethod = $parsed['action_method'];
|
||||||
$params = $parsed['params'];
|
$params = $parsed['params'];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If not route was matched, return an appropriate http
|
// If not route was matched, return an appropriate http
|
||||||
// error message
|
// error message
|
||||||
$error_route = $this->get_error_params();
|
$error_route = $this->getErrorParams();
|
||||||
$controller_name = AnimeClient::DEFAULT_CONTROLLER;
|
$controllerName = AnimeClient::DEFAULT_CONTROLLER;
|
||||||
$action_method = $error_route['action_method'];
|
$actionMethod = $error_route['action_method'];
|
||||||
$params = $error_route['params'];
|
$params = $error_route['params'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actually instantiate the controller
|
// Actually instantiate the controller
|
||||||
$this->call($controller_name, $action_method, $params);
|
$this->call($controllerName, $actionMethod, $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -142,7 +141,7 @@ class Dispatcher extends RoutingBase {
|
|||||||
* @throws \LogicException
|
* @throws \LogicException
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function process_route($route)
|
protected function processRoute($route)
|
||||||
{
|
{
|
||||||
if (array_key_exists('controller', $route->attributes))
|
if (array_key_exists('controller', $route->attributes))
|
||||||
{
|
{
|
||||||
@ -156,7 +155,7 @@ class Dispatcher extends RoutingBase {
|
|||||||
// Get the full namespace for a controller if a short name is given
|
// Get the full namespace for a controller if a short name is given
|
||||||
if (strpos($controller_name, '\\') === FALSE)
|
if (strpos($controller_name, '\\') === FALSE)
|
||||||
{
|
{
|
||||||
$map = $this->get_controller_list();
|
$map = $this->getControllerList();
|
||||||
$controller_name = $map[$controller_name];
|
$controller_name = $map[$controller_name];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +190,7 @@ class Dispatcher extends RoutingBase {
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function get_controller()
|
public function getController()
|
||||||
{
|
{
|
||||||
$route_type = $this->__get('default_list');
|
$route_type = $this->__get('default_list');
|
||||||
$request_uri = $this->request->getUri()->getPath();
|
$request_uri = $this->request->getUri()->getPath();
|
||||||
@ -213,13 +212,13 @@ class Dispatcher extends RoutingBase {
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function get_controller_list()
|
public function getControllerList()
|
||||||
{
|
{
|
||||||
$default_namespace = AnimeClient::DEFAULT_CONTROLLER_NAMESPACE;
|
$default_namespace = AnimeClient::DEFAULT_CONTROLLER_NAMESPACE;
|
||||||
$path = str_replace('\\', '/', $default_namespace);
|
$path = str_replace('\\', '/', $default_namespace);
|
||||||
$path = str_replace('Aviat/AnimeClient/', '', $path);
|
$path = str_replace('Aviat/AnimeClient/', '', $path);
|
||||||
$path = trim($path, '/');
|
$path = trim($path, '/');
|
||||||
$actual_path = realpath(\_dir(AnimeClient::SRC_DIR, $path));
|
$actual_path = realpath(_dir(AnimeClient::SRC_DIR, $path));
|
||||||
$class_files = glob("{$actual_path}/*.php");
|
$class_files = glob("{$actual_path}/*.php");
|
||||||
|
|
||||||
$controllers = [];
|
$controllers = [];
|
||||||
@ -240,16 +239,16 @@ class Dispatcher extends RoutingBase {
|
|||||||
* Create the controller object and call the appropriate
|
* Create the controller object and call the appropriate
|
||||||
* method
|
* method
|
||||||
*
|
*
|
||||||
* @param string $controller_name - The full namespace of the controller class
|
* @param string $controllerName - The full namespace of the controller class
|
||||||
* @param string $method
|
* @param string $method
|
||||||
* @param array $params
|
* @param array $params
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function call($controller_name, $method, array $params)
|
protected function call($controllerName, $method, array $params)
|
||||||
{
|
{
|
||||||
$logger = $this->container->getLogger('default');
|
$logger = $this->container->getLogger('default');
|
||||||
|
|
||||||
$controller = new $controller_name($this->container);
|
$controller = new $controllerName($this->container);
|
||||||
|
|
||||||
// Run the appropriate controller method
|
// Run the appropriate controller method
|
||||||
$logger->debug('Dispatcher - controller arguments');
|
$logger->debug('Dispatcher - controller arguments');
|
||||||
@ -263,7 +262,7 @@ class Dispatcher extends RoutingBase {
|
|||||||
*
|
*
|
||||||
* @return array|false
|
* @return array|false
|
||||||
*/
|
*/
|
||||||
protected function get_error_params()
|
protected function getErrorParams()
|
||||||
{
|
{
|
||||||
$logger = $this->container->getLogger('default');
|
$logger = $this->container->getLogger('default');
|
||||||
$failure = $this->matcher->getFailedRoute();
|
$failure = $this->matcher->getFailedRoute();
|
||||||
@ -309,9 +308,9 @@ class Dispatcher extends RoutingBase {
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function _setup_routes()
|
protected function _setupRoutes()
|
||||||
{
|
{
|
||||||
$route_type = $this->get_controller();
|
$route_type = $this->getController();
|
||||||
|
|
||||||
// Add routes
|
// Add routes
|
||||||
$routes = [];
|
$routes = [];
|
||||||
@ -320,7 +319,7 @@ class Dispatcher extends RoutingBase {
|
|||||||
$path = $route['path'];
|
$path = $route['path'];
|
||||||
unset($route['path']);
|
unset($route['path']);
|
||||||
|
|
||||||
$controller_map = $this->get_controller_list();
|
$controller_map = $this->getControllerList();
|
||||||
$controller_class = (array_key_exists($route_type, $controller_map))
|
$controller_class = (array_key_exists($route_type, $controller_map))
|
||||||
? $controller_map[$route_type]
|
? $controller_map[$route_type]
|
||||||
: AnimeClient::DEFAULT_CONTROLLER;
|
: AnimeClient::DEFAULT_CONTROLLER;
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* Hummingbird Anime Client
|
* Anime List Client
|
||||||
*
|
*
|
||||||
* An API client for Hummingbird to manage anime and manga watch lists
|
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
|
||||||
*
|
*
|
||||||
* PHP version 7
|
* PHP version 7
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package AnimeListClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2016 Timothy J. Warren
|
* @copyright 2015 - 2016 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.1
|
* @version 4.0
|
||||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* Hummingbird Anime Client
|
* Anime List Client
|
||||||
*
|
*
|
||||||
* An API client for Hummingbird to manage anime and manga watch lists
|
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
|
||||||
*
|
*
|
||||||
* PHP version 7
|
* PHP version 7
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package AnimeListClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2016 Timothy J. Warren
|
* @copyright 2015 - 2016 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.1
|
* @version 4.0
|
||||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\AnimeClient\Model;
|
namespace Aviat\AnimeClient\Model;
|
||||||
|
|
||||||
use Aviat\AnimeClient\AnimeClient;
|
use Aviat\AnimeClient\AnimeClient;
|
||||||
use Aviat\Ion\Di\ContainerInterface;
|
use Aviat\Ion\Di\{ContainerAware, ContainerInterface};
|
||||||
use Aviat\Ion\Model;
|
use Aviat\Ion\Model;
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use GuzzleHttp\Cookie\CookieJar;
|
use GuzzleHttp\Cookie\CookieJar;
|
||||||
@ -36,7 +36,7 @@ use Psr\Http\Message\ResponseInterface;
|
|||||||
*/
|
*/
|
||||||
class API extends Model {
|
class API extends Model {
|
||||||
|
|
||||||
use \Aviat\Ion\Di\ContainerAware;
|
use ContainerAware;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Config manager
|
* Config manager
|
||||||
@ -68,6 +68,12 @@ class API extends Model {
|
|||||||
*/
|
*/
|
||||||
protected $cache;
|
protected $cache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default settings for Guzzle
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $connectionDefaults = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@ -93,15 +99,16 @@ class API extends Model {
|
|||||||
'base_uri' => $this->base_url,
|
'base_uri' => $this->base_url,
|
||||||
'cookies' => TRUE,
|
'cookies' => TRUE,
|
||||||
'http_errors' => FALSE,
|
'http_errors' => FALSE,
|
||||||
'defaults' => [
|
'defaults' => array_merge([
|
||||||
'cookies' => $this->cookieJar,
|
'cookies' => $this->cookieJar,
|
||||||
'headers' => [
|
'headers' => [
|
||||||
'User-Agent' => "Tim's Anime Client/3.0",
|
'User-Agent' => "Tim's Anime Client/4.0",
|
||||||
'Accept-Encoding' => 'application/json'
|
'Accept-Encoding' => 'application/vnd.api+json',
|
||||||
|
'Content-Type' => 'application/vnd.api+json'
|
||||||
],
|
],
|
||||||
'timeout' => 25,
|
'timeout' => 25,
|
||||||
'connect_timeout' => 25
|
'connect_timeout' => 25
|
||||||
]
|
], $this->connectionDefaults)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,12 +123,19 @@ class API extends Model {
|
|||||||
{
|
{
|
||||||
$valid_methods = [
|
$valid_methods = [
|
||||||
'get',
|
'get',
|
||||||
|
'getAsync',
|
||||||
'delete',
|
'delete',
|
||||||
|
'deleteAsync',
|
||||||
'head',
|
'head',
|
||||||
|
'headAsync',
|
||||||
'options',
|
'options',
|
||||||
|
'optionsAsync',
|
||||||
'patch',
|
'patch',
|
||||||
|
'patchAsync',
|
||||||
'post',
|
'post',
|
||||||
'put'
|
'postAsync',
|
||||||
|
'put',
|
||||||
|
'putAsync'
|
||||||
];
|
];
|
||||||
|
|
||||||
if ( ! in_array($method, $valid_methods))
|
if ( ! in_array($method, $valid_methods))
|
||||||
@ -172,31 +186,6 @@ class API extends Model {
|
|||||||
array_multisort($sort, SORT_ASC, $array);
|
array_multisort($sort, SORT_ASC, $array);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Attempt login via the api
|
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
* @param string $username
|
|
||||||
* @param string $password
|
|
||||||
* @return string|false
|
|
||||||
*/
|
|
||||||
public function authenticate(string $username, string $password)
|
|
||||||
{
|
|
||||||
$response = $this->post(AnimeClient::HUMMINGBIRD_AUTH_URL, [
|
|
||||||
'form_params' => [
|
|
||||||
'username' => $username,
|
|
||||||
'password' => $password
|
|
||||||
]
|
|
||||||
]);
|
|
||||||
|
|
||||||
if ($response->getStatusCode() === 201)
|
|
||||||
{
|
|
||||||
return json_decode((string)$response->getBody(), TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dummy function that should be abstract. Is not abstract because
|
* Dummy function that should be abstract. Is not abstract because
|
||||||
* this class is used concretely for authorizing API calls
|
* this class is used concretely for authorizing API calls
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* Hummingbird Anime Client
|
* Anime List Client
|
||||||
*
|
*
|
||||||
* An API client for Hummingbird to manage anime and manga watch lists
|
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
|
||||||
*
|
*
|
||||||
* PHP version 7
|
* PHP version 7
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package AnimeListClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2016 Timothy J. Warren
|
* @copyright 2015 - 2016 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.1
|
* @version 4.0
|
||||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\AnimeClient\Model;
|
namespace Aviat\AnimeClient\Model;
|
||||||
|
|
||||||
use Aviat\AnimeClient\Hummingbird\Enum\AnimeWatchingStatus;
|
use Aviat\AnimeClient\API\Kitsu\Enum\AnimeWatchingStatus;
|
||||||
use Aviat\AnimeClient\Hummingbird\Transformer\AnimeListTransformer;
|
use Aviat\AnimeClient\API\Kitsu\Transformer\AnimeListTransformer;
|
||||||
use Aviat\Ion\Json;
|
use Aviat\Ion\Json;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,7 +36,7 @@ class Anime extends API {
|
|||||||
* The base url for api requests
|
* The base url for api requests
|
||||||
* @var string $base_url
|
* @var string $base_url
|
||||||
*/
|
*/
|
||||||
protected $base_url = "https://hummingbird.me/api/v1/";
|
protected $base_url = "https://kitsu.io/api/edge/";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map of API status constants to display constants
|
* Map of API status constants to display constants
|
||||||
@ -226,7 +226,7 @@ class Anime extends API {
|
|||||||
$config['query']['auth_token'] = $auth->get_auth_token();
|
$config['query']['auth_token'] = $auth->get_auth_token();
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = $this->get("users/{$username}/library", $config);
|
$response = $this->get("library-entries?filter[media_type]=Anime&filter[user_id]=2644&filter[status]=1,2&include=media", $config);
|
||||||
$output = $this->transform($status, $response);
|
$output = $this->transform($status, $response);
|
||||||
|
|
||||||
$util = $this->container->get('util');
|
$util = $this->container->get('util');
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* Hummingbird Anime Client
|
* Anime List Client
|
||||||
*
|
*
|
||||||
* An API client for Hummingbird to manage anime and manga watch lists
|
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
|
||||||
*
|
*
|
||||||
* PHP version 7
|
* PHP version 7
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package AnimeListClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2016 Timothy J. Warren
|
* @copyright 2015 - 2016 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.1
|
* @version 4.0
|
||||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* Hummingbird Anime Client
|
* Anime List Client
|
||||||
*
|
*
|
||||||
* An API client for Hummingbird to manage anime and manga watch lists
|
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
|
||||||
*
|
*
|
||||||
* PHP version 7
|
* PHP version 7
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package AnimeListClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2016 Timothy J. Warren
|
* @copyright 2015 - 2016 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.1
|
* @version 4.0
|
||||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* Hummingbird Anime Client
|
* Anime List Client
|
||||||
*
|
*
|
||||||
* An API client for Hummingbird to manage anime and manga watch lists
|
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
|
||||||
*
|
*
|
||||||
* PHP version 7
|
* PHP version 7
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package AnimeListClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2016 Timothy J. Warren
|
* @copyright 2015 - 2016 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.1
|
* @version 4.0
|
||||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* Hummingbird Anime Client
|
* Anime List Client
|
||||||
*
|
*
|
||||||
* An API client for Hummingbird to manage anime and manga watch lists
|
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
|
||||||
*
|
*
|
||||||
* PHP version 7
|
* PHP version 7
|
||||||
*
|
*
|
||||||
* @package HummingbirdAnimeClient
|
* @package AnimeListClient
|
||||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
* @copyright 2015 - 2016 Timothy J. Warren
|
* @copyright 2015 - 2016 Timothy J. Warren
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @version 3.1
|
* @version 4.0
|
||||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\AnimeClient\Model;
|
namespace Aviat\AnimeClient\Model;
|
||||||
|
|
||||||
use Aviat\AnimeClient\Hummingbird\Enum\MangaReadingStatus;
|
use Aviat\AnimeClient\API\Kitsu\Enum\MangaReadingStatus;
|
||||||
use Aviat\AnimeClient\Hummingbird\Transformer;
|
use Aviat\AnimeClient\API\Kitsu\Transformer;
|
||||||
use Aviat\Ion\Json;
|
use Aviat\Ion\Json;
|
||||||
use GuzzleHttp\Cookie\SetCookie;
|
use GuzzleHttp\Cookie\SetCookie;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
|
@ -18,14 +18,15 @@ namespace Aviat\AnimeClient;
|
|||||||
|
|
||||||
use abeautifulsite\SimpleImage;
|
use abeautifulsite\SimpleImage;
|
||||||
use Aviat\Ion\ConfigInterface;
|
use Aviat\Ion\ConfigInterface;
|
||||||
use Aviat\Ion\Di\ContainerInterface;
|
use Aviat\Ion\Di\{ContainerAware, ContainerInterface};
|
||||||
|
use DomainException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility method class
|
* Utility method class
|
||||||
*/
|
*/
|
||||||
class Util {
|
class Util {
|
||||||
|
|
||||||
use \Aviat\Ion\Di\ContainerAware;
|
use ContainerAware;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Routes that don't require a second navigation level
|
* Routes that don't require a second navigation level
|
||||||
@ -164,7 +165,7 @@ class Util {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new \DomainException("Couldn't cache images because they couldn't be downloaded.");
|
throw new DomainException("Couldn't cache images because they couldn't be downloaded.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resize the image
|
// Resize the image
|
||||||
|
@ -137,7 +137,7 @@ class DispatcherTest extends AnimeClient_TestCase {
|
|||||||
|
|
||||||
// Check route setup
|
// Check route setup
|
||||||
$this->assertEquals($config['routes'], $this->config->get('routes'), "Incorrect route path");
|
$this->assertEquals($config['routes'], $this->config->get('routes'), "Incorrect route path");
|
||||||
$this->assertTrue(is_array($this->router->get_output_routes()));
|
$this->assertTrue(is_array($this->router->getOutputRoutes()));
|
||||||
|
|
||||||
// Check environment variables
|
// Check environment variables
|
||||||
$this->assertEquals($uri, $request->getServerParams()['REQUEST_URI']);
|
$this->assertEquals($uri, $request->getServerParams()['REQUEST_URI']);
|
||||||
@ -145,10 +145,10 @@ class DispatcherTest extends AnimeClient_TestCase {
|
|||||||
|
|
||||||
// Make sure the route is an anime type
|
// Make sure the route is an anime type
|
||||||
//$this->assertTrue($matcher->count() > 0, "0 routes");
|
//$this->assertTrue($matcher->count() > 0, "0 routes");
|
||||||
$this->assertEquals($controller, $this->router->get_controller(), "Incorrect Route type");
|
$this->assertEquals($controller, $this->router->getController(), "Incorrect Route type");
|
||||||
|
|
||||||
// Make sure the route matches, by checking that it is actually an object
|
// Make sure the route matches, by checking that it is actually an object
|
||||||
$route = $this->router->get_route();
|
$route = $this->router->getRoute();
|
||||||
$this->assertInstanceOf('Aura\\Router\\Route', $route, "Route is invalid, not matched");
|
$this->assertInstanceOf('Aura\\Router\\Route', $route, "Route is invalid, not matched");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,6 +252,6 @@ class DispatcherTest extends AnimeClient_TestCase {
|
|||||||
public function testGetControllerList($config, $expected)
|
public function testGetControllerList($config, $expected)
|
||||||
{
|
{
|
||||||
$this->_set_up($config, '/', 'localhost');
|
$this->_set_up($config, '/', 'localhost');
|
||||||
$this->assertEquals($expected, $this->router->get_controller_list());
|
$this->assertEquals($expected, $this->router->getControllerList());
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user