From a931d10fa1bb75d4bd4bd376d5c3fdeedcb9eb23 Mon Sep 17 00:00:00 2001 From: Chris Kankiewicz Date: Thu, 1 Dec 2022 08:16:26 -0700 Subject: [PATCH] Import DI functions --- app/config/app.php | 42 +++++++++++++++++++++------------------- app/config/cache.php | 20 ++++++++++--------- app/config/container.php | 27 ++++++++++++++------------ 3 files changed, 48 insertions(+), 41 deletions(-) diff --git a/app/config/app.php b/app/config/app.php index d11d4b6..23485a9 100644 --- a/app/config/app.php +++ b/app/config/app.php @@ -1,5 +1,7 @@ DI\env('APP_DEBUG', false), + 'debug' => env('APP_DEBUG', false), /** * The application interface language. @@ -19,7 +21,7 @@ return [ * * Defualt value: 'en' */ - 'language' => DI\env('APP_LANGUAGE', 'en'), + 'language' => env('APP_LANGUAGE', 'en'), /** * The title of your directory listing. This will be displayed in the @@ -27,14 +29,14 @@ return [ * * Default value: 'Directory Lister' */ - 'site_title' => DI\env('SITE_TITLE', 'Directory Lister'), + 'site_title' => env('SITE_TITLE', 'Directory Lister'), /** * Meta tag description text. * * Default value: 'Yet another directory listing, powered by Directory Lister.'. */ - 'meta_description' => DI\env('META_DESCRIPTION', 'Yet another directory listing, powered by Directory Lister.'), + 'meta_description' => env('META_DESCRIPTION', 'Yet another directory listing, powered by Directory Lister.'), /** * Text of the 'home' link in the navigation breadcrumbs. If undefined or @@ -42,28 +44,28 @@ return [ * * Default value: null */ - 'home_text' => DI\env('HOME_TEXT', null), + 'home_text' => env('HOME_TEXT', null), /** * Parse and render README files on the page. * * Default value: true */ - 'display_readmes' => DI\env('DISPLAY_READMES', true), + 'display_readmes' => env('DISPLAY_READMES', true), /** * Show READMEs before the file listing. * * Default value: false */ - 'readmes_first' => DI\env('READMES_FIRST', false), + 'readmes_first' => env('READMES_FIRST', false), /** * Enable downloading of directories as a zip archive. * * Default value: true */ - 'zip_downloads' => DI\env('ZIP_DOWNLOADS', true), + 'zip_downloads' => env('ZIP_DOWNLOADS', true), /** * Your Google analytics tracking ID. @@ -71,21 +73,21 @@ return [ * Expected format: 'UA-123456789-0' * Default value: false */ - 'google_analytics_id' => DI\env('GOOGLE_ANALYTICS_ID', false), + 'google_analytics_id' => env('GOOGLE_ANALYTICS_ID', false), /** * Your Matomo analytics URL. * * Default value: false */ - 'matomo_analytics_url' => DI\env('MATOMO_ANALYTICS_URL', false), + 'matomo_analytics_url' => env('MATOMO_ANALYTICS_URL', false), /** * Your Matomo analytics site ID. * * Default value: false */ - 'matomo_analytics_site_id' => DI\env('MATOMO_ANALYTICS_SITE_ID', false), + 'matomo_analytics_site_id' => env('MATOMO_ANALYTICS_SITE_ID', false), /** * Sorting order of files and folders. @@ -93,14 +95,14 @@ return [ * Possible values: type, natural, name, accessed, changed, modified * Default value: 'type' */ - 'sort_order' => DI\env('SORT_ORDER', 'type'), + 'sort_order' => env('SORT_ORDER', 'type'), /** * When enabled, reverses the order of files (after sorting is applied). * * Default value: false */ - 'reverse_sort' => DI\env('REVERSE_SORT', false), + 'reverse_sort' => env('REVERSE_SORT', false), /** * File containing hidden file definitions. Will be merged with definitions @@ -108,7 +110,7 @@ return [ * * Default value: '.hidden' */ - 'hidden_files_list' => DI\env('HIDDEN_FILES_LIST', '.hidden'), + 'hidden_files_list' => env('HIDDEN_FILES_LIST', '.hidden'), /** * Array of hidden file definitions. Will be merged with definitions in the @@ -126,14 +128,14 @@ return [ * * Default value: true */ - 'hide_app_files' => DI\env('HIDE_APP_FILES', true), + 'hide_app_files' => env('HIDE_APP_FILES', true), /** * Whether or not to hide dot files/directories from the listing. * * Default value: true */ - 'hide_dot_files' => DI\env('HIDE_DOT_FILES', true), + 'hide_dot_files' => env('HIDE_DOT_FILES', true), /** * Hide the files Version Control System (i.e. Git and Mercurial) use to @@ -141,7 +143,7 @@ return [ * * Default value: true */ - 'hide_vcs_files' => DI\env('HIDE_VSC_FILES', true), + 'hide_vcs_files' => env('HIDE_VSC_FILES', true), /** * Default date format. For additional info on date formatting see: @@ -149,7 +151,7 @@ return [ * * Default value: 'Y-m-d H:i:s' */ - 'date_format' => DI\env('DATE_FORMAT', 'Y-m-d H:i:s'), + 'date_format' => env('DATE_FORMAT', 'Y-m-d H:i:s'), /** * Timezone used for date formatting. For a list of supported timezones see: @@ -157,7 +159,7 @@ return [ * * Default value: The server's timezone */ - 'timezone' => DI\env('TIMEZONE', date_default_timezone_get()), + 'timezone' => env('TIMEZONE', date_default_timezone_get()), /** * The maximum file size (in bytes) that can be hashed. This helps to @@ -165,5 +167,5 @@ return [ * * Default value: 1000000000 */ - 'max_hash_size' => DI\env('MAX_HASH_SIZE', 1000000000), + 'max_hash_size' => env('MAX_HASH_SIZE', 1000000000), ]; diff --git a/app/config/cache.php b/app/config/cache.php index af4813a..d88faad 100644 --- a/app/config/cache.php +++ b/app/config/cache.php @@ -1,6 +1,8 @@ DI\env('CACHE_DRIVER', 'file'), + 'cache_driver' => env('CACHE_DRIVER', 'file'), /** * The app cache lifetime (in seconds). If set to 0, cache indefinitely. * * Default value: 3600 (one hour) */ - 'cache_lifetime' => DI\env('CACHE_LIFETIME', 3600), + 'cache_lifetime' => env('CACHE_LIFETIME', 3600), /** * Some cache drivers require manually pruning the cache periodically to @@ -28,7 +30,7 @@ return [ * * Default value: 2 */ - 'cache_lottery' => DI\env('CACHE_LOTTERY', 2), + 'cache_lottery' => env('CACHE_LOTTERY', 2), /** * Path to the view cache directory. Set to 'false' to disable @@ -37,21 +39,21 @@ return [ * * Default value: 'app/cache/views' */ - 'view_cache' => DI\env('VIEW_CACHE', 'app/cache/views'), + 'view_cache' => env('VIEW_CACHE', 'app/cache/views'), /** * The Memcached server hostname or IP address. * * Default value: 'localhost' */ - 'memcached_host' => DI\env('MEMCACHED_HOST', 'localhost'), + 'memcached_host' => env('MEMCACHED_HOST', 'localhost'), /** * The Memcached server port. * * Default value: 11211 */ - 'memcached_port' => DI\env('MEMCACHED_PORT', 11211), + 'memcached_port' => env('MEMCACHED_PORT', 11211), /** * The Memcached configuration closure. This option is used when the @@ -66,7 +68,7 @@ return [ * * Default value: Connects to a server at localhost:11211 */ - 'memcached_config' => DI\value(function (Memcached $memcached, Config $config): void { + 'memcached_config' => value(function (Memcached $memcached, Config $config): void { $memcached->addServer( $config->get('memcached_host'), $config->get('memcached_port') @@ -78,14 +80,14 @@ return [ * * Default value: 'localhost' */ - 'redis_host' => DI\env('REDIS_HOST', 'localhost'), + 'redis_host' => env('REDIS_HOST', 'localhost'), /** * The Redis server port. * * Default value: 6379 */ - 'redis_port' => DI\env('REDIS_PORT', 6379), + 'redis_port' => env('REDIS_PORT', 6379), /** * The Redis configuration closure. This option is used when the diff --git a/app/config/container.php b/app/config/container.php index ab60874..0fe26ac 100644 --- a/app/config/container.php +++ b/app/config/container.php @@ -4,17 +4,20 @@ use App\Factories; use App\Middlewares; use App\SortMethods; use App\ViewFunctions; +use function DI\create; +use function DI\factory; +use function DI\string; return [ /** Path definitions */ 'base_path' => dirname(__DIR__, 2), 'app_path' => dirname(__DIR__), - 'asset_path' => DI\string('{app_path}/assets'), - 'cache_path' => DI\string('{app_path}/cache'), - 'config_path' => DI\string('{app_path}/config'), - 'source_path' => DI\string('{app_path}/src'), - 'translations_path' => DI\string('{app_path}/translations'), - 'views_path' => DI\string('{app_path}/views'), + 'asset_path' => string('{app_path}/assets'), + 'cache_path' => string('{app_path}/cache'), + 'config_path' => string('{app_path}/config'), + 'source_path' => string('{app_path}/src'), + 'translations_path' => string('{app_path}/translations'), + 'views_path' => string('{app_path}/views'), /** Array of application files (to be hidden) */ 'app_files' => ['app', 'index.php', '.env', '.env.example', '.hidden'], @@ -56,10 +59,10 @@ return [ ], /** Container definitions */ - App\HiddenFiles::class => DI\factory([App\HiddenFiles::class, 'fromConfig']), - Symfony\Component\Finder\Finder::class => DI\factory(Factories\FinderFactory::class), - Symfony\Contracts\Cache\CacheInterface::class => DI\factory(Factories\CacheFactory::class), - Symfony\Contracts\Translation\TranslatorInterface::class => DI\factory(Factories\TranslationFactory::class), - Slim\Views\Twig::class => DI\factory(Factories\TwigFactory::class), - Whoops\RunInterface::class => DI\create(Whoops\Run::class), + App\HiddenFiles::class => factory([App\HiddenFiles::class, 'fromConfig']), + Symfony\Component\Finder\Finder::class => factory(Factories\FinderFactory::class), + Symfony\Contracts\Cache\CacheInterface::class => factory(Factories\CacheFactory::class), + Symfony\Contracts\Translation\TranslatorInterface::class => factory(Factories\TranslationFactory::class), + Slim\Views\Twig::class => factory(Factories\TwigFactory::class), + Whoops\RunInterface::class => create(Whoops\Run::class), ];