Skip to content

Commit 29e12af

Browse files
committed
[TwigBundle] Extract output buffer cleaning to method
1 parent ed1a6c2 commit 29e12af

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,7 @@ public function showAction(FlattenException $exception, DebugLoggerInterface $lo
3737
{
3838
$this->container->get('request')->setRequestFormat($format);
3939

40-
// the count variable avoids an infinite loop on
41-
// some Windows configurations where ob_get_level()
42-
// never reaches 0
43-
$count = 100;
44-
$startObLevel = $this->container->get('kernel')->getStartObLevel();
45-
$currentContent = '';
46-
while (ob_get_level() > $startObLevel && --$count) {
47-
$currentContent .= ob_get_clean();
48-
}
40+
$currentContent = $this->getAndCleanOutputBuffering();
4941

5042
$templating = $this->container->get('templating');
5143
$code = $exception->getStatusCode();
@@ -67,6 +59,21 @@ public function showAction(FlattenException $exception, DebugLoggerInterface $lo
6759
return $response;
6860
}
6961

62+
protected function getAndCleanOutputBuffering()
63+
{
64+
// the count variable avoids an infinite loop on
65+
// some Windows configurations where ob_get_level()
66+
// never reaches 0
67+
$count = 100;
68+
$startObLevel = $this->container->get('kernel')->getStartObLevel();
69+
$currentContent = '';
70+
while (ob_get_level() > $startObLevel && --$count) {
71+
$currentContent .= ob_get_clean();
72+
}
73+
74+
return $currentContent;
75+
}
76+
7077
protected function findTemplate($templating, $format, $code, $debug)
7178
{
7279
$name = $debug ? 'exception' : 'error';

0 commit comments

Comments
 (0)