Skip to content

Commit

Permalink
[TwigBundle] Extract output buffer cleaning to method
Browse files Browse the repository at this point in the history
  • Loading branch information
igorw committed Nov 11, 2011
1 parent ed1a6c2 commit 29e12af
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php
Expand Up @@ -37,15 +37,7 @@ public function showAction(FlattenException $exception, DebugLoggerInterface $lo
{
$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();
Expand All @@ -67,6 +59,21 @@ public function showAction(FlattenException $exception, DebugLoggerInterface $lo
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';
Expand Down

0 comments on commit 29e12af

Please sign in to comment.