Skip to content

Commit b7c8712

Browse files
committed
Add badge to events
1 parent a46abc9 commit b7c8712

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/DataCollector/EventCollector.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?php
2-
32
namespace Barryvdh\Debugbar\DataCollector;
43

54
use DebugBar\DataCollector\TimeDataCollector;
@@ -15,6 +14,7 @@ public function __construct($requestStartTime = null){
1514
parent::__construct($requestStartTime);
1615
$this->exporter = new ValueExporter();
1716
}
17+
1818
public function onWildcardEvent()
1919
{
2020
$args = func_get_args();
@@ -40,7 +40,8 @@ protected function getCurrentEvent($args)
4040
return $event;
4141
}
4242

43-
protected function prepareParams($params){
43+
protected function prepareParams($params)
44+
{
4445
$data = array();
4546
foreach ($params as $key => $value) {
4647
if (is_object($value) && method_exists($value, 'toArray')) {
@@ -51,6 +52,13 @@ protected function prepareParams($params){
5152
return $data;
5253
}
5354

55+
public function collect()
56+
{
57+
$data = parent::collect();
58+
$data['nb_measures'] = count($data['measures']);
59+
return $data;
60+
}
61+
5462
public function getName()
5563
{
5664
return 'event';
@@ -64,8 +72,11 @@ public function getWidgets()
6472
"widget" => "PhpDebugBar.Widgets.TimelineWidget",
6573
"map" => "event",
6674
"default" => "{}"
75+
),
76+
'events:badge' => array(
77+
'map' => 'event.nb_measures',
78+
'default' => 0
6779
)
6880
);
6981
}
70-
7182
}

0 commit comments

Comments
 (0)