File tree Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Expand file tree Collapse file tree 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)
4242 $ public = $ alias ->isPublic ();
4343 $ container ->setAlias ($ renamedId , new Alias ((string ) $ alias , false ));
4444 } 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 );
4951 }
5052
5153 $ container ->setAlias ($ inner , new Alias ($ id , $ public ));
Original file line number Diff line number Diff line change @@ -82,6 +82,24 @@ public function testProcessWithAlias()
8282 $ this ->assertNull ($ fooExtendedDefinition ->getDecoratedService ());
8383 }
8484
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+
85103 protected function process (ContainerBuilder $ container )
86104 {
87105 $ repeatedPass = new DecoratorServicePass ();
You can’t perform that action at this time.
0 commit comments