@@ -46,29 +46,38 @@ public function process(ContainerBuilder $container)
46
46
return ;
47
47
}
48
48
49
- $ collectorDefinition = $ container ->getDefinition ($ this ->dataCollectorCacheId );
50
49
foreach ($ container ->findTaggedServiceIds ($ this ->cachePoolTag ) as $ id => $ attributes ) {
51
- $ definition = $ container ->getDefinition ($ id );
52
- if ($ definition ->isAbstract ()) {
53
- continue ;
54
- }
50
+ $ this ->addToCollector ($ id , $ container );
55
51
56
- $ recorder = new Definition (is_subclass_of ($ definition ->getClass (), TagAwareAdapterInterface::class) ? TraceableTagAwareAdapter::class : TraceableAdapter::class);
57
- $ recorder ->setTags ($ definition ->getTags ());
58
- if (!$ definition ->isPublic () || !$ definition ->isPrivate ()) {
59
- $ recorder ->setPublic ($ definition ->isPublic ());
52
+ if (($ attributes [0 ]['name ' ] ?? $ id ) !== $ id ) {
53
+ $ this ->addToCollector ($ attributes [0 ]['name ' ], $ container );
60
54
}
61
- $ recorder ->setArguments ([new Reference ($ innerId = $ id .$ this ->cachePoolRecorderInnerSuffix )]);
62
-
63
- $ definition ->setTags ([]);
64
- $ definition ->setPublic (false );
55
+ }
56
+ }
65
57
66
- $ container ->setDefinition ($ innerId , $ definition );
67
- $ container ->setDefinition ($ id , $ recorder );
58
+ private function addToCollector (string $ id , ContainerBuilder $ container )
59
+ {
60
+ $ definition = $ container ->getDefinition ($ id );
61
+ if ($ definition ->isAbstract ()) {
62
+ return ;
63
+ }
68
64
69
- // Tell the collector to add the new instance
70
- $ collectorDefinition ->addMethodCall ('addInstance ' , [$ id , new Reference ($ id )]);
71
- $ collectorDefinition ->setPublic (false );
65
+ $ collectorDefinition = $ container ->getDefinition ($ this ->dataCollectorCacheId );
66
+ $ recorder = new Definition (is_subclass_of ($ definition ->getClass (), TagAwareAdapterInterface::class) ? TraceableTagAwareAdapter::class : TraceableAdapter::class);
67
+ $ recorder ->setTags ($ definition ->getTags ());
68
+ if (!$ definition ->isPublic () || !$ definition ->isPrivate ()) {
69
+ $ recorder ->setPublic ($ definition ->isPublic ());
72
70
}
71
+ $ recorder ->setArguments ([new Reference ($ innerId = $ id .$ this ->cachePoolRecorderInnerSuffix )]);
72
+
73
+ $ definition ->setTags ([]);
74
+ $ definition ->setPublic (false );
75
+
76
+ $ container ->setDefinition ($ innerId , $ definition );
77
+ $ container ->setDefinition ($ id , $ recorder );
78
+
79
+ // Tell the collector to add the new instance
80
+ $ collectorDefinition ->addMethodCall ('addInstance ' , [$ id , new Reference ($ id )]);
81
+ $ collectorDefinition ->setPublic (false );
73
82
}
74
83
}
0 commit comments