16
16
use Symfony \Component \DependencyInjection \Compiler \CompilerPassInterface ;
17
17
use Symfony \Component \DependencyInjection \Compiler \ServiceLocatorTagPass ;
18
18
use Symfony \Component \DependencyInjection \ContainerBuilder ;
19
+ use Symfony \Component \DependencyInjection \Definition ;
19
20
use Symfony \Component \DependencyInjection \Exception \InvalidArgumentException ;
20
21
use Symfony \Component \DependencyInjection \Exception \RuntimeException ;
21
22
use Symfony \Component \DependencyInjection \Reference ;
29
30
*/
30
31
class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface
31
32
{
32
- private $ connections ;
33
- private $ eventManagers ;
34
- private $ managerTemplate ;
35
- private $ tagPrefix ;
33
+ private string $ connectionsParameter ;
34
+ private array $ connections ;
35
+
36
+ /**
37
+ * @var array<string, Definition>
38
+ */
39
+ private array $ eventManagers = [];
40
+
41
+ private string $ managerTemplate ;
42
+ private string $ tagPrefix ;
36
43
37
44
/**
38
- * @param string $connections Parameter ID for connections
39
45
* @param string $managerTemplate sprintf() template for generating the event
40
46
* manager's service ID for a connection name
41
47
* @param string $tagPrefix Tag prefix for listeners and subscribers
42
48
*/
43
- public function __construct (string $ connections , string $ managerTemplate , string $ tagPrefix )
49
+ public function __construct (string $ connectionsParameter , string $ managerTemplate , string $ tagPrefix )
44
50
{
45
- $ this ->connections = $ connections ;
51
+ $ this ->connectionsParameter = $ connectionsParameter ;
46
52
$ this ->managerTemplate = $ managerTemplate ;
47
53
$ this ->tagPrefix = $ tagPrefix ;
48
54
}
@@ -52,11 +58,11 @@ public function __construct(string $connections, string $managerTemplate, string
52
58
*/
53
59
public function process (ContainerBuilder $ container )
54
60
{
55
- if (!$ container ->hasParameter ($ this ->connections )) {
61
+ if (!$ container ->hasParameter ($ this ->connectionsParameter )) {
56
62
return ;
57
63
}
58
64
59
- $ this ->connections = $ container ->getParameter ($ this ->connections );
65
+ $ this ->connections = $ container ->getParameter ($ this ->connectionsParameter );
60
66
$ listenerRefs = $ this ->addTaggedServices ($ container );
61
67
62
68
// replace service container argument of event managers with smaller service locator
0 commit comments