Skip to content
This repository has been archived by the owner on Nov 2, 2018. It is now read-only.

Commit

Permalink
Another change that should've been in 490b695
Browse files Browse the repository at this point in the history
  • Loading branch information
hassankhan committed Feb 12, 2014
1 parent fa880ec commit e792ce7
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions plugins/WhoopsPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,37 @@ class WhoopsPlugin implements \Zepto\PluginInterface {

public function after_plugins_load()
{
$container = func_get_arg(0);
$app = func_get_arg(0);

// Add Whoops handlers
$container['whoopsPrettyPageHandler'] = $container->share(
$app['whoopsPrettyPageHandler'] = $app->share(
function() {
return new PrettyPageHandler();
}
);
$container['whoopsJsonResponseHandler'] = $container->share(
$app['whoopsJsonResponseHandler'] = $app->share(
function() {
$handler = new JsonResponseHandler();
$handler->onlyForAjaxRequests(true);
return $handler;
}
);
$container["whoopsZeptoInfoHandler"] = $container->protect(
function() use ($container) {
$app["whoopsZeptoInfoHandler"] = $app->protect(
function() use ($app) {

// Check to see if there is a current route, otherwise
// ignore because router isn't set up yet
try{
$current_route = $container['router']->current_route();
$current_route = $app['router']->current_route();
}
catch (\Exception $e) {
return;
}

$route_details = array();

$container['whoopsPrettyPageHandler']->setPageTitle('Shit hit the fan!');
$container['whoopsPrettyPageHandler']->setEditor('sublime');
$app['whoopsPrettyPageHandler']->setPageTitle('Shit hit the fan!');
$app['whoopsPrettyPageHandler']->setEditor('sublime');

if ($current_route !== null) {
$route_details = array(
Expand All @@ -56,47 +56,47 @@ function() use ($container) {
);
}

$container["whoopsPrettyPageHandler"]->addDataTable(
$app["whoopsPrettyPageHandler"]->addDataTable(
'Zepto Application',
array_merge(array(
'Charset' => $container['request']->headers->get('Accept-Charset'),
'Locale' => $container['request']->getPreferredLanguage()
'Charset' => $app['request']->headers->get('Accept-Charset'),
'Locale' => $app['request']->getPreferredLanguage()
), $route_details)
);

$container["whoopsPrettyPageHandler"]->addDataTable(
$app["whoopsPrettyPageHandler"]->addDataTable(
'Request Information',
array(
'URI' => $container['request']->getUri(),
'Request URI' => $container['request']->getRequestUri(),
'Path' => $container['request']->getPathInfo(),
'Query String' => $container['request']->getQueryString(),
'HTTP Method' => $container['request']->getMethod(),
'Script Name' => $container['request']->getScriptName(),
'Base URL' => $container['request']->getBaseUrl(),
'Scheme' => $container['request']->getScheme(),
'Port' => $container['request']->getPort(),
'Host' => $container['request']->getHost()
'URI' => $app['request']->getUri(),
'Request URI' => $app['request']->getRequestUri(),
'Path' => $app['request']->getPathInfo(),
'Query String' => $app['request']->getQueryString(),
'HTTP Method' => $app['request']->getMethod(),
'Script Name' => $app['request']->getScriptName(),
'Base URL' => $app['request']->getBaseUrl(),
'Scheme' => $app['request']->getScheme(),
'Port' => $app['request']->getPort(),
'Host' => $app['request']->getHost()
)
);
}
);

// Add actual Whoops\Run object
$container['whoops'] = $container->share(
function($container) {
$app['whoops'] = $app->share(
function($app) {
$run = new Run();
$run->pushHandler($container['whoopsPrettyPageHandler']);
$run->pushHandler($container['whoopsJsonResponseHandler']);
$run->pushHandler($container['whoopsZeptoInfoHandler']);
$run->pushHandler($app['whoopsPrettyPageHandler']);
$run->pushHandler($app['whoopsJsonResponseHandler']);
$run->pushHandler($app['whoopsZeptoInfoHandler']);
return $run;
}
);

// Try to register Whoops, and set the callback function
try {
$container['whoops']->register();
$container['router']->error(array($container['whoops'], Run::EXCEPTION_HANDLER));
$app['whoops']->register();
$app['router']->error(array($app['whoops'], Run::EXCEPTION_HANDLER));
} catch (\Exception $e) {
return;
}
Expand Down

0 comments on commit e792ce7

Please sign in to comment.