Check config object shape on page load

This commit is contained in:
Timothy Warren 2018-08-24 14:37:53 -04:00
parent a71fb185bd
commit 0624c3be67

View File

@ -16,6 +16,8 @@
namespace Aviat\AnimeClient; namespace Aviat\AnimeClient;
use Aviat\AnimeClient\Types\Config as ConfigType;
use function Aviat\Ion\_dir; use function Aviat\Ion\_dir;
// Work around the silly timezone error // Work around the silly timezone error
@ -43,19 +45,17 @@ $CONF_DIR = _dir($APP_DIR, 'config');
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Dependency Injection setup // Dependency Injection setup
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
$base_config = require $APPCONF_DIR . '/base_config.php'; $baseConfig = require $APPCONF_DIR . '/base_config.php';
$di = require $APP_DIR . '/bootstrap.php'; $di = require $APP_DIR . '/bootstrap.php';
$config = loadToml($CONF_DIR); $config = loadToml($CONF_DIR);
$config_array = array_merge($base_config, $config); $configArray = array_merge($baseConfig, $config);
// User config
$config_array['default_config'] = $base_config;
$config_array['user_config_settings'] = $config;
$container = $di($config_array); $checkedConfig = (new ConfigType($configArray))->toArray();
$container = $di($checkedConfig);
// Unset 'constants' // Unset 'constants'
unset($APP_DIR, $APPCONF_DIR); unset($APP_DIR, $CONF_DIR, $APPCONF_DIR);
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Dispatch to the current route // Dispatch to the current route