@@ -23,41 +23,41 @@ class DataCollectorPlugin extends DataCollector implements Plugin
23
23
*/
24
24
protected $ listenerHandlers = [];
25
25
26
+ /**
27
+ * @var array
28
+ */
29
+ private $ buses = [];
30
+
26
31
/**
27
32
* @var Stopwatch
28
33
*/
29
34
private $ stopwatch ;
30
35
36
+ /**
37
+ * @var ContainerInterface
38
+ */
39
+ private $ container ;
40
+
31
41
public function __construct (ContainerInterface $ container , string $ busType )
32
42
{
33
43
$ this ->stopwatch = new Stopwatch ();
34
- $ this ->data ['bus_type ' ] = $ busType ;
35
44
$ this ->container = $ container ;
45
+ $ this ->data ['bus_type ' ] = $ busType ;
36
46
$ this ->data ['messages ' ] = [];
37
47
$ this ->data ['duration ' ] = [];
38
- $ this ->buses = [];
39
48
}
40
49
41
- /**
42
- * {@inheritdoc}
43
- */
44
50
public function collect (Request $ request , Response $ response , \Exception $ exception = null )
45
51
{
46
52
foreach ($ this ->buses as $ bus ) {
47
53
$ busName = $ bus ->busName ();
48
54
49
- $ reflClass = new \ReflectionClass ($ bus );
50
- $ reflProperty = $ reflClass ->getProperty ('events ' );
51
- $ reflProperty ->setAccessible (true );
52
- // todo maybe put as default value in config tree builder to also make it configurable?
53
- // $this->data['config'][$busName]['action_event_emitter'] = get_class($reflProperty->getValue($bus));
54
- $ this ->data ['config ' ][$ busName ] = $ this ->container ->getParameter (sprintf ('prooph_service_bus.%s.configuration ' , $ busName ));
55
+ $ this ->data ['config ' ][$ busName ] = $ this ->container ->getParameter (
56
+ sprintf ('prooph_service_bus.%s.configuration ' , $ busName )
57
+ );
55
58
}
56
59
}
57
60
58
- /**
59
- * {@inheritdoc}
60
- */
61
61
public function getName (): string
62
62
{
63
63
return sprintf ('prooph.%s_bus ' , $ this ->data ['bus_type ' ]);
@@ -105,9 +105,14 @@ public function attachToMessageBus(MessageBus $messageBus): void
105
105
if ($ messageBus instanceof QueryBus) {
106
106
return ;
107
107
}
108
+
108
109
$ this ->buses [] = $ messageBus ;
109
110
if (! $ messageBus instanceof NamedMessageBus) {
110
- throw new RuntimeException (sprinf ('To use the Symfony Datacollector, the Bus "%s" needs to implement "%s" ' , $ messageBus , NamedMessageBus::class));
111
+ throw new RuntimeException (sprinf (
112
+ 'To use the Symfony Datacollector, the Bus "%s" needs to implement "%s" ' ,
113
+ $ messageBus ,
114
+ NamedMessageBus::class
115
+ ));
111
116
}
112
117
113
118
$ this ->listenerHandlers [] = $ messageBus ->attach (MessageBus::EVENT_DISPATCH , function (ActionEvent $ actionEvent ) {
@@ -142,11 +147,11 @@ public function attachToMessageBus(MessageBus $messageBus): void
142
147
$ this ->data ['message_callstack ' ][$ actionEvent ->getTarget ()->busName ()][] = [
143
148
'id ' => $ actionEvent ->getParam ('message ' )->uuid (),
144
149
'message ' => $ actionEvent ->getParam ('message-name ' ),
145
- 'handler ' => \is_object ($ actionEvent ->getParam ('message-handler ' )) ? get_class ($ actionEvent ->getParam ('message-handler ' )) : (string ) $ actionEvent ->getParam ('message-handler ' ),
150
+ 'handler ' => is_object ($ actionEvent ->getParam ('message-handler ' ))
151
+ ? get_class ($ actionEvent ->getParam ('message-handler ' ))
152
+ : (string ) $ actionEvent ->getParam ('message-handler ' ),
146
153
];
147
154
}
148
-
149
- $ context = $ this ->createContextFromActionEvent ($ actionEvent );
150
155
}, MessageBus::PRIORITY_ROUTE - 50000 );
151
156
}
152
157
@@ -166,7 +171,9 @@ protected function createContextFromActionEvent(ActionEvent $event): array
166
171
'message-data ' => $ event ->getParam ('message ' )->toArray (),
167
172
'message-name ' => $ event ->getParam ('message-name ' ),
168
173
'message-handled ' => $ event ->getParam ('message-handled ' ),
169
- 'message-handler ' => \is_object ($ event ->getParam ('message-handler ' )) ? get_class ($ event ->getParam ('message-handler ' )) : $ event ->getParam ('message-handler ' ),
174
+ 'message-handler ' => is_object ($ event ->getParam ('message-handler ' ))
175
+ ? get_class ($ event ->getParam ('message-handler ' ))
176
+ : $ event ->getParam ('message-handler ' ),
170
177
];
171
178
}
172
179
0 commit comments