Fix cache clear command

This commit is contained in:
Timothy Warren 2017-01-19 12:49:18 -05:00
parent 94bfdebf46
commit 5f6c1f9f48
3 changed files with 23 additions and 15 deletions

View File

@ -58,10 +58,9 @@ return function(array $config_array = []) {
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// Create Config Object // Create Config Object
$container->set('config', function() { $container->set('config', function() use ($config_array) {
return new Config(); return new Config($config_array);
}); });
$container->setInstance('config', new Config($config_array));
// Create Cache Object // Create Cache Object
$container->set('cache', function($container) { $container->set('cache', function($container) {

View File

@ -17,15 +17,19 @@
namespace Aviat\AnimeClient\Command; namespace Aviat\AnimeClient\Command;
use Aura\Session\SessionFactory; use Aura\Session\SessionFactory;
use Aviat\AnimeClient\AnimeClient; use Aviat\AnimeClient\{
AnimeClient,
Model,
Util
};
use Aviat\AnimeClient\Auth\HummingbirdAuth; use Aviat\AnimeClient\Auth\HummingbirdAuth;
use Aviat\AnimeClient\Model; use Aviat\Banker\Pool;
use Aviat\AnimeClient\Util;
use Aviat\Ion\Cache\CacheManager;
use Aviat\Ion\Config; use Aviat\Ion\Config;
use Aviat\Ion\Di\Container; use Aviat\Ion\Di\Container;
use ConsoleKit\Command; use ConsoleKit\Command;
use ConsoleKit\Widgets\Box; use ConsoleKit\Widgets\Box;
use Monolog\Handler\RotatingFileHandler;
use Monolog\Logger;
/** /**
* Base class for console command setup * Base class for console command setup
@ -54,24 +58,30 @@ class BaseCommand extends Command {
*/ */
protected function setupContainer() protected function setupContainer()
{ {
$CONF_DIR = realpath(__DIR__ . '/../../app/config/'); $APP_DIR = realpath(__DIR__ . '/../../app');
$CONF_DIR = realpath("{$APP_DIR}/config/");
require_once $CONF_DIR . '/base_config.php'; // $base_config require_once $CONF_DIR . '/base_config.php'; // $base_config
$config = AnimeClient::loadToml($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) use ($APP_DIR) {
$container = new Container(); $container = new Container();
$app_logger = new Logger('animeclient');
$app_logger->pushHandler(new RotatingFileHandler("{$APP_DIR}/logs/app.log", Logger::NOTICE));
$container->setLogger($app_logger, 'default');
// Create Config Object // Create Config Object
$container->set('config', function() { $container->set('config', function() use ($config_array) {
return new Config(); return new Config($config_array);
}); });
$container->setInstance('config', $config_array);
// Create Cache Object // Create Cache Object
$container->set('cache', function($container) { $container->set('cache', function($container) {
return new CacheManager($container->get('config')); $logger = $container->getLogger();
$config = $container->get('config')->get('cache');
return new Pool($config, $logger);
}); });
// Create session Object // Create session Object

View File

@ -37,4 +37,3 @@ class ClearCache extends BaseCommand {
$this->echoBox('API Cache has been cleared.'); $this->echoBox('API Cache has been cleared.');
} }
} }
// End of ClearCache.php