From 38b7687c373bbd553018e75c08113cfe52bb1d89 Mon Sep 17 00:00:00 2001 From: Florian Krauthan Date: Wed, 25 May 2016 10:20:39 -0700 Subject: [PATCH] Added a extra check to prevent assetic:dump from working Fixes #23 --- Assetic/Filter/CssURLRewriteFilter.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Assetic/Filter/CssURLRewriteFilter.php b/Assetic/Filter/CssURLRewriteFilter.php index 0a1eb76..7ea6f74 100644 --- a/Assetic/Filter/CssURLRewriteFilter.php +++ b/Assetic/Filter/CssURLRewriteFilter.php @@ -90,7 +90,7 @@ private function getSubstringAfterNString($string, $searchString, $afterN) { $i=0; $pos = -1; - while (($pos=strpos($string, $searchString, $pos+1)) !== false) { + while (($pos = strpos($string, $searchString, $pos + 1)) !== false) { $i++; if ($i==$afterN) { @@ -104,10 +104,10 @@ private function getSubstringAfterNString($string, $searchString, $afterN) private function calculateSwitchPath() { $targetPath = dirname($this->asset->getTargetPath()); - $numDirs = substr_count($targetPath, '/')+1; + $numDirs = substr_count($targetPath, '/') + 1; $output = ''; - for ($i=0; $i<$numDirs; $i++) { + for ($i=0; $i < $numDirs; $i++) { $output .= '../'; } @@ -121,7 +121,7 @@ private function calculateSwitchPath() $request = $this->kernel->getContainer()->get('request'); } - if (substr($request->getBaseUrl(), -4) != '.php') { + if ($request && substr($request->getBaseUrl(), -4) != '.php') { $output = substr($output, 3); } } catch (InactiveScopeException $e) {