Skip to content

Commit

Permalink
Remove session dependancy
Browse files Browse the repository at this point in the history
  • Loading branch information
barryvdh committed Jan 2, 2016
1 parent 71b13b9 commit 6eb8034
Showing 1 changed file with 36 additions and 31 deletions.
67 changes: 36 additions & 31 deletions src/LaravelDebugbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use Exception;

use Illuminate\Contracts\Foundation\Application;
use Illuminate\Session\SessionManager;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

Expand Down Expand Up @@ -107,8 +108,8 @@ public function boot()
return;
}

if ($this->isDebugbarRequest()) {
$this->app['session']->reflash();
if ($this->isDebugbarRequest() && $this->app->bound(SessionManager::class)) {
$this->app->make(SessionManager::class)->reflash();
}

/** @var \Barryvdh\Debugbar\LaravelDebugbar $debugbar */
Expand All @@ -133,14 +134,14 @@ public function boot()

if ( ! $this->isLumen()) {
$this->app->booted(
function () use ($debugbar, $startTime) {
if ($startTime) {
$debugbar['time']->addMeasure('Booting', $startTime, microtime(true));
}
}
function () use ($debugbar, $startTime) {
if ($startTime) {
$debugbar['time']->addMeasure('Booting', $startTime, microtime(true));
}
}
);
}

$debugbar->startMeasure('application', 'Application');
}

Expand Down Expand Up @@ -446,7 +447,6 @@ public function getJavascriptRenderer($baseUrl = null, $basePath = null)
{
if ($this->jsRenderer === null) {
$this->jsRenderer = new JavascriptRenderer($this, $baseUrl, $basePath);
$this->jsRenderer->setUrlGenerator($this->app['url']);
}
return $this->jsRenderer;
}
Expand All @@ -464,7 +464,7 @@ public function modifyResponse(Request $request, Response $response)
if ($app->runningInConsole() || !$this->isEnabled() || $this->isDebugbarRequest()) {
return $response;
}

// Show the Http Response Exception in the Debugbar, when available
if (isset($response->exception)) {
$this->addException($response->exception);
Expand All @@ -486,23 +486,28 @@ public function modifyResponse(Request $request, Response $response)
}
}

/** @var \Illuminate\Session\SessionManager $sessionManager */
$sessionManager = $app['session'];
$httpDriver = new SymfonyHttpDriver($sessionManager, $response);
$this->setHttpDriver($httpDriver);
if ($this->app->bound(SessionManager::class)){

if ($this->shouldCollect('session')) {
try {
$this->addCollector(new SessionCollector($sessionManager));
} catch (\Exception $e) {
$this->addException(
new Exception(
'Cannot add SessionCollector to Laravel Debugbar: ' . $e->getMessage(),
$e->getCode(),
$e
)
);
/** @var \Illuminate\Session\SessionManager $sessionManager */
$sessionManager = $app->make(SessionManager::class);
$httpDriver = new SymfonyHttpDriver($sessionManager, $response);
$this->setHttpDriver($httpDriver);

if ($this->shouldCollect('session')) {
try {
$this->addCollector(new SessionCollector($sessionManager));
} catch (\Exception $e) {
$this->addException(
new Exception(
'Cannot add SessionCollector to Laravel Debugbar: ' . $e->getMessage(),
$e->getCode(),
$e
)
);
}
}
} else {
$sessionManager = null;
}

if ($this->shouldCollect('symfony_request', true) && !$this->hasCollector('request')) {
Expand All @@ -525,11 +530,11 @@ public function modifyResponse(Request $request, Response $response)
$this->addCollector(new ClockworkCollector($request, $response, $sessionManager));
} catch (\Exception $e) {
$this->addException(
new Exception(
'Cannot add ClockworkCollector to Laravel Debugbar: ' . $e->getMessage(),
$e->getCode(),
$e
)
new Exception(
'Cannot add ClockworkCollector to Laravel Debugbar: ' . $e->getMessage(),
$e->getCode(),
$e
)
);
}

Expand Down Expand Up @@ -666,7 +671,7 @@ public function injectDebugbar(Response $response)

$renderer = $this->getJavascriptRenderer();
if ($this->getStorage()) {
$openHandlerUrl = $this->app['url']->route('debugbar.openhandler');
$openHandlerUrl = route('debugbar.openhandler');
$renderer->setOpenHandlerUrl($openHandlerUrl);
}

Expand Down

0 comments on commit 6eb8034

Please sign in to comment.