Ver código fonte

[FrameworkBundle] Tweak to how the routing parameters are output

The json_encode is actually really nice, except that it results in the "escaped" namesapces (e.g. Symfony\\Component\\...).
Ryan Weaver 14 anos atrás
pai
commit
3e41bef1e8

+ 11 - 1
src/Symfony/Bundle/FrameworkBundle/RequestListener.php

@@ -91,7 +91,7 @@ class RequestListener
             $parameters = $this->router->match($request->getPathInfo());
 
             if (null !== $this->logger) {
-                $this->logger->info(sprintf('Matched route "%s" (parameters: %s)', $parameters['_route'], json_encode($parameters)));
+                $this->logger->info(sprintf('Matched route "%s" (parameters: %s)', $parameters['_route'], $this->parametersToString($parameters)));
             }
 
             $request->attributes->add($parameters);
@@ -113,4 +113,14 @@ class RequestListener
             throw new MethodNotAllowedHttpException($e->getAllowedMethods(), $message, $e);
         }
     }
+
+    private function parametersToString(array $parameters)
+    {
+        $pieces = array();
+        foreach ($parameters as $key => $val) {
+            $pieces[] = sprintf('"%s": "%s"', $key, (is_string($val) ? $val : json_encode($val)));
+        }
+
+        return implode(', ', $pieces);
+    }
 }