Skip to content

Commit

Permalink
Support events collector on clockwork
Browse files Browse the repository at this point in the history
  • Loading branch information
erikn69 committed Oct 19, 2023
1 parent b736241 commit a9f3182
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/LaravelDebugbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,8 @@ function () use ($debugbar, $startTime) {
if ($this->shouldCollect('events', false) && isset($this->app['events'])) {
try {
$startTime = $this->app['request']->server('REQUEST_TIME_FLOAT');
$eventCollector = new EventCollector($startTime);
$this->addCollector($eventCollector);
$this->app['events']->subscribe($eventCollector);
$this->addCollector(new EventCollector($startTime));
$this->app['events']->subscribe($debugbar['event']);
} catch (\Exception $e) {
$this->addThrowable(
new Exception(
Expand Down
17 changes: 17 additions & 0 deletions src/Support/Clockwork/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,23 @@ public function convert($data)
}
}

if (isset($data['event'])) {
foreach ($data['event']['measures'] as $event) {
$event['data'] = [];
$event['listeners'] = [];
foreach ($event['params'] ?? [] as $key => $param) {
$event[is_numeric($key) ? 'data' : 'listeners'] = $param;
}
$output['events'][] = [
'event' => ['event' => $event['label']],
'data' => $event['data'],
'time' => $event['start'],
'duration' => $event['duration'] * 1000,
'listeners' => $event['listeners'],
];
}
}

if (isset($data['symfonymailer_mails'])) {
foreach ($data['symfonymailer_mails']['mails'] as $mail) {
$output['emailsData'][] = [
Expand Down

0 comments on commit a9f3182

Please sign in to comment.