diff --git a/src/Symfony/Bundle/FrameworkBundle/DataCollector/RouterDataCollector.php b/src/Symfony/Bundle/FrameworkBundle/DataCollector/RouterDataCollector.php
index 83520715cc..daee8c6967 100644
--- a/src/Symfony/Bundle/FrameworkBundle/DataCollector/RouterDataCollector.php
+++ b/src/Symfony/Bundle/FrameworkBundle/DataCollector/RouterDataCollector.php
@@ -14,6 +14,9 @@ namespace Symfony\Bundle\FrameworkBundle\DataCollector;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
+use Symfony\Bundle\FrameworkBundle\Controller\RedirectController;
+use Symfony\Component\HttpFoundation\RedirectResponse;
+use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
/**
* RouterDataCollector.
@@ -22,11 +25,73 @@ use Symfony\Component\HttpKernel\DataCollector\DataCollector;
*/
class RouterDataCollector extends DataCollector
{
+ protected $controllers;
+
+ public function __construct()
+ {
+ $this->controllers = new \SplObjectStorage();
+
+ $this->data = array(
+ 'redirect' => false,
+ 'url' => null,
+ 'route' => null,
+ );
+ }
+
/**
* {@inheritdoc}
*/
public function collect(Request $request, Response $response, \Exception $exception = null)
{
+ if ($response instanceof RedirectResponse) {
+ $this->data['redirect'] = true;
+ $this->data['url'] = $response->getTargetUrl();
+
+ if ($this->controllers->contains($request)) {
+ $controller = $this->controllers[$request];
+ if (is_array($controller)) {
+ $controller = $controller[0];
+ }
+
+ if ($controller instanceof RedirectController) {
+ $this->data['route'] = $request->attributes->get('_route', 'n/a');
+ }
+ }
+ }
+ }
+
+ /**
+ * Remembers the controller associated to each request.
+ *
+ * @param FilterControllerEvent The filter controller event
+ */
+ public function onKernelController(FilterControllerEvent $event)
+ {
+ $this->controllers[$event->getRequest()] = $event->getController();
+ }
+
+ /**
+ * @return Boolean Whether this request will result in a redirect
+ */
+ public function getRedirect()
+ {
+ return $this->data['redirect'];
+ }
+
+ /**
+ * @return string|null The target URL
+ */
+ public function getTargetUrl()
+ {
+ return $this->data['url'];
+ }
+
+ /**
+ * @return string|null The target route
+ */
+ public function getTargetRoute()
+ {
+ return $this->data['route'];
}
/**
@@ -36,4 +101,4 @@ class RouterDataCollector extends DataCollector
{
return 'router';
}
-}
+}
\ No newline at end of file
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/collectors.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/collectors.xml
index 6b44b59222..33763c3823 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/collectors.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/collectors.xml
@@ -52,7 +52,8 @@
-
+
+
diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php
index 05d96f3670..e035fc6a7d 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php
+++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php
@@ -46,6 +46,7 @@ class RouterController extends ContainerAware
return $this->container->get('templating')->renderResponse('WebProfilerBundle:Router:panel.html.twig', array(
'request' => $request,
+ 'router' => $profile->getCollector('router'),
'traces' => $matcher->getTraces($request->getPathInfo()),
));
}
diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Router/panel.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Router/panel.html.twig
index f8a0f0e2ff..245c56698b 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Router/panel.html.twig
+++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Router/panel.html.twig
@@ -4,12 +4,20 @@
Route: {{ request.route }}
Route parameters:
- {% include 'WebProfilerBundle:Profiler:table.html.twig' with { 'data': request.routeParams } only %}
+ {% if request.routeParams|length %}
+ {% include 'WebProfilerBundle:Profiler:table.html.twig' with { 'data': request.routeParams, 'class': 'inline' } only %}
+ {% else %}
+ No parameters
+ {% endif %}
-
+ {% if router.redirect %}
+
+ Redirecting to: "{{ router.targetUrl }}" {% if router.targetRoute %}(route: "{{ router.targetRoute }}"){% endif %}
+
+ {% endif %}
Route matching:
-