From 5171ab7221830a9d377add03dd60dbe6bd7b331f Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Tue, 16 Sep 2014 18:51:19 +1200 Subject: [PATCH] Changed exception behavior --- src/PiwikTwigExtension.php | 9 ++++----- tests/DisabledExtensionFixture/EmptyFunctionCall.test | 1 - 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/PiwikTwigExtension.php b/src/PiwikTwigExtension.php index 94d9943..ae91ec0 100644 --- a/src/PiwikTwigExtension.php +++ b/src/PiwikTwigExtension.php @@ -60,6 +60,10 @@ public function getFunctions() */ public function generatePiwikTrackerCode($piwikHost = null, $siteId = null) { + if (! $this->enabled) { + return ''; + } + $piwikHost = $piwikHost ?: $this->piwikHost; $siteId = $siteId ?: $this->siteId; @@ -70,11 +74,6 @@ public function generatePiwikTrackerCode($piwikHost = null, $siteId = null) throw new InvalidArgumentException('No Piwik site ID was configured or given to generate the tracker code'); } - // Check only now so that exceptions are still thrown in dev environment - if (! $this->enabled) { - return ''; - } - $piwikHost = rtrim($piwikHost, '/'); $code = <<