diff --git a/examples/example-silex.php b/examples/example-silex.php index 1e1f789..9c965fe 100644 --- a/examples/example-silex.php +++ b/examples/example-silex.php @@ -27,6 +27,14 @@ $app['debug'] = true; if($app['debug']) { $app->register(new DamnitServiceProvider); + + // Example: Extend the error page to disable the 'damnit' branding + // in the top-right corner, so those big-wigs at the office wont' + // throw a tantrum: + $app['damnit.error_page_handler'] = $app->extend('damnit.error_page_handler', function($handler) { + $handler->showBranding(true); + return $handler; + }); } $app->get('/', function() use($app) { diff --git a/src/Damnit/Handler/PrettyPageHandler.php b/src/Damnit/Handler/PrettyPageHandler.php index 82676c7..7993711 100644 --- a/src/Damnit/Handler/PrettyPageHandler.php +++ b/src/Damnit/Handler/PrettyPageHandler.php @@ -20,6 +20,11 @@ class PrettyPageHandler extends Handler */ private $extraTables = array(); + /** + * @var bool + */ + private $showBranding = true; + /** * @return int|null */ @@ -44,12 +49,13 @@ class PrettyPageHandler extends Handler $frames = $inspector->getFrames(); $v = (object) array( - 'name' => explode('\\', $inspector->getExceptionName()), - 'message' => $inspector->getException()->getMessage(), - 'frames' => $frames, - 'hasFrames' => !!count($frames), - 'handler' => $this, - 'handlers' => $this->getRun()->getHandlers(), + 'name' => explode('\\', $inspector->getExceptionName()), + 'message' => $inspector->getException()->getMessage(), + 'frames' => $frames, + 'hasFrames' => !!count($frames), + 'handler' => $this, + 'handlers' => $this->getRun()->getHandlers(), + 'showBranding' => $this->showBranding, 'tables' => array( 'GET Data' => $_GET, @@ -83,6 +89,15 @@ class PrettyPageHandler extends Handler return Handler::QUIT; } + /** + * Should the `damnit` branding be visible in the top-right corner? + * @param bool $showBranding + */ + public function showBranding($showBranding = true) + { + $this->showBranding = (bool) $showBranding; + } + /** * Adds an entry to the list of tables displayed in the template. * The expected data is a simple associative array. Any nested arrays diff --git a/src/Damnit/Resources/pretty-template.php b/src/Damnit/Resources/pretty-template.php index d8f8dcd..fe8e951 100644 --- a/src/Damnit/Resources/pretty-template.php +++ b/src/Damnit/Resources/pretty-template.php @@ -296,9 +296,11 @@