Version 5.1 - All the GraphQL #32

Closed
timw4mail wants to merge 1160 commits from develop into master
9 changed files with 37 additions and 26 deletions
Showing only changes of commit 816a309f18 - Show all commits

View File

@ -38,7 +38,7 @@ A self-hosted client that allows custom formatting of data from the hummingbird
### Installation
1. Install dependencies via composer: `composer install`
1. Install via composer: `composer create-project timw4mail/hummingbird-anime-client`
2. Configure settings in `app/config/config.php` to your liking
3. Create the following directories if they don't exist, and make sure they are world writable
* app/cache
@ -51,7 +51,7 @@ A self-hosted client that allows custom formatting of data from the hummingbird
* For importing anime:
1. Login
2. Use the form to select your media
3. Save & Repeat as needed
3. Save & Repeat as needed
* For bulk importing anime:
1. Find the anime you are looking for on the hummingbird search api page: `https://hummingbird.me/api/v1/search/anime?query=`
2. Create an `import.json` file in the root of the app, with an array of objects from the search page that you want to import

View File

@ -29,8 +29,7 @@ return function(array $config_array = []) {
$app_logger = new Logger('animeclient');
$app_logger->pushHandler(new RotatingFileHandler(__DIR__ . '/logs/app.log', Logger::NOTICE));
$app_logger->pushHandler(new BrowserConsoleHandler(Logger::DEBUG));
$container->setLogger($app_logger);
$container->setLogger($app_logger, 'default');
// -------------------------------------------------------------------------
// Injected Objects

View File

@ -7,16 +7,15 @@
"aura/html": "2.*",
"aura/router": "2.2.*",
"aura/session": "2.*",
"aura/web": "2.0.*",
"aura/web": "2.*",
"aviat4ion/query": "2.5.*",
"container-interop/container-interop": "1.*",
"danielstjules/stringy": "~2.1",
"filp/whoops": "1.1.*",
"guzzlehttp/guzzle": "6.*",
"monolog/monolog": "1.*",
"mustache/mustache": "*",
"psr/log": "~1.0",
"robmorgan/phinx": "0.4.*",
"szymach/c-pchart": "1.*"
"yosymfony/toml": "0.3.*"
}
}

View File

@ -86,7 +86,6 @@ unset($SRC_DIR);
unset($CONF_DIR);
$container = $di($config_array);
$container->set('error-handler', $defaultHandler);
// -----------------------------------------------------------------------------
// Dispatch to the current route

View File

@ -197,8 +197,6 @@ class Controller {
*/
protected function load_partial($view, $template, array $data = [])
{
$errorHandler = $this->container->get('error-handler');
$errorHandler->addDataTable('Template Data', $data);
$router = $this->container->get('dispatcher');
if (isset($this->base_data))

View File

@ -62,14 +62,15 @@ class Dispatcher extends RoutingBase {
*/
public function get_route()
{
$error_handler = $this->container->get('error-handler');
$logger = $this->container->getLogger('default');
$raw_route = $this->request->url->get(PHP_URL_PATH);
$route_path = "/" . trim($raw_route, '/');
$error_handler->addDataTable('Route Info', [
$logger->addDebug('Dispatcher - Routing data from get_route method');
$logger->addDebug(print_r([
'route_path' => $route_path
]);
], TRUE));
return $this->router->match($route_path, $_SERVER);
}
@ -93,12 +94,14 @@ class Dispatcher extends RoutingBase {
*/
public function __invoke($route = NULL)
{
$error_handler = $this->container->get('error-handler');
$logger = $this->container->getLogger('default');
if (is_null($route))
{
$route = $this->get_route();
$error_handler->addDataTable('route_args', (array)$route);
$logger->addDebug('Dispatcher - Route invoke arguments');
$logger->addDebug(print_r($route, TRUE));
}
if($route)
@ -233,12 +236,13 @@ class Dispatcher extends RoutingBase {
*/
protected function call($controller_name, $method, array $params)
{
$error_handler = $this->container->get('error-handler');
$logger = $this->container->getLogger('default');
$controller = new $controller_name($this->container);
// Run the appropriate controller method
$error_handler->addDataTable('controller_args', $params);
$logger->addDebug('Dispatcher - controller arguments');
$logger->addDebug(print_r($params, TRUE));
call_user_func_array([$controller, $method], $params);
}
@ -250,9 +254,12 @@ class Dispatcher extends RoutingBase {
*/
protected function get_error_params()
{
$logger = $this->container->getLogger('default');
$failure = $this->router->getFailedRoute();
$error_handler = $this->container->get('error-handler');
$error_handler->addDataTable('failed_route', (array)$failure);
$logger->info('Dispatcher - failed route');
$logger->info(print_r($failure, TRUE));
$action_method = AnimeClient::ERROR_MESSAGE_METHOD;
$params = [];

View File

@ -149,7 +149,7 @@ class Anime extends API {
*/
public function search($name)
{
$errorHandler = $this->container->get('error-handler');
$logger = $this->container->getLogger('default');
$config = [
'query' => [
@ -158,10 +158,12 @@ class Anime extends API {
];
$response = $this->get('search/anime', $config);
$errorHandler->addDataTable('anime_search_response', (array)$response);
if ($response->getStatusCode() != 200)
{
$logger->addWarning("Non 200 response for search api call");
$logger->addWarning($response->getBody());
throw new RuntimeException($response->getEffectiveUrl());
}

View File

@ -1,11 +1,15 @@
<?php
use Aura\Web\WebFactory;
use Aura\Router\RouterFactory;
use Monolog\Logger;
use Monolog\Handler\TestHandler;
use Aviat\Ion\Di\Container;
use Aviat\AnimeClient\Dispatcher;
use Aviat\AnimeClient\Config;
use Aviat\AnimeClient\UrlGenerator;
use Aura\Web\WebFactory;
use Aura\Router\RouterFactory;
class DispatcherTest extends AnimeClient_TestCase {
@ -35,15 +39,19 @@ class DispatcherTest extends AnimeClient_TestCase {
$old_config = $this->container->get('config');
$logger = new Logger('test_logger');
$logger->pushHandler(new TestHandler(Logger::DEBUG));
// Add the appropriate objects to the container
$this->container = new Container([
'config' => $old_config,
'request' => $web_factory->newRequest(),
'response' => $web_factory->newResponse(),
'aura-router' => $router_factory->newInstance(),
'error-handler' => new MockErrorHandler()
'aura-router' => $router_factory->newInstance()
]);
$this->container->setLogger($logger, 'default');
if ( ! empty($config))
{
$config = new Config($config);

View File

@ -75,7 +75,6 @@ class AnimeClient_TestCase extends PHPUnit_Framework_TestCase {
// Set up DI container
$di = require _dir($APP_DIR, 'bootstrap.php');
$container = $di($config_array);
$container->set('error-handler', new MockErrorHandler());
$container->set('session-handler', self::$session_handler);
$this->container = $container;