-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add files back for BC compact with 3rd party extensions (#1531)
- Loading branch information
Showing
2 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
namespace Barryvdh\Debugbar\DataCollector; | ||
|
||
use DebugBar\DataCollector\DataCollector; | ||
use DebugBar\DataCollector\DataCollectorInterface; | ||
use DebugBar\DataCollector\Renderable; | ||
use Illuminate\Contracts\Events\Dispatcher; | ||
|
||
/** | ||
* @deprecated in favor of \DebugBar\DataCollector\ObjectCountCollector | ||
*/ | ||
class JobsCollector extends DataCollector implements DataCollectorInterface, Renderable | ||
{ | ||
public $jobs = []; | ||
public $count = 0; | ||
|
||
/** | ||
* @param Dispatcher $events | ||
*/ | ||
public function __construct(Dispatcher $events) | ||
{ | ||
$events->listen(\Illuminate\Queue\Events\JobQueued::class, function ($event) { | ||
$class = get_class($event->job); | ||
$this->jobs[$class] = ($this->jobs[$class] ?? 0) + 1; | ||
$this->count++; | ||
}); | ||
} | ||
|
||
public function collect() | ||
{ | ||
ksort($this->jobs, SORT_NUMERIC); | ||
|
||
return ['data' => array_reverse($this->jobs), 'count' => $this->count]; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getName() | ||
{ | ||
return 'jobs'; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getWidgets() | ||
{ | ||
return [ | ||
"jobs" => [ | ||
"icon" => "briefcase", | ||
"widget" => "PhpDebugBar.Widgets.HtmlVariableListWidget", | ||
"map" => "jobs.data", | ||
"default" => "{}" | ||
], | ||
'jobs:badge' => [ | ||
'map' => 'jobs.count', | ||
'default' => 0 | ||
] | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
namespace Barryvdh\Debugbar\DataCollector; | ||
|
||
use DebugBar\DataCollector\DataCollector; | ||
use DebugBar\DataCollector\DataCollectorInterface; | ||
use DebugBar\DataCollector\Renderable; | ||
use Illuminate\Contracts\Events\Dispatcher; | ||
|
||
/** | ||
* Collector for Models. | ||
* @deprecated in favor of \DebugBar\DataCollector\ObjectCountCollector | ||
*/ | ||
class ModelsCollector extends DataCollector implements DataCollectorInterface, Renderable | ||
{ | ||
public $models = []; | ||
public $count = 0; | ||
|
||
/** | ||
* @param Dispatcher $events | ||
*/ | ||
public function __construct(Dispatcher $events) | ||
{ | ||
$events->listen('eloquent.retrieved:*', function ($event, $models) { | ||
foreach (array_filter($models) as $model) { | ||
$class = get_class($model); | ||
$this->models[$class] = ($this->models[$class] ?? 0) + 1; | ||
$this->count++; | ||
} | ||
}); | ||
} | ||
|
||
public function collect() | ||
{ | ||
ksort($this->models, SORT_NUMERIC); | ||
|
||
return ['data' => array_reverse($this->models), 'count' => $this->count]; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getName() | ||
{ | ||
return 'models'; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getWidgets() | ||
{ | ||
return [ | ||
"models" => [ | ||
"icon" => "cubes", | ||
"widget" => "PhpDebugBar.Widgets.HtmlVariableListWidget", | ||
"map" => "models.data", | ||
"default" => "{}" | ||
], | ||
'models:badge' => [ | ||
'map' => 'models.count', | ||
'default' => 0 | ||
] | ||
]; | ||
} | ||
} |