Skip to content

Commit

Permalink
Changed exception behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
mnapoli committed Sep 16, 2014
1 parent 9ff7523 commit 5171ab7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
9 changes: 4 additions & 5 deletions src/PiwikTwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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 = <<<HTML
Expand Down
1 change: 0 additions & 1 deletion tests/DisabledExtensionFixture/EmptyFunctionCall.test
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ Calling "piwik" function without parameters when the extension is disabled
--DATA--
return array();
--EXPECT--
Twig_Error: Twig_Error_Runtime: An exception has been thrown during the rendering of a template ("No Piwik host was configured or given to generate the tracker code") in "index.twig" at line 2 in "EmptyFunctionCall.test".

0 comments on commit 5171ab7

Please sign in to comment.