Set default values for values retrieved from the config

This commit is contained in:
Chris Kankiewicz
2019-11-09 00:28:17 -07:00
parent 1e2cc71bd5
commit fc92d5d302
2 changed files with 3 additions and 3 deletions

View File

@@ -17,12 +17,12 @@ class ViewComposer
public function __invoke(Config $config, Twig $twig): void
{
$twig->getEnvironment()->getExtension(CoreExtension::class)->setDateFormat(
$config->get('date_format'), '%d days'
$config->get('date_format', 'Y-m-d H:i:s'), '%d days'
);
$twig->getEnvironment()->addFunction(
new TwigFunction('asset', function ($path) use ($config) {
return "/app/themes/{$config->get('theme')}/{$path}";
return "/app/themes/{$config->get('theme', 'defualt')}/{$path}";
})
);

View File

@@ -21,7 +21,7 @@ $container = new Container();
$container->set(Config::class, new Config('app/config'));
$container->set(Twig::class, function (Config $config) {
return new Twig("app/themes/{$config->get('theme')}", [
'cache' => $config->get('view_cache')
'cache' => $config->get('view_cache', 'app/cache/views')
]);
});