Kaynağa Gözat

[TwigBundle] Extract output buffer cleaning to method

Igor Wiedler 13 yıl önce
ebeveyn
işleme
29e12affb0

+ 16 - 9
src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php

@@ -37,15 +37,7 @@ class ExceptionController extends ContainerAware
     {
         $this->container->get('request')->setRequestFormat($format);
 
-        // the count variable avoids an infinite loop on
-        // some Windows configurations where ob_get_level()
-        // never reaches 0
-        $count = 100;
-        $startObLevel = $this->container->get('kernel')->getStartObLevel();
-        $currentContent = '';
-        while (ob_get_level() > $startObLevel && --$count) {
-            $currentContent .= ob_get_clean();
-        }
+        $currentContent = $this->getAndCleanOutputBuffering();
 
         $templating = $this->container->get('templating');
         $code = $exception->getStatusCode();
@@ -67,6 +59,21 @@ class ExceptionController extends ContainerAware
         return $response;
     }
 
+    protected function getAndCleanOutputBuffering()
+    {
+        // the count variable avoids an infinite loop on
+        // some Windows configurations where ob_get_level()
+        // never reaches 0
+        $count = 100;
+        $startObLevel = $this->container->get('kernel')->getStartObLevel();
+        $currentContent = '';
+        while (ob_get_level() > $startObLevel && --$count) {
+            $currentContent .= ob_get_clean();
+        }
+
+        return $currentContent;
+    }
+
     protected function findTemplate($templating, $format, $code, $debug)
     {
         $name = $debug ? 'exception' : 'error';