From 3d6906ae5f26eebb36f274d4cb2e1e78c0aeea8f Mon Sep 17 00:00:00 2001 From: Svante Richter Date: Wed, 22 Feb 2017 16:38:41 +0100 Subject: [PATCH] Add twig namespacing Base and Widget are pretty common template names, so add a namespace to make sure nothing clashes. --- src/Action/StatisticsAction.php | 2 +- src/GoogleAnalyticsExtension.php | 6 ++++-- src/Snippet/AnalyticsSnippet.php | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Action/StatisticsAction.php b/src/Action/StatisticsAction.php index 1d75fd8..de17c06 100644 --- a/src/Action/StatisticsAction.php +++ b/src/Action/StatisticsAction.php @@ -61,6 +61,6 @@ public function displayStatistics(Request $request) 'webpath' => $this->webPath, ]; - return $this->view->render("base.twig", $data); + return $this->view->render("@GoogleAnalytics/base.twig", $data); } } \ No newline at end of file diff --git a/src/GoogleAnalyticsExtension.php b/src/GoogleAnalyticsExtension.php index ac633ff..3d98cc7 100644 --- a/src/GoogleAnalyticsExtension.php +++ b/src/GoogleAnalyticsExtension.php @@ -111,7 +111,7 @@ public function widget() ]; // Render the template, and return the results - return $this->renderTemplate('widget.twig', $twigvars); + return $this->renderTemplate('@GoogleAnalytics/widget.twig', $twigvars); } /** @@ -119,6 +119,8 @@ public function widget() */ protected function registerTwigPaths() { - return ['templates']; + return [ + 'templates' => ['namespace' => 'GoogleAnalytics'] + ]; } } diff --git a/src/Snippet/AnalyticsSnippet.php b/src/Snippet/AnalyticsSnippet.php index 7989567..27b5205 100644 --- a/src/Snippet/AnalyticsSnippet.php +++ b/src/Snippet/AnalyticsSnippet.php @@ -48,12 +48,12 @@ public function insertAnalytics() //Check to see if universal is set if ($this->config->isUniversal()) { $data['domainname'] = $this->config->getUniversalDomainname(); - return $this->view->render("universal.twig", $data); + return $this->view->render("@GoogleAnalytics/universal.twig", $data); } //Get full url for the current website $data['domainname'] = $this->request->getCurrentRequest()->server->get('HTTP_HOST'); - return $this->view->render("normal.twig", $data); + return $this->view->render("@GoogleAnalytics/normal.twig", $data); } } \ No newline at end of file