From a9f31825fe799959979d456f5dbc5666b3d31140 Mon Sep 17 00:00:00 2001 From: erikn69 Date: Thu, 19 Oct 2023 16:08:46 -0500 Subject: [PATCH] Support events collector on clockwork --- src/LaravelDebugbar.php | 5 ++--- src/Support/Clockwork/Converter.php | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/LaravelDebugbar.php b/src/LaravelDebugbar.php index 2213f269..e105b92b 100644 --- a/src/LaravelDebugbar.php +++ b/src/LaravelDebugbar.php @@ -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( diff --git a/src/Support/Clockwork/Converter.php b/src/Support/Clockwork/Converter.php index 521c32c8..984e0179 100644 --- a/src/Support/Clockwork/Converter.php +++ b/src/Support/Clockwork/Converter.php @@ -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'][] = [