Version 5.1 - All the GraphQL #32

Closed
timw4mail wants to merge 1160 commits from develop into master
9 changed files with 42 additions and 13 deletions
Showing only changes of commit 77709c068a - Show all commits

View File

@ -15,6 +15,7 @@ use Monolog\Handler\BrowserConsoleHandler;
use Aviat\Ion\Di\Container;
use Aviat\AnimeClient\Auth\HummingbirdAuth;
use Aviat\AnimeClient\Model;
// -----------------------------------------------------------------------------
// Setup DI container
@ -68,13 +69,21 @@ return function(array $config_array = []) {
$container->set('session', $session);
$container->set('url-generator', new UrlGenerator($container));
$container->set('auth', new HummingbirdAuth($container));
// Miscellaneous helper methods
$anime_client = new AnimeClient();
$anime_client->setContainer($container);
$container->set('anime_client', $anime_client);
// Models
$container->set('api-model', new Model\API($container));
$container->set('anime-model', new Model\Anime($container));
$container->set('manga-model', new Model\Manga($container));
$container->set('anime-collection-model', new Model\AnimeCollection($container));
$container->set('auth', new HummingbirdAuth($container));
// -------------------------------------------------------------------------
// Dispatcher
// -------------------------------------------------------------------------

View File

@ -47,7 +47,7 @@ class HummingbirdAuth {
$this->setContainer($container);
$this->segment = $container->get('session')
->getSegment(__NAMESPACE__);
$this->model = new API($container);
$this->model = $container->get('api-model');
}
/**

View File

@ -44,7 +44,7 @@ class Anime extends BaseController {
{
parent::__construct($container);
$this->model = new AnimeModel($container);
$this->model = $container->get('anime-model');
$this->base_data = array_merge($this->base_data, [
'menu_name' => 'anime_list',
'message' => '',

View File

@ -53,8 +53,8 @@ class Collection extends BaseController {
parent::__construct($container);
$this->urlGenerator = $container->get('url-generator');
$this->anime_model = new AnimeModel($container);
$this->anime_collection_model = new AnimeCollectionModel($container);
$this->anime_model = $container->get('anime-model');
$this->anime_collection_model = $container->get('anime-collection-model');
$this->base_data = array_merge($this->base_data, [
'menu_name' => 'collection',
'message' => '',

View File

@ -43,7 +43,7 @@ class Manga extends Controller {
{
parent::__construct($container);
$this->model = new MangaModel($container);
$this->model = $container->get('manga-model');
$this->base_data = array_merge($this->base_data, [
'menu_name' => 'manga_list',
'config' => $this->config,

View File

@ -60,6 +60,16 @@ class API extends BaseModel {
public function __construct(ContainerInterface $container)
{
parent::__construct($container);
$this->init();
}
/**
* Set up the class properties
*
* @return void
*/
protected function init()
{
$this->cookieJar = new CookieJar();
$this->client = new Client([
'base_uri' => $this->base_url,

View File

@ -51,7 +51,7 @@ class AnimeCollection extends DB {
$this->valid_database = FALSE;
return FALSE;
}
$this->anime_model = new AnimeModel($container);
$this->anime_model = $container->get('anime-model');
// Is database valid? If not, set a flag so the
// app can be run without a valid database

View File

@ -12,7 +12,6 @@
namespace Aviat\Ion\Di;
use ArrayObject;
use Psr\Log\LoggerInterface;
/**
@ -41,8 +40,8 @@ class Container implements ContainerInterface {
*/
public function __construct(array $values = [])
{
$this->container = new ArrayObject($values);
$this->loggers = new ArrayObject([]);
$this->container = $values;
$this->loggers = [];
}
/**
@ -93,7 +92,7 @@ class Container implements ContainerInterface {
*/
public function has($id)
{
return $this->container->offsetExists($id);
return array_key_exists($id, $this->container);
}
/**
@ -103,7 +102,7 @@ class Container implements ContainerInterface {
*/
public function hasLogger($key = 'default')
{
return $this->loggers->offsetExists($key);
return array_key_exists($key, $this->loggers);
}
/**

View File

@ -36,7 +36,18 @@ class AnimeClient_TestCase extends PHPUnit_Framework_TestCase {
'asset_path' => '//localhost/assets/',
'img_cache_path' => _dir(ROOT_DIR, 'public/images'),
'data_cache_path' => _dir(TEST_DATA_DIR, 'cache'),
'database' => [],
'database' => [
'collection' => [
'type' => 'sqlite',
'host' => '',
'user' => '',
'pass' => '',
'port' => '',
'name' => 'default',
'database' => '',
'file' => ':memory:',
]
],
'routing' => [
'asset_path' => '/assets'
],