Skip to content

Commit 75194d4

Browse files
committed
Add Storage and OpenHandler
To save ajax/redirect requests in storage, instead of headers/sessions
1 parent 425adab commit 75194d4

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/Barryvdh/Debugbar/LaravelDebugBar.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ public function modifyResponse($request, $response){
267267
if($response->isRedirection()){
268268
$this->stackData();
269269
}elseif( $request->isXmlHttpRequest() and $app['config']->get('laravel-debugbar::config.capture_ajax', true)){
270-
$this->sendDataInHeaders();
270+
$this->sendDataInHeaders(true);
271271
}elseif(
272272
($response->headers->has('Content-Type') && false === strpos($response->headers->get('Content-Type'), 'html'))
273273
|| 'html' !== $request->getRequestFormat()
@@ -399,6 +399,8 @@ public function injectDebugbar(Response $response)
399399
$pos = $posrFunction($content, '</body>');
400400

401401
$renderer = $this->getJavascriptRenderer();
402+
$renderer->setOpenHandlerUrl('_debugbar/open');
403+
402404
$debugbar = $renderer->renderHead() . $renderer->render();
403405

404406
if (false !== $pos) {

src/Barryvdh/Debugbar/ServiceProvider.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php namespace Barryvdh\Debugbar;
22

3+
use DebugBar\Storage\FileStorage;
34

45
class ServiceProvider extends \Illuminate\Support\ServiceProvider {
56

@@ -44,9 +45,20 @@ public function register()
4445
$httpDriver = new SymfonyHttpDriver($sessionManager);
4546
$debugbar->setHttpDriver($httpDriver);
4647

48+
$debugbar->setStorage($app['debugbar.storage']);
49+
4750
return $debugbar;
4851
});
4952

53+
$this->app['debugbar.storage'] = $this->app->share(function ($app){
54+
55+
$storagePath = storage_path().'/cache/debugbar';
56+
if (!file_exists($storagePath)) {
57+
mkdir($storagePath, 0777, true);
58+
}
59+
return new FileStorage($storagePath);
60+
});
61+
5062
$this->app['command.debugbar.publish'] = $this->app->share(function($app)
5163
{
5264
//Make sure the asset publisher is registered.
@@ -64,6 +76,18 @@ public function register()
6476
});
6577
}
6678

79+
$this->app['router']->get('_debugbar/open', function() use($app){
80+
81+
$debugbar = $app['debugbar'];
82+
$debugbar->setStorage($app['debugbar.storage']);
83+
$openHandler = new \DebugBar\OpenHandler($debugbar);
84+
85+
$data = $openHandler->handle(null, false, false);
86+
return \Response::make($data, 200, array(
87+
'Content-Type'=> 'application/json'
88+
));
89+
});
90+
6791
}
6892

6993
/**
@@ -73,7 +97,7 @@ public function register()
7397
*/
7498
public function provides()
7599
{
76-
return array('debugbar', 'command.debugbar.publish');
100+
return array('debugbar', 'debugbar.storage', 'command.debugbar.publish');
77101
}
78102

79103
}

0 commit comments

Comments
 (0)