Skip to content

Commit

Permalink
Simplify middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
barryvdh committed Jan 1, 2016
1 parent 3bf871f commit 5c1fef4
Showing 1 changed file with 9 additions and 28 deletions.
37 changes: 9 additions & 28 deletions src/Middleware/Debugbar.php
Original file line number Diff line number Diff line change
@@ -1,35 +1,25 @@
<?php namespace Barryvdh\Debugbar\Middleware;

use Closure;
use Illuminate\Contracts\Debug\ExceptionHandler;
use Illuminate\Contracts\Foundation\Application;
use Barryvdh\Debugbar\LaravelDebugbar;

class Debugbar {

/**
* The Laravel Application
*
* @var Application
*/
protected $app;

/**
* The Exception Handler
*
* @var ExceptionHandler
* @var LaravelDebugbar
*/
protected $exceptionHandler;
protected $debugbar;

/**
* Create a new middleware instance.
*
* @param Application $app
* @param ExceptionHandler $exceptionHandler
* @param LaravelDebugbar $debugbar
*/
public function __construct(Application $app, ExceptionHandler $exceptionHandler)
public function __construct(LaravelDebugbar $debugbar)
{
$this->app = $app;
$this->exceptionHandler = $exceptionHandler;
$this->debugbar = $debugbar;
}

/**
Expand All @@ -41,20 +31,11 @@ public function __construct(Application $app, ExceptionHandler $exceptionHandler
*/
public function handle($request, Closure $next)
{
/** @var \Barryvdh\Debugbar\LaravelDebugbar $debugbar */
$debugbar = $this->app['debugbar'];

try {
/** @var \Illuminate\Http\Response $response */
$response = $next($request);
} catch (\Exception $e) {
$debugbar->addException($e);
$response = $next($request);

$this->exceptionHandler->report($e);
$response = $this->exceptionHandler->render($request, $e);
}
$this->debugbar->modifyResponse($request, $response);

return $debugbar->modifyResponse($request, $response);
return $response;

}
}

0 comments on commit 5c1fef4

Please sign in to comment.