13
13
class ManagerRegistry extends AbstractManagerRegistry
14
14
{
15
15
16
- /** @var Container */
17
- private $ container ;
16
+ private Container $ container ;
18
17
19
18
public function __construct (Connection $ connection , EntityManagerInterface $ em , Container $ container )
20
19
{
21
- $ defaultConnection = $ container ->findByType (get_class ( $ connection) )[0 ];
22
- $ defaultManager = $ container ->findByType (get_class ( $ em) )[0 ];
20
+ $ defaultConnection = $ container ->findByType ($ connection::class )[0 ];
21
+ $ defaultManager = $ container ->findByType ($ em::class )[0 ];
23
22
24
23
$ connections = ['default ' => $ defaultConnection ];
25
24
$ managers = ['default ' => $ defaultManager ];
26
25
27
26
parent ::__construct ('ORM ' , $ connections , $ managers , 'default ' , 'default ' , Proxy::class);
28
- $ this ->container = $ container ;
29
- }
30
27
31
- /**
32
- * @param string $name
33
- * @return object&ObjectManager
34
- * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
35
- * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint
36
- */
37
- protected function getService ($ name )
38
- {
39
- return $ this ->container ->getService ($ name );
40
- }
41
-
42
- /**
43
- * @param string $name
44
- * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
45
- */
46
- protected function resetService ($ name ): void
47
- {
48
- $ this ->container ->removeService ($ name );
28
+ $ this ->container = $ container ;
49
29
}
50
30
51
31
/**
52
- * @param string $alias
53
32
* @throws ORMException
54
33
* @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
55
34
*/
56
- public function getAliasNamespace ($ alias ): string
35
+ public function getAliasNamespace (string $ alias ): string
57
36
{
58
37
foreach (array_keys ($ this ->getManagers ()) as $ name ) {
59
38
try {
@@ -69,4 +48,22 @@ public function getAliasNamespace($alias): string
69
48
throw new ORMException (sprintf ('Unknown Entity namespace alias "%s" ' , $ alias ));
70
49
}
71
50
51
+ /**
52
+ * @return object&ObjectManager
53
+ * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
54
+ * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint
55
+ */
56
+ protected function getService (string $ name )
57
+ {
58
+ return $ this ->container ->getService ($ name );
59
+ }
60
+
61
+ /**
62
+ * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
63
+ */
64
+ protected function resetService (string $ name ): void
65
+ {
66
+ $ this ->container ->removeService ($ name );
67
+ }
68
+
72
69
}
0 commit comments