diff --git a/app/config/app.php b/app/config/app.php index ae52e4f..7792ac8 100644 --- a/app/config/app.php +++ b/app/config/app.php @@ -3,6 +3,28 @@ use App\Support\Helpers; return [ + /** + * Enable dark mode? + * + * Default value: false + */ + 'dark_mode' => Helpers::env('DARK_MODE'), + + /** + * Parse and render README files on the page. + * + * Default value: true + */ + 'display_readmes' => Helpers::env('DISPLAY_READMES'), + + /** + * Your Google analytics tracking ID. + * Expected format: 'UA-123456789-0'. + * + * Default value: false + */ + 'google_analytics_id' => Helpers::env('GOOGLE_ANALYTICS_ID'), + /** * Sorting order of files and folders. * @@ -44,11 +66,12 @@ return [ 'hide_vcs_files' => Helpers::env('HIDE_VSC_FILES'), /** - * Parse and render README files on the page. + * Default date format. For additional info on date formatting see: + * https://www.php.net/manual/en/function.date.php. * - * Default value: true + * Default value: 'Y-m-d H:i:s' */ - 'display_readmes' => Helpers::env('DISPLAY_READMES'), + 'date_format' => Helpers::env('DATE_FORMAT'), /** * The maximum file size (in bytes) that can be hashed. This helps to @@ -57,4 +80,12 @@ return [ * Default value: 1000000000 */ 'max_hash_size' => Helpers::env('MAX_HASH_SIZE'), + + /** + * Path to the view cache directory. + * Set to 'false' to disable view caching entirely. + * + * Default value: 'app/cache/views' + */ + 'view_cache' => Helpers::env('VIEW_CACHE'), ]; diff --git a/app/config/view.php b/app/config/view.php deleted file mode 100644 index 110d5f8..0000000 --- a/app/config/view.php +++ /dev/null @@ -1,36 +0,0 @@ - Helpers::env('DARK_MODE'), - - /** - * Your Google analytics tracking ID. - * Expected format: 'UA-123456789-0'. - * - * Default value: false - */ - 'google_analytics_id' => Helpers::env('GOOGLE_ANALYTICS_ID'), - - /** - * Default date format. For additional info on date formatting see: - * https://www.php.net/manual/en/function.date.php. - * - * Default value: 'Y-m-d H:i:s' - */ - 'date_format' => Helpers::env('DATE_FORMAT'), - - /** - * Path to the view cache directory. - * Set to 'false' to disable view caching entirely. - * - * Default value: 'app/cache/views' - */ - 'cache' => Helpers::env('VIEW_CACHE'), -]; diff --git a/app/src/Providers/TwigProvider.php b/app/src/Providers/TwigProvider.php index ca38d5b..d9586a9 100644 --- a/app/src/Providers/TwigProvider.php +++ b/app/src/Providers/TwigProvider.php @@ -52,11 +52,11 @@ class TwigProvider $twig = new Twig(new FilesystemLoader('app/views')); $twig->getEnvironment()->setCache( - $this->config->get('view.cache', 'app/cache/views') + $this->config->get('app.view_cache', 'app/cache/views') ); $twig->getEnvironment()->getExtension(CoreExtension::class)->setDateFormat( - $this->config->get('view.date_format', 'Y-m-d H:i:s'), '%d days' + $this->config->get('app.date_format', 'Y-m-d H:i:s'), '%d days' ); foreach (self::VIEW_FUNCTIONS as $function) { diff --git a/app/src/ViewFunctions/Config.php b/app/src/ViewFunctions/Config.php index a8b0b4b..bdecf9b 100644 --- a/app/src/ViewFunctions/Config.php +++ b/app/src/ViewFunctions/Config.php @@ -17,8 +17,6 @@ class Config extends ViewFunction */ public function __invoke(string $key, $default = null) { - $viewConfig = $this->config->split('view'); - - return $viewConfig->get($key, $default); + return $this->config->split('app')->get($key, $default); } } diff --git a/tests/Providers/ConfigProviderTest.php b/tests/Providers/ConfigProviderTest.php index 02db312..9093fc8 100644 --- a/tests/Providers/ConfigProviderTest.php +++ b/tests/Providers/ConfigProviderTest.php @@ -17,6 +17,5 @@ class ConfigProviderTest extends TestCase $this->assertInstanceOf(Config::class, $config); $this->assertTrue($config->has('app')); $this->assertTrue($config->has('icons')); - $this->assertTrue($config->has('view')); } } diff --git a/tests/TestCase.php b/tests/TestCase.php index ea87950..1a0fc6e 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -35,10 +35,8 @@ class TestCase extends PHPUnitTestCase 'hide_vcs_files' => false, 'display_readmes' => true, 'max_hash_size' => 1000000000, - ], - 'view' => [ - 'cache' => false - ], + 'view_cache' => false, + ] ]); $this->container = new Container(); diff --git a/tests/ViewFunctions/ConfigTest.php b/tests/ViewFunctions/ConfigTest.php index eae8981..792dc24 100644 --- a/tests/ViewFunctions/ConfigTest.php +++ b/tests/ViewFunctions/ConfigTest.php @@ -18,7 +18,7 @@ class ConfigTest extends TestCase $this->config = new AppConfig([ 'foo' => false, 'bar' => 'Red herring', - 'view' => [ + 'app' => [ 'foo' => 'Test value; please ignore' ], ]);