mirror of
https://github.com/DirectoryLister/DirectoryLister.git
synced 2025-08-29 08:40:42 +02:00
Unified app and view config into a single file
This commit is contained in:
@@ -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'),
|
||||
];
|
||||
|
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Support\Helpers;
|
||||
|
||||
return [
|
||||
/**
|
||||
* Enable dark mode?
|
||||
*
|
||||
* Default value: false
|
||||
*/
|
||||
'dark_mode' => 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'),
|
||||
];
|
@@ -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) {
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -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'));
|
||||
}
|
||||
}
|
||||
|
@@ -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();
|
||||
|
@@ -18,7 +18,7 @@ class ConfigTest extends TestCase
|
||||
$this->config = new AppConfig([
|
||||
'foo' => false,
|
||||
'bar' => 'Red herring',
|
||||
'view' => [
|
||||
'app' => [
|
||||
'foo' => 'Test value; please ignore'
|
||||
],
|
||||
]);
|
||||
|
Reference in New Issue
Block a user