From 0fefece3e3b48f15327f2d4529caded51423ff36 Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Fri, 24 Aug 2018 14:37:53 -0400 Subject: [PATCH] Check config object shape on page load --- index.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/index.php b/index.php index c8aa3081..64583ac6 100644 --- a/index.php +++ b/index.php @@ -16,6 +16,8 @@ namespace Aviat\AnimeClient; +use Aviat\AnimeClient\Types\Config as ConfigType; + use function Aviat\Ion\_dir; // Work around the silly timezone error @@ -43,19 +45,17 @@ $CONF_DIR = _dir($APP_DIR, 'config'); // ----------------------------------------------------------------------------- // Dependency Injection setup // ----------------------------------------------------------------------------- -$base_config = require $APPCONF_DIR . '/base_config.php'; +$baseConfig = require $APPCONF_DIR . '/base_config.php'; $di = require $APP_DIR . '/bootstrap.php'; $config = loadToml($CONF_DIR); -$config_array = array_merge($base_config, $config); -// User config -$config_array['default_config'] = $base_config; -$config_array['user_config_settings'] = $config; +$configArray = array_merge($baseConfig, $config); -$container = $di($config_array); +$checkedConfig = (new ConfigType($configArray))->toArray(); +$container = $di($checkedConfig); // Unset 'constants' -unset($APP_DIR, $APPCONF_DIR); +unset($APP_DIR, $CONF_DIR, $APPCONF_DIR); // ----------------------------------------------------------------------------- // Dispatch to the current route