File tree 2 files changed +24
-4
lines changed
src/Symfony/Component/DependencyInjection
2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -42,10 +42,12 @@ public function process(ContainerBuilder $container)
42
42
$ public = $ alias ->isPublic ();
43
43
$ container ->setAlias ($ renamedId , new Alias ((string ) $ alias , false ));
44
44
} else {
45
- $ definition = $ container ->getDefinition ($ inner );
46
- $ public = $ definition ->isPublic ();
47
- $ definition ->setPublic (false );
48
- $ container ->setDefinition ($ renamedId , $ definition );
45
+ $ decoratedDefinition = $ container ->getDefinition ($ inner );
46
+ $ definition ->setTags ($ decoratedDefinition ->getTags (), $ definition ->getTags ());
47
+ $ public = $ decoratedDefinition ->isPublic ();
48
+ $ decoratedDefinition ->setPublic (false );
49
+ $ decoratedDefinition ->setTags (array ());
50
+ $ container ->setDefinition ($ renamedId , $ decoratedDefinition );
49
51
}
50
52
51
53
$ container ->setAlias ($ inner , new Alias ($ id , $ public ));
Original file line number Diff line number Diff line change @@ -82,6 +82,24 @@ public function testProcessWithAlias()
82
82
$ this ->assertNull ($ fooExtendedDefinition ->getDecoratedService ());
83
83
}
84
84
85
+ public function testProcessMovesTagsFromDecoratedDefinitionToDecoratingDefinition ()
86
+ {
87
+ $ container = new ContainerBuilder ();
88
+ $ container
89
+ ->register ('foo ' )
90
+ ->setTags (array ('name ' => 'bar ' ))
91
+ ;
92
+ $ container
93
+ ->register ('baz ' )
94
+ ->setDecoratedService ('foo ' )
95
+ ;
96
+
97
+ $ this ->process ($ container );
98
+
99
+ $ this ->assertEmpty ($ container ->getDefinition ('baz.inner ' )->getTags ());
100
+ $ this ->assertEquals (array ('name ' => 'bar ' ), $ container ->getDefinition ('baz ' )->getTags ());
101
+ }
102
+
85
103
protected function process (ContainerBuilder $ container )
86
104
{
87
105
$ repeatedPass = new DecoratorServicePass ();
You can’t perform that action at this time.
0 commit comments