From a4515d9c68206d2ec1119fbc39b7e77e944d4a66 Mon Sep 17 00:00:00 2001 From: chadyred Date: Mon, 25 Apr 2016 15:47:20 +0200 Subject: [PATCH] Compatibility handle with Symfony 2 and 3 Compatibility handle with Symfony 2 and 3 --- Assetic/Filter/CssURLRewriteFilter.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Assetic/Filter/CssURLRewriteFilter.php b/Assetic/Filter/CssURLRewriteFilter.php index 0a8725e..d7bb475 100644 --- a/Assetic/Filter/CssURLRewriteFilter.php +++ b/Assetic/Filter/CssURLRewriteFilter.php @@ -113,7 +113,18 @@ private function calculateSwitchPath() if (substr($targetPath, 0, 11) == '_controller') { try { - $request = $this->kernel->getContainer()->get('request'); + $request = null; + + if ($this->container->has('request_stack')) { + + $request = $this->kernel->getContainer()->get('request_stack')->getCurrentRequest(); + + } elseif (method_exists($this->container, 'isScopeActive') && $this->container->isScopeActive('request')) { + + $request = $this->kernel->getContainer()->get('request'); + + } + if (substr($request->getBaseUrl(), -4) != '.php') { $output = substr($output, 3); }