25
25
*/
26
26
class RegisterListenersPass implements CompilerPassInterface
27
27
{
28
- protected $ dispatcherService ;
29
- protected $ listenerTag ;
30
- protected $ subscriberTag ;
31
- protected $ eventAliasesParameter ;
32
-
33
28
private $ hotPathEvents = [];
34
29
private $ hotPathTagName ;
35
30
private $ noPreloadEvents = [];
36
31
private $ noPreloadTagName ;
37
32
38
- public function __construct (string $ dispatcherService = 'event_dispatcher ' , string $ listenerTag = 'kernel.event_listener ' , string $ subscriberTag = 'kernel.event_subscriber ' , string $ eventAliasesParameter = 'event_dispatcher.event_aliases ' )
39
- {
40
- if (0 < \func_num_args ()) {
41
- trigger_deprecation ('symfony/event-dispatcher ' , '5.3 ' , 'Configuring "%s" is deprecated. ' , __CLASS__ );
42
- }
43
-
44
- $ this ->dispatcherService = $ dispatcherService ;
45
- $ this ->listenerTag = $ listenerTag ;
46
- $ this ->subscriberTag = $ subscriberTag ;
47
- $ this ->eventAliasesParameter = $ eventAliasesParameter ;
48
- }
49
-
50
33
/**
51
34
* @return $this
52
35
*/
@@ -71,26 +54,26 @@ public function setNoPreloadEvents(array $noPreloadEvents, string $tagName = 'co
71
54
72
55
public function process (ContainerBuilder $ container )
73
56
{
74
- if (!$ container ->hasDefinition ($ this -> dispatcherService ) && !$ container ->hasAlias ($ this -> dispatcherService )) {
57
+ if (!$ container ->hasDefinition (' event_dispatcher ' ) && !$ container ->hasAlias (' event_dispatcher ' )) {
75
58
return ;
76
59
}
77
60
78
61
$ aliases = [];
79
62
80
- if ($ container ->hasParameter ($ this -> eventAliasesParameter )) {
81
- $ aliases = $ container ->getParameter ($ this -> eventAliasesParameter );
63
+ if ($ container ->hasParameter (' event_dispatcher.event_aliases ' )) {
64
+ $ aliases = $ container ->getParameter (' event_dispatcher.event_aliases ' );
82
65
}
83
66
84
- $ globalDispatcherDefinition = $ container ->findDefinition ($ this -> dispatcherService );
67
+ $ globalDispatcherDefinition = $ container ->findDefinition (' event_dispatcher ' );
85
68
86
- foreach ($ container ->findTaggedServiceIds ($ this -> listenerTag , true ) as $ id => $ events ) {
69
+ foreach ($ container ->findTaggedServiceIds (' kernel.event_listener ' , true ) as $ id => $ events ) {
87
70
$ noPreload = 0 ;
88
71
89
72
foreach ($ events as $ event ) {
90
73
$ priority = $ event ['priority ' ] ?? 0 ;
91
74
92
75
if (!isset ($ event ['event ' ])) {
93
- if ($ container ->getDefinition ($ id )->hasTag ($ this -> subscriberTag )) {
76
+ if ($ container ->getDefinition ($ id )->hasTag (' kernel.event_subscriber ' )) {
94
77
continue ;
95
78
}
96
79
@@ -133,7 +116,7 @@ public function process(ContainerBuilder $container)
133
116
134
117
$ extractingDispatcher = new ExtractingEventDispatcher ();
135
118
136
- foreach ($ container ->findTaggedServiceIds ($ this -> subscriberTag , true ) as $ id => $ tags ) {
119
+ foreach ($ container ->findTaggedServiceIds (' kernel.event_subscriber ' , true ) as $ id => $ tags ) {
137
120
$ def = $ container ->getDefinition ($ id );
138
121
139
122
// We must assume that the class value has been correctly filled, even if the service is created by a factory
@@ -195,7 +178,7 @@ private function getEventFromTypeDeclaration(ContainerBuilder $container, string
195
178
|| $ type ->isBuiltin ()
196
179
|| Event::class === ($ name = $ type ->getName ())
197
180
) {
198
- throw new InvalidArgumentException (sprintf ('Service "%s" must define the "event" attribute on "%s " tags. ' , $ id, $ this -> listenerTag ));
181
+ throw new InvalidArgumentException (sprintf ('Service "%s" must define the "event" attribute on "kernel.event_listener " tags. ' , $ id ));
199
182
}
200
183
201
184
return $ name ;
0 commit comments