Ugly progress commit
This commit is contained in:
parent
e097b02457
commit
c9f5964d5e
@ -17,6 +17,15 @@ test:7:
|
||||
script:
|
||||
- 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:
|
||||
before_script:
|
||||
- /usr/local/bin/composer self-update
|
||||
|
@ -1,16 +1,16 @@
|
||||
<?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
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @package AnimeListClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
* @copyright 2015 - 2016 Timothy J. Warren
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @version 3.1
|
||||
* @version 4.0
|
||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||
*/
|
||||
|
||||
@ -19,16 +19,14 @@ namespace Aviat\AnimeClient;
|
||||
use Aura\Html\HelperLocatorFactory;
|
||||
use Aura\Router\RouterContainer;
|
||||
use Aura\Session\SessionFactory;
|
||||
use Monolog\Logger;
|
||||
use Monolog\Handler\RotatingFileHandler;
|
||||
use Zend\Diactoros\ServerRequestFactory;
|
||||
use Zend\Diactoros\Response;
|
||||
|
||||
use Aviat\AnimeClient\API\Kitsu\Auth as KitsuAuth;
|
||||
use Aviat\AnimeClient\Model;
|
||||
use Aviat\Ion\Cache\CacheManager;
|
||||
use Aviat\Ion\Config;
|
||||
use Aviat\Ion\Di\Container;
|
||||
use Aviat\Ion\Cache\CacheManager;
|
||||
use Aviat\AnimeClient\Auth\HummingbirdAuth;
|
||||
use Aviat\AnimeClient\Model;
|
||||
use Monolog\Handler\RotatingFileHandler;
|
||||
use Monolog\Logger;
|
||||
use Zend\Diactoros\{Response, ServerRequestFactory};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Setup DI container
|
||||
@ -115,9 +113,9 @@ return function(array $config_array = []) {
|
||||
});
|
||||
|
||||
// Miscellaneous Classes
|
||||
$container->set('auth', function($container) {
|
||||
/* $container->set('auth', function($container) {
|
||||
return new HummingbirdAuth($container);
|
||||
});
|
||||
}); */
|
||||
$container->set('url-generator', function($container) {
|
||||
return new UrlGenerator($container);
|
||||
});
|
||||
|
@ -147,7 +147,7 @@ return [
|
||||
// ---------------------------------------------------------------------
|
||||
'cache_purge' => [
|
||||
'path' => '/cache_purge',
|
||||
'action' => 'clear_cache',
|
||||
'action' => 'clearCache',
|
||||
'controller' => AnimeClient::DEFAULT_CONTROLLER_NAMESPACE,
|
||||
'verb' => 'get',
|
||||
],
|
||||
@ -159,7 +159,7 @@ return [
|
||||
],
|
||||
'login.post' => [
|
||||
'path' => '/login',
|
||||
'action' => 'login_action',
|
||||
'action' => 'loginAction',
|
||||
'controller' => AnimeClient::DEFAULT_CONTROLLER_NAMESPACE,
|
||||
'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">
|
||||
<span class="flex-no-wrap grow-1">
|
||||
<?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
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @package AnimeListClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
* @copyright 2015 - 2016 Timothy J. Warren
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @version 3.1
|
||||
* @version 4.0
|
||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||
*/
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
$animeclient_file_patterns = [
|
||||
'app/config/*.php',
|
||||
$file_patterns = [
|
||||
'app/bootstrap.php',
|
||||
'src/functions.php',
|
||||
'src/*.php',
|
||||
'tests/**/*.php'
|
||||
'migrations/*.php',
|
||||
'src/**/*.php',
|
||||
'tests/**/*.php',
|
||||
];
|
||||
|
||||
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);
|
||||
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";
|
@ -41,5 +41,8 @@
|
||||
"henrikbjorn/lurker": "^1.1.0",
|
||||
"symfony/var-dumper": "^3.1",
|
||||
"squizlabs/php_codesniffer": "^3.0.0@beta"
|
||||
},
|
||||
"scripts": {
|
||||
|
||||
}
|
||||
}
|
||||
|
20
console
20
console
@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
use Aviat\AnimeClient\Model;
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
if ( ! function_exists('_dir'))
|
||||
{
|
||||
@ -23,23 +22,6 @@ $APP_DIR = __DIR__ . '/app/';
|
||||
$SRC_DIR = __DIR__ . '/src/';
|
||||
$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
|
||||
require_once realpath(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
|
@ -13,8 +13,11 @@
|
||||
* @version 3.1
|
||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||
*/
|
||||
namespace Aviat\AnimeClient;
|
||||
|
||||
use Aviat\AnimeClient\AnimeClient;
|
||||
use Whoops\Handler\PrettyPageHandler;
|
||||
use Whoops\Run;
|
||||
|
||||
// Work around the silly timezone error
|
||||
$timezone = ini_get('date.timezone');
|
||||
@ -44,7 +47,7 @@ require _dir(__DIR__, '/vendor/autoload.php');
|
||||
// -------------------------------------------------------------------------
|
||||
// Setup error handling
|
||||
// -------------------------------------------------------------------------
|
||||
$whoops = new \Whoops\Run();
|
||||
$whoops = new Run();
|
||||
|
||||
// Set up default handler for general errors
|
||||
$defaultHandler = new PrettyPageHandler();
|
||||
@ -63,7 +66,7 @@ $whoops->register();
|
||||
require _dir($CONF_DIR, 'base_config.php'); // $base_config
|
||||
$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);
|
||||
|
||||
$container = $di($config_array);
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
|
@ -26,12 +26,13 @@ define('SRC_DIR', realpath(__DIR__));
|
||||
class AnimeClient {
|
||||
|
||||
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 DEFAULT_CONTROLLER_NAMESPACE = 'Aviat\AnimeClient\Controller';
|
||||
const DEFAULT_CONTROLLER = 'Aviat\AnimeClient\Controller\Anime';
|
||||
const DEFAULT_CONTROLLER_METHOD = 'index';
|
||||
const NOT_FOUND_METHOD = 'not_found';
|
||||
const ERROR_MESSAGE_METHOD = 'error_page';
|
||||
const NOT_FOUND_METHOD = 'notFound';
|
||||
const ERROR_MESSAGE_METHOD = 'errorPage';
|
||||
const SRC_DIR = SRC_DIR;
|
||||
|
||||
/**
|
||||
@ -40,7 +41,7 @@ class AnimeClient {
|
||||
* @param string $path - Path to load config
|
||||
* @return array
|
||||
*/
|
||||
public static function load_toml($path)
|
||||
public static function loadToml(string $path): array
|
||||
{
|
||||
$output = [];
|
||||
$files = glob("{$path}/*.toml");
|
||||
|
@ -1,16 +1,16 @@
|
||||
<?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
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @package AnimeListClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
* @copyright 2015 - 2016 Timothy J. Warren
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @version 3.1
|
||||
* @version 4.0
|
||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||
*/
|
||||
|
||||
@ -57,7 +57,7 @@ class BaseCommand extends Command {
|
||||
$CONF_DIR = realpath(__DIR__ . '/../../app/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);
|
||||
|
||||
$di = function ($config_array) {
|
||||
|
@ -1,16 +1,16 @@
|
||||
<?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
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @package AnimeListClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
* @copyright 2015 - 2016 Timothy J. Warren
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @version 3.1
|
||||
* @version 4.0
|
||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||
*/
|
||||
|
||||
|
@ -1,16 +1,16 @@
|
||||
<?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
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @package AnimeListClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
* @copyright 2015 - 2016 Timothy J. Warren
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @version 3.1
|
||||
* @version 4.0
|
||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||
*/
|
||||
|
||||
|
@ -16,14 +16,8 @@
|
||||
|
||||
namespace Aviat\AnimeClient;
|
||||
|
||||
use Aviat\Ion\Di\
|
||||
{
|
||||
ContainerAware, ContainerInterface
|
||||
};
|
||||
use Aviat\Ion\View\
|
||||
{
|
||||
HtmlView, HttpView, JsonView
|
||||
};
|
||||
use Aviat\Ion\Di\{ContainerAware, ContainerInterface};
|
||||
use Aviat\Ion\View\{HtmlView, HttpView, JsonView};
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
@ -103,7 +97,7 @@ class Controller {
|
||||
$this->response = $container->get('response');
|
||||
$this->base_data['url'] = $auraUrlGenerator;
|
||||
$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->urlGenerator = $urlGenerator;
|
||||
|
||||
@ -189,7 +183,7 @@ class Controller {
|
||||
$target = $this->session->get('redirect_url');
|
||||
if (empty($target))
|
||||
{
|
||||
$this->not_found();
|
||||
$this->notFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -234,8 +228,8 @@ class Controller {
|
||||
$data = array_merge($this->base_data, $data);
|
||||
}
|
||||
|
||||
$route = $router->get_route();
|
||||
$data['route_path'] = $route ? $router->get_route()->path : '';
|
||||
$route = $router->getRoute();
|
||||
$data['route_path'] = $route ? $router->getRoute()->path : '';
|
||||
|
||||
|
||||
$template_path = _dir($this->config->get('view_path'), "{$template}.php");
|
||||
@ -301,7 +295,7 @@ class Controller {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function login_action()
|
||||
public function loginAction()
|
||||
{
|
||||
$auth = $this->container->get('auth');
|
||||
$post = $this->request->getParsedBody();
|
||||
@ -331,7 +325,7 @@ class Controller {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function not_found()
|
||||
public function notFound()
|
||||
{
|
||||
$this->outputHTML('404', [
|
||||
'title' => 'Sorry, page not found'
|
||||
@ -347,7 +341,7 @@ class Controller {
|
||||
* @param string $long_message
|
||||
* @return void
|
||||
*/
|
||||
public function error_page($http_code, $title, $message, $long_message = "")
|
||||
public function errorPage($http_code, $title, $message, $long_message = "")
|
||||
{
|
||||
$this->outputHTML('error', [
|
||||
'title' => $title,
|
||||
@ -364,7 +358,7 @@ class Controller {
|
||||
* @param string $type
|
||||
* @return void
|
||||
*/
|
||||
public function set_flash_message($message, $type = "info")
|
||||
public function setFlashMessage($message, $type = "info")
|
||||
{
|
||||
$this->session->setFlash('message', [
|
||||
'message_type' => $type,
|
||||
@ -377,7 +371,7 @@ class Controller {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clear_cache()
|
||||
public function clearCache()
|
||||
{
|
||||
$this->cache->purge();
|
||||
$this->outputHTML('blank', [
|
||||
@ -394,7 +388,7 @@ class Controller {
|
||||
* @param string $message
|
||||
* @return string
|
||||
*/
|
||||
protected function show_message($view, $type, $message)
|
||||
protected function showMessage($view, $type, $message)
|
||||
{
|
||||
return $this->load_partial($view, 'message', [
|
||||
'message_type' => $type,
|
||||
|
@ -1,24 +1,24 @@
|
||||
<?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
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @package AnimeListClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
* @copyright 2015 - 2016 Timothy J. Warren
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @version 3.1
|
||||
* @version 4.0
|
||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||
*/
|
||||
|
||||
namespace Aviat\AnimeClient\Controller;
|
||||
|
||||
use Aviat\AnimeClient\Controller as BaseController;
|
||||
use Aviat\AnimeClient\Hummingbird\Enum\AnimeWatchingStatus;
|
||||
use Aviat\AnimeClient\Hummingbird\Transformer\AnimeListTransformer;
|
||||
use Aviat\AnimeClient\Kitsu\Enum\AnimeWatchingStatus;
|
||||
use Aviat\AnimeClient\Kitsu\Transformer\AnimeListTransformer;
|
||||
use Aviat\Ion\Di\ContainerInterface;
|
||||
|
||||
/**
|
||||
|
@ -1,16 +1,16 @@
|
||||
<?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
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @package AnimeListClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
* @copyright 2015 - 2016 Timothy J. Warren
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @version 3.1
|
||||
* @version 4.0
|
||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||
*/
|
||||
|
||||
|
@ -1,34 +1,34 @@
|
||||
<?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
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @package AnimeListClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
* @copyright 2015 - 2016 Timothy J. Warren
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @version 3.1
|
||||
* @version 4.0
|
||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||
*/
|
||||
|
||||
namespace Aviat\AnimeClient\Controller;
|
||||
|
||||
use Aviat\AnimeClient\Controller;
|
||||
use Aviat\AnimeClient\Hummingbird\Enum\MangaReadingStatus;
|
||||
use Aviat\AnimeClient\Hummingbird\Transformer\MangaListTransformer;
|
||||
use Aviat\AnimeClient\API\Kitsu\Enum\MangaReadingStatus;
|
||||
use Aviat\AnimeClient\API\Kitsu\Transformer\MangaListTransformer;
|
||||
use Aviat\AnimeClient\Model\Manga as MangaModel;
|
||||
use Aviat\Ion\Di\ContainerInterface;
|
||||
use Aviat\Ion\Json;
|
||||
use Aviat\Ion\{Json, StringWrapper};
|
||||
|
||||
/**
|
||||
* Controller for manga list
|
||||
*/
|
||||
class Manga extends Controller {
|
||||
|
||||
use \Aviat\Ion\StringWrapper;
|
||||
use StringWrapper;
|
||||
|
||||
/**
|
||||
* The manga model
|
||||
|
@ -19,7 +19,6 @@ namespace Aviat\AnimeClient;
|
||||
use Aviat\Ion\Di\ContainerInterface;
|
||||
use Aviat\Ion\Friend;
|
||||
|
||||
|
||||
/**
|
||||
* Basic routing/ dispatch
|
||||
*/
|
||||
@ -61,7 +60,7 @@ class Dispatcher extends RoutingBase {
|
||||
$this->matcher = $container->get('aura-router')->getMatcher();
|
||||
$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
|
||||
*/
|
||||
public function get_route()
|
||||
public function getRoute()
|
||||
{
|
||||
$logger = $this->container->getLogger('default');
|
||||
|
||||
@ -89,7 +88,7 @@ class Dispatcher extends RoutingBase {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_output_routes()
|
||||
public function getOutputRoutes()
|
||||
{
|
||||
return $this->output_routes;
|
||||
}
|
||||
@ -107,7 +106,7 @@ class Dispatcher extends RoutingBase {
|
||||
|
||||
if (is_null($route))
|
||||
{
|
||||
$route = $this->get_route();
|
||||
$route = $this->getRoute();
|
||||
|
||||
$logger->debug('Dispatcher - Route invoke arguments');
|
||||
$logger->debug(print_r($route, TRUE));
|
||||
@ -115,23 +114,23 @@ class Dispatcher extends RoutingBase {
|
||||
|
||||
if ($route)
|
||||
{
|
||||
$parsed = $this->process_route(new Friend($route));
|
||||
$controller_name = $parsed['controller_name'];
|
||||
$action_method = $parsed['action_method'];
|
||||
$parsed = $this->processRoute(new Friend($route));
|
||||
$controllerName = $parsed['controller_name'];
|
||||
$actionMethod = $parsed['action_method'];
|
||||
$params = $parsed['params'];
|
||||
}
|
||||
else
|
||||
{
|
||||
// If not route was matched, return an appropriate http
|
||||
// error message
|
||||
$error_route = $this->get_error_params();
|
||||
$controller_name = AnimeClient::DEFAULT_CONTROLLER;
|
||||
$action_method = $error_route['action_method'];
|
||||
$error_route = $this->getErrorParams();
|
||||
$controllerName = AnimeClient::DEFAULT_CONTROLLER;
|
||||
$actionMethod = $error_route['action_method'];
|
||||
$params = $error_route['params'];
|
||||
}
|
||||
|
||||
// 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
|
||||
* @return array
|
||||
*/
|
||||
protected function process_route($route)
|
||||
protected function processRoute($route)
|
||||
{
|
||||
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
|
||||
if (strpos($controller_name, '\\') === FALSE)
|
||||
{
|
||||
$map = $this->get_controller_list();
|
||||
$map = $this->getControllerList();
|
||||
$controller_name = $map[$controller_name];
|
||||
}
|
||||
|
||||
@ -191,7 +190,7 @@ class Dispatcher extends RoutingBase {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_controller()
|
||||
public function getController()
|
||||
{
|
||||
$route_type = $this->__get('default_list');
|
||||
$request_uri = $this->request->getUri()->getPath();
|
||||
@ -213,13 +212,13 @@ class Dispatcher extends RoutingBase {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_controller_list()
|
||||
public function getControllerList()
|
||||
{
|
||||
$default_namespace = AnimeClient::DEFAULT_CONTROLLER_NAMESPACE;
|
||||
$path = str_replace('\\', '/', $default_namespace);
|
||||
$path = str_replace('Aviat/AnimeClient/', '', $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");
|
||||
|
||||
$controllers = [];
|
||||
@ -240,16 +239,16 @@ class Dispatcher extends RoutingBase {
|
||||
* Create the controller object and call the appropriate
|
||||
* 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 array $params
|
||||
* @return void
|
||||
*/
|
||||
protected function call($controller_name, $method, array $params)
|
||||
protected function call($controllerName, $method, array $params)
|
||||
{
|
||||
$logger = $this->container->getLogger('default');
|
||||
|
||||
$controller = new $controller_name($this->container);
|
||||
$controller = new $controllerName($this->container);
|
||||
|
||||
// Run the appropriate controller method
|
||||
$logger->debug('Dispatcher - controller arguments');
|
||||
@ -263,7 +262,7 @@ class Dispatcher extends RoutingBase {
|
||||
*
|
||||
* @return array|false
|
||||
*/
|
||||
protected function get_error_params()
|
||||
protected function getErrorParams()
|
||||
{
|
||||
$logger = $this->container->getLogger('default');
|
||||
$failure = $this->matcher->getFailedRoute();
|
||||
@ -309,9 +308,9 @@ class Dispatcher extends RoutingBase {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function _setup_routes()
|
||||
protected function _setupRoutes()
|
||||
{
|
||||
$route_type = $this->get_controller();
|
||||
$route_type = $this->getController();
|
||||
|
||||
// Add routes
|
||||
$routes = [];
|
||||
@ -320,7 +319,7 @@ class Dispatcher extends RoutingBase {
|
||||
$path = $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_map[$route_type]
|
||||
: AnimeClient::DEFAULT_CONTROLLER;
|
||||
|
@ -1,16 +1,16 @@
|
||||
<?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
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @package AnimeListClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
* @copyright 2015 - 2016 Timothy J. Warren
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @version 3.1
|
||||
* @version 4.0
|
||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||
*/
|
||||
|
||||
|
@ -1,23 +1,23 @@
|
||||
<?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
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @package AnimeListClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
* @copyright 2015 - 2016 Timothy J. Warren
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @version 3.1
|
||||
* @version 4.0
|
||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||
*/
|
||||
|
||||
namespace Aviat\AnimeClient\Model;
|
||||
|
||||
use Aviat\AnimeClient\AnimeClient;
|
||||
use Aviat\Ion\Di\ContainerInterface;
|
||||
use Aviat\Ion\Di\{ContainerAware, ContainerInterface};
|
||||
use Aviat\Ion\Model;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Cookie\CookieJar;
|
||||
@ -36,7 +36,7 @@ use Psr\Http\Message\ResponseInterface;
|
||||
*/
|
||||
class API extends Model {
|
||||
|
||||
use \Aviat\Ion\Di\ContainerAware;
|
||||
use ContainerAware;
|
||||
|
||||
/**
|
||||
* Config manager
|
||||
@ -68,6 +68,12 @@ class API extends Model {
|
||||
*/
|
||||
protected $cache;
|
||||
|
||||
/**
|
||||
* Default settings for Guzzle
|
||||
* @var array
|
||||
*/
|
||||
protected $connectionDefaults = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -93,15 +99,16 @@ class API extends Model {
|
||||
'base_uri' => $this->base_url,
|
||||
'cookies' => TRUE,
|
||||
'http_errors' => FALSE,
|
||||
'defaults' => [
|
||||
'defaults' => array_merge([
|
||||
'cookies' => $this->cookieJar,
|
||||
'headers' => [
|
||||
'User-Agent' => "Tim's Anime Client/3.0",
|
||||
'Accept-Encoding' => 'application/json'
|
||||
'User-Agent' => "Tim's Anime Client/4.0",
|
||||
'Accept-Encoding' => 'application/vnd.api+json',
|
||||
'Content-Type' => 'application/vnd.api+json'
|
||||
],
|
||||
'timeout' => 25,
|
||||
'connect_timeout' => 25
|
||||
]
|
||||
], $this->connectionDefaults)
|
||||
]);
|
||||
}
|
||||
|
||||
@ -116,12 +123,19 @@ class API extends Model {
|
||||
{
|
||||
$valid_methods = [
|
||||
'get',
|
||||
'getAsync',
|
||||
'delete',
|
||||
'deleteAsync',
|
||||
'head',
|
||||
'headAsync',
|
||||
'options',
|
||||
'optionsAsync',
|
||||
'patch',
|
||||
'patchAsync',
|
||||
'post',
|
||||
'put'
|
||||
'postAsync',
|
||||
'put',
|
||||
'putAsync'
|
||||
];
|
||||
|
||||
if ( ! in_array($method, $valid_methods))
|
||||
@ -172,31 +186,6 @@ class API extends Model {
|
||||
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
|
||||
* this class is used concretely for authorizing API calls
|
||||
|
@ -1,23 +1,23 @@
|
||||
<?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
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @package AnimeListClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
* @copyright 2015 - 2016 Timothy J. Warren
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @version 3.1
|
||||
* @version 4.0
|
||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||
*/
|
||||
|
||||
namespace Aviat\AnimeClient\Model;
|
||||
|
||||
use Aviat\AnimeClient\Hummingbird\Enum\AnimeWatchingStatus;
|
||||
use Aviat\AnimeClient\Hummingbird\Transformer\AnimeListTransformer;
|
||||
use Aviat\AnimeClient\API\Kitsu\Enum\AnimeWatchingStatus;
|
||||
use Aviat\AnimeClient\API\Kitsu\Transformer\AnimeListTransformer;
|
||||
use Aviat\Ion\Json;
|
||||
|
||||
/**
|
||||
@ -36,7 +36,7 @@ class Anime extends API {
|
||||
* The base url for api requests
|
||||
* @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
|
||||
@ -226,7 +226,7 @@ class Anime extends API {
|
||||
$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);
|
||||
|
||||
$util = $this->container->get('util');
|
||||
|
@ -1,16 +1,16 @@
|
||||
<?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
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @package AnimeListClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
* @copyright 2015 - 2016 Timothy J. Warren
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @version 3.1
|
||||
* @version 4.0
|
||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||
*/
|
||||
|
||||
|
@ -1,16 +1,16 @@
|
||||
<?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
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @package AnimeListClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
* @copyright 2015 - 2016 Timothy J. Warren
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @version 3.1
|
||||
* @version 4.0
|
||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||
*/
|
||||
|
||||
|
@ -1,16 +1,16 @@
|
||||
<?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
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @package AnimeListClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
* @copyright 2015 - 2016 Timothy J. Warren
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @version 3.1
|
||||
* @version 4.0
|
||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||
*/
|
||||
|
||||
|
@ -1,23 +1,23 @@
|
||||
<?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
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @package AnimeListClient
|
||||
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||
* @copyright 2015 - 2016 Timothy J. Warren
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @version 3.1
|
||||
* @version 4.0
|
||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||
*/
|
||||
|
||||
namespace Aviat\AnimeClient\Model;
|
||||
|
||||
use Aviat\AnimeClient\Hummingbird\Enum\MangaReadingStatus;
|
||||
use Aviat\AnimeClient\Hummingbird\Transformer;
|
||||
use Aviat\AnimeClient\API\Kitsu\Enum\MangaReadingStatus;
|
||||
use Aviat\AnimeClient\API\Kitsu\Transformer;
|
||||
use Aviat\Ion\Json;
|
||||
use GuzzleHttp\Cookie\SetCookie;
|
||||
use RuntimeException;
|
||||
|
@ -18,14 +18,15 @@ namespace Aviat\AnimeClient;
|
||||
|
||||
use abeautifulsite\SimpleImage;
|
||||
use Aviat\Ion\ConfigInterface;
|
||||
use Aviat\Ion\Di\ContainerInterface;
|
||||
use Aviat\Ion\Di\{ContainerAware, ContainerInterface};
|
||||
use DomainException;
|
||||
|
||||
/**
|
||||
* Utility method class
|
||||
*/
|
||||
class Util {
|
||||
|
||||
use \Aviat\Ion\Di\ContainerAware;
|
||||
use ContainerAware;
|
||||
|
||||
/**
|
||||
* Routes that don't require a second navigation level
|
||||
@ -164,7 +165,7 @@ class Util {
|
||||
}
|
||||
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
|
||||
|
@ -137,7 +137,7 @@ class DispatcherTest extends AnimeClient_TestCase {
|
||||
|
||||
// Check route setup
|
||||
$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
|
||||
$this->assertEquals($uri, $request->getServerParams()['REQUEST_URI']);
|
||||
@ -145,10 +145,10 @@ class DispatcherTest extends AnimeClient_TestCase {
|
||||
|
||||
// Make sure the route is an anime type
|
||||
//$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
|
||||
$route = $this->router->get_route();
|
||||
$route = $this->router->getRoute();
|
||||
$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)
|
||||
{
|
||||
$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