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) {