Add PrettyPageHandler::showBranding(bool) to add ability to hide 'damnit' branding

This commit is contained in:
filp
2013-03-15 18:47:59 +00:00
parent 36f7839e2b
commit e5e6674438
3 changed files with 34 additions and 9 deletions
+8
View File
@@ -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) {
+21 -6
View File
@@ -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
+5 -3
View File
@@ -296,9 +296,11 @@
</head>
<body>
<div class="container">
<div class="branding">
generated by the <strong><a href="http://github.com/filp/damnit">damnit!</a></strong> php error handler
</div>
<?php if($v->showBranding): ?>
<div class="branding">
generated by the <strong><a href="http://github.com/filp/damnit">damnit!</a></strong> php error handler
</div>
<?php endif ?>
<header>
<div class="exception">
<h3 class="exc-title">