From 5d3eb78deaeddad127f7532c4504e917d2fc6d62 Mon Sep 17 00:00:00 2001 From: Chris Kankiewicz Date: Thu, 5 Dec 2019 20:58:28 -0700 Subject: [PATCH] Extracted theme path to a property --- app/Bootstrap/ViewComposer.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Bootstrap/ViewComposer.php b/app/Bootstrap/ViewComposer.php index cb4b70c..4a0d0aa 100644 --- a/app/Bootstrap/ViewComposer.php +++ b/app/Bootstrap/ViewComposer.php @@ -15,6 +15,9 @@ class ViewComposer /** @var Twig Twig instance */ protected $twig; + /** @var string Path to theme */ + protected $themePath; + /** * Create a new ViewComposer object. * @@ -24,6 +27,7 @@ class ViewComposer { $this->config = $config; $this->twig = $twig; + $this->themePath = $twig->getLoader()->getPaths()[0]; } /** @@ -54,7 +58,7 @@ class ViewComposer { $this->twig->getEnvironment()->addFunction( new TwigFunction('asset', function (string $path) { - return "/app/themes/{$this->config->get('theme', 'defualt')}/{$path}"; + return "/{$this->themePath}/{$path}"; }) ); @@ -75,7 +79,7 @@ class ViewComposer */ public function registerThemeFunctions(): void { - $themeConfigPath = "{$this->twig->getLoader()->getPaths()[0]}/config.php"; + $themeConfigPath = "{$this->themePath}/config.php"; if (file_exists($themeConfigPath)) { $themeConfig = include $themeConfigPath;