Browse Source

[WebProfilerBundle] Use a template for the redirection interceptions

Antoine Hérault 14 years ago
parent
commit
7049810729

+ 10 - 0
src/Symfony/Bundle/WebProfilerBundle/Resources/views/Redirection/interception.html.twig

@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>Redirection Intercepted</title>
+</head>
+<body>
+    <h1>This Request redirects to<br /><a href="{{ location }}">{{ location }}</a>.</h1>
+    <h4>The redirect was intercepted by the web debug toolbar to help debugging.<br/>For more information, see the "intercept-redirects" option of the Profiler.</h4>
+</body>
+</html>

+ 2 - 2
src/Symfony/Bundle/WebProfilerBundle/Tests/WebDebugToolbarListenerTest.php

@@ -57,11 +57,11 @@ class WebDebugToolbarListenerTest extends \PHPUnit_Framework_TestCase
             $response->headers->set('X-Debug-Token', 'xxxxxxxx');
             $response->headers->set('X-Debug-Token', 'xxxxxxxx');
             $event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), Kernel::MASTER_REQUEST, $response);
             $event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), Kernel::MASTER_REQUEST, $response);
 
 
-            $listener = new WebDebugToolbarListener($this->getTemplatingMock(), true);
+            $listener = new WebDebugToolbarListener($this->getTemplatingMock('Redirection'), true);
             $listener->onCoreResponse($event);
             $listener->onCoreResponse($event);
 
 
             $this->assertEquals(200, $response->getStatusCode());
             $this->assertEquals(200, $response->getStatusCode());
-            $this->assertRegExp('/The redirect was intercepted/', $response->getContent());
+            $this->assertEquals('Redirection', $response->getContent());
         }
         }
     }
     }
 
 

+ 1 - 4
src/Symfony/Bundle/WebProfilerBundle/WebDebugToolbarListener.php

@@ -52,10 +52,7 @@ class WebDebugToolbarListener
             // keep current flashes for one more request
             // keep current flashes for one more request
             $request->getSession()->setFlashes($request->getSession()->getFlashes());
             $request->getSession()->setFlashes($request->getSession()->getFlashes());
 
 
-            $response->setContent(
-                sprintf('<html><head></head><body><h1>This Request redirects to<br /><a href="%1$s">%1$s</a>.</h1><h4>The redirect was intercepted by the web debug toolbar to help debugging.<br/>For more information, see the "intercept-redirects" option of the Profiler.</h4></body></html>',
-                $response->headers->get('Location'))
-            );
+            $response->setContent($this->templating->render('WebDebugToolbar:Profiler:redirect.html.twig', array('location' => $response->headers->get('Location'))));
             $response->setStatusCode(200);
             $response->setStatusCode(200);
             $response->headers->remove('Location');
             $response->headers->remove('Location');
         }
         }