Skip to content

Commit 70831de

Browse files
committed
Update for 5.5, remove old checks
1 parent 8d49f95 commit 70831de

14 files changed

+99
-227
lines changed

composer.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
"require": {
1313
"php": ">=7.0",
1414
"maximebf/debugbar": "~1.14.0",
15-
"illuminate/support": "5.5.*",
16-
"symfony/debug": "~3.3",
17-
"symfony/finder": "~3.3"
15+
"illuminate/support": "5.5.x",
16+
"illuminate/session": "5.5.x",
17+
"symfony/debug": "^3.3",
18+
"symfony/finder": "^3.3",
19+
"illuminate/routing": "5.5.x"
1820
},
1921
"autoload": {
2022
"psr-4": {

config/debugbar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
|
1313
*/
1414

15-
'enabled' => env('DEBUGBAR_ENABLED', null),
15+
'enabled' => env('DEBUGBAR_ENABLED', env('APP_DEBUG', false)),
1616

1717
/*
1818
|--------------------------------------------------------------------------

src/Console/PublishCommand.php

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/DataCollector/AuthCollector.php

Lines changed: 0 additions & 115 deletions
This file was deleted.

src/DataCollector/EventCollector.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,6 @@ public function __construct($requestStartTime = null)
2323

2424
public function onWildcardEvent($name = null, $data = [])
2525
{
26-
// Pre-Laravel 5.4, using 'firing' to get the current event name.
27-
if (method_exists($this->events, 'firing')) {
28-
$name = $this->events->firing();
29-
30-
// Get the arguments passed to the event
31-
$data = func_get_args();
32-
}
33-
3426
$params = $this->prepareParams($data);
3527
$time = microtime(true);
3628

src/DataCollector/GateCollector.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ public function __construct(Gate $gate)
2222
parent::__construct('gate');
2323
$this->exporter = new ValueExporter();
2424

25-
if (method_exists($gate, 'after')) {
26-
$gate->after([$this, 'addCheck']);
27-
}
25+
$gate->after([$this, 'addCheck']);
2826
}
2927

3028
public function addCheck(Authenticatable $user, $ability, $result, $arguments = [])

src/DataCollector/MultiAuthCollector.php

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,45 @@
22

33
namespace Barryvdh\Debugbar\DataCollector;
44

5+
use DebugBar\DataCollector\DataCollector;
6+
use DebugBar\DataCollector\Renderable;
57
use Illuminate\Auth\SessionGuard;
68
use Illuminate\Contracts\Auth\Guard;
79
use Illuminate\Support\Str;
10+
use Illuminate\Contracts\Support\Arrayable;
11+
812

913
/**
1014
* Collector for Laravel's Auth provider
1115
*/
12-
class MultiAuthCollector extends AuthCollector
16+
class MultiAuthCollector extends DataCollector implements Renderable
1317
{
1418
/** @var array $guards */
1519
protected $guards;
1620

21+
/** @var \Illuminate\Auth\AuthManager */
22+
protected $auth;
23+
/** @var bool */
24+
protected $showName = false;
25+
1726
/**
1827
* @param \Illuminate\Auth\AuthManager $auth
1928
* @param array $guards
2029
*/
2130
public function __construct($auth, $guards)
2231
{
23-
parent::__construct($auth);
32+
$this->auth = $auth;
2433
$this->guards = $guards;
2534
}
2635

36+
/**
37+
* Set to show the users name/email
38+
* @param bool $showName
39+
*/
40+
public function setShowName($showName)
41+
{
42+
$this->showName = (bool) $showName;
43+
}
2744

2845
/**
2946
* @{inheritDoc}
@@ -77,6 +94,49 @@ private function resolveUser(Guard $guard)
7794
return $guard->user();
7895
}
7996

97+
/**
98+
* Get displayed user information
99+
* @param \Illuminate\Auth\UserInterface $user
100+
* @return array
101+
*/
102+
protected function getUserInformation($user = null)
103+
{
104+
// Defaults
105+
if (is_null($user)) {
106+
return [
107+
'name' => 'Guest',
108+
'user' => ['guest' => true],
109+
];
110+
}
111+
112+
// The default auth identifer is the ID number, which isn't all that
113+
// useful. Try username and email.
114+
$identifier = $user->getAuthIdentifier();
115+
if (is_numeric($identifier)) {
116+
try {
117+
if ($user->username) {
118+
$identifier = $user->username;
119+
} elseif ($user->email) {
120+
$identifier = $user->email;
121+
}
122+
} catch (\Exception $e) {
123+
}
124+
}
125+
126+
return [
127+
'name' => $identifier,
128+
'user' => $user instanceof Arrayable ? $user->toArray() : $user,
129+
];
130+
}
131+
132+
/**
133+
* @{inheritDoc}
134+
*/
135+
public function getName()
136+
{
137+
return 'auth';
138+
}
139+
80140
/**
81141
* @{inheritDoc}
82142
*/
@@ -102,4 +162,5 @@ public function getWidgets()
102162

103163
return $widgets;
104164
}
165+
105166
}

src/Facade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ class Facade extends \Illuminate\Support\Facades\Facade
77
*/
88
protected static function getFacadeAccessor()
99
{
10-
return 'debugbar';
10+
return LaravelDebugbar::class;
1111
}
1212
}

src/LaravelDebugbar.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -436,13 +436,8 @@ function ($query, $bindings = null, $time = null, $connectionName = null) use ($
436436

437437
if ($this->shouldCollect('auth', false)) {
438438
try {
439-
if($this->checkVersion('5.2')) {
440-
// fix for compatibility with Laravel 5.2.*
441-
$guards = array_keys($this->app['config']->get('auth.guards'));
442-
$authCollector = new MultiAuthCollector($app['auth'], $guards);
443-
} else {
444-
$authCollector = new AuthCollector($app['auth']);
445-
}
439+
$guards = array_keys($this->app['config']->get('auth.guards'));
440+
$authCollector = new MultiAuthCollector($app['auth'], $guards);
446441

447442
$authCollector->setShowName(
448443
$this->app['config']->get('debugbar.options.auth.show_name')

src/LumenServiceProvider.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,6 @@ protected function registerMiddleware($middleware)
3737
$this->app->middleware([$middleware]);
3838
}
3939

40-
/**
41-
* Check the App Debug status
42-
*/
43-
protected function checkAppDebug()
44-
{
45-
return env('APP_DEBUG');
46-
}
47-
4840
/**
4941
* Get the services provided by the provider.
5042
*

src/Middleware/Debugbar.php renamed to src/Middleware/InjectDebugbar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Illuminate\Contracts\Debug\ExceptionHandler;
1010
use Symfony\Component\Debug\Exception\FatalThrowableError;
1111

12-
class Debugbar
12+
class InjectDebugbar
1313
{
1414
/**
1515
* The App container

0 commit comments

Comments
 (0)