Skip to content

Commit

Permalink
Update for 5.5, remove old checks
Browse files Browse the repository at this point in the history
  • Loading branch information
barryvdh committed Jul 21, 2017
1 parent 8d49f95 commit 70831de
Show file tree
Hide file tree
Showing 14 changed files with 99 additions and 227 deletions.
8 changes: 5 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
"require": {
"php": ">=7.0",
"maximebf/debugbar": "~1.14.0",
"illuminate/support": "5.5.*",
"symfony/debug": "~3.3",
"symfony/finder": "~3.3"
"illuminate/support": "5.5.x",
"illuminate/session": "5.5.x",
"symfony/debug": "^3.3",
"symfony/finder": "^3.3",
"illuminate/routing": "5.5.x"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion config/debugbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
|
*/

'enabled' => env('DEBUGBAR_ENABLED', null),
'enabled' => env('DEBUGBAR_ENABLED', env('APP_DEBUG', false)),

/*
|--------------------------------------------------------------------------
Expand Down
39 changes: 0 additions & 39 deletions src/Console/PublishCommand.php

This file was deleted.

115 changes: 0 additions & 115 deletions src/DataCollector/AuthCollector.php

This file was deleted.

8 changes: 0 additions & 8 deletions src/DataCollector/EventCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@ public function __construct($requestStartTime = null)

public function onWildcardEvent($name = null, $data = [])
{
// Pre-Laravel 5.4, using 'firing' to get the current event name.
if (method_exists($this->events, 'firing')) {
$name = $this->events->firing();

// Get the arguments passed to the event
$data = func_get_args();
}

$params = $this->prepareParams($data);
$time = microtime(true);

Expand Down
4 changes: 1 addition & 3 deletions src/DataCollector/GateCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ public function __construct(Gate $gate)
parent::__construct('gate');
$this->exporter = new ValueExporter();

if (method_exists($gate, 'after')) {
$gate->after([$this, 'addCheck']);
}
$gate->after([$this, 'addCheck']);
}

public function addCheck(Authenticatable $user, $ability, $result, $arguments = [])
Expand Down
65 changes: 63 additions & 2 deletions src/DataCollector/MultiAuthCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,45 @@

namespace Barryvdh\Debugbar\DataCollector;

use DebugBar\DataCollector\DataCollector;
use DebugBar\DataCollector\Renderable;
use Illuminate\Auth\SessionGuard;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Support\Str;
use Illuminate\Contracts\Support\Arrayable;


/**
* Collector for Laravel's Auth provider
*/
class MultiAuthCollector extends AuthCollector
class MultiAuthCollector extends DataCollector implements Renderable
{
/** @var array $guards */
protected $guards;

/** @var \Illuminate\Auth\AuthManager */
protected $auth;
/** @var bool */
protected $showName = false;

/**
* @param \Illuminate\Auth\AuthManager $auth
* @param array $guards
*/
public function __construct($auth, $guards)
{
parent::__construct($auth);
$this->auth = $auth;
$this->guards = $guards;
}

/**
* Set to show the users name/email
* @param bool $showName
*/
public function setShowName($showName)
{
$this->showName = (bool) $showName;
}

/**
* @{inheritDoc}
Expand Down Expand Up @@ -77,6 +94,49 @@ private function resolveUser(Guard $guard)
return $guard->user();
}

/**
* Get displayed user information
* @param \Illuminate\Auth\UserInterface $user
* @return array
*/
protected function getUserInformation($user = null)
{
// Defaults
if (is_null($user)) {
return [
'name' => 'Guest',
'user' => ['guest' => true],
];
}

// The default auth identifer is the ID number, which isn't all that
// useful. Try username and email.
$identifier = $user->getAuthIdentifier();
if (is_numeric($identifier)) {
try {
if ($user->username) {
$identifier = $user->username;
} elseif ($user->email) {
$identifier = $user->email;
}
} catch (\Exception $e) {
}
}

return [
'name' => $identifier,
'user' => $user instanceof Arrayable ? $user->toArray() : $user,
];
}

/**
* @{inheritDoc}
*/
public function getName()
{
return 'auth';
}

/**
* @{inheritDoc}
*/
Expand All @@ -102,4 +162,5 @@ public function getWidgets()

return $widgets;
}

}
2 changes: 1 addition & 1 deletion src/Facade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ class Facade extends \Illuminate\Support\Facades\Facade
*/
protected static function getFacadeAccessor()
{
return 'debugbar';
return LaravelDebugbar::class;
}
}
9 changes: 2 additions & 7 deletions src/LaravelDebugbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,13 +436,8 @@ function ($query, $bindings = null, $time = null, $connectionName = null) use ($

if ($this->shouldCollect('auth', false)) {
try {
if($this->checkVersion('5.2')) {
// fix for compatibility with Laravel 5.2.*
$guards = array_keys($this->app['config']->get('auth.guards'));
$authCollector = new MultiAuthCollector($app['auth'], $guards);
} else {
$authCollector = new AuthCollector($app['auth']);
}
$guards = array_keys($this->app['config']->get('auth.guards'));
$authCollector = new MultiAuthCollector($app['auth'], $guards);

$authCollector->setShowName(
$this->app['config']->get('debugbar.options.auth.show_name')
Expand Down
8 changes: 0 additions & 8 deletions src/LumenServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@ protected function registerMiddleware($middleware)
$this->app->middleware([$middleware]);
}

/**
* Check the App Debug status
*/
protected function checkAppDebug()
{
return env('APP_DEBUG');
}

/**
* Get the services provided by the provider.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Illuminate\Contracts\Debug\ExceptionHandler;
use Symfony\Component\Debug\Exception\FatalThrowableError;

class Debugbar
class InjectDebugbar
{
/**
* The App container
Expand Down
Loading

0 comments on commit 70831de

Please sign in to comment.