16
16
17
17
use Symfony \Component \Config \Definition \Processor ;
18
18
use Symfony \Component \Config \FileLocator ;
19
+ use Symfony \Component \DependencyInjection \ChildDefinition ;
19
20
use Symfony \Component \DependencyInjection \ContainerBuilder ;
21
+ use Symfony \Component \DependencyInjection \Definition ;
20
22
use Symfony \Component \DependencyInjection \DefinitionDecorator ;
21
23
use Symfony \Component \DependencyInjection \Reference ;
22
24
use Symfony \Component \DependencyInjection \Loader \XmlFileLoader ;
@@ -83,7 +85,9 @@ private function registerClientConfiguration(array $config, ContainerBuilder $co
83
85
$ loader ->load ('client.xml ' );
84
86
85
87
foreach ($ config as $ client => $ options ) {
86
- $ definition = new DefinitionDecorator ('besimple.soap.client.builder ' );
88
+ $ childDefinitionClass = $ this ->getChildDefinitionClass ();
89
+ /** @var ChildDefinition $definition */
90
+ $ definition = new $ childDefinitionClass ('besimple.soap.client.builder ' );
87
91
$ container ->setDefinition (sprintf ('besimple.soap.client.builder.%s ' , $ client ), $ definition );
88
92
89
93
$ definition ->replaceArgument (0 , $ options ['wsdl ' ]);
@@ -130,7 +134,9 @@ private function registerClientConfiguration(array $config, ContainerBuilder $co
130
134
131
135
private function createClientClassmap ($ client , array $ classmap , ContainerBuilder $ container )
132
136
{
133
- $ definition = new DefinitionDecorator ('besimple.soap.classmap ' );
137
+ $ childDefinitionClass = $ this ->getChildDefinitionClass ();
138
+ /** @var Definition $definition */
139
+ $ definition = new $ childDefinitionClass ('besimple.soap.classmap ' );
134
140
$ container ->setDefinition (sprintf ('besimple.soap.classmap.%s ' , $ client ), $ definition );
135
141
136
142
if (!empty ($ classmap )) {
@@ -144,13 +150,12 @@ private function createClientClassmap($client, array $classmap, ContainerBuilder
144
150
145
151
private function createClient ($ client , ContainerBuilder $ container )
146
152
{
147
- $ definition = new DefinitionDecorator ('besimple.soap.client ' );
153
+ $ childDefinitionClass = $ this ->getChildDefinitionClass ();
154
+ /** @var Definition $definition */
155
+ $ definition = new $ childDefinitionClass ('besimple.soap.client ' );
148
156
$ container ->setDefinition (sprintf ('besimple.soap.client.%s ' , $ client ), $ definition );
149
157
150
- $ definition ->setFactory (array (
151
- new Reference (sprintf ('besimple.soap.client.builder.%s ' , $ client )),
152
- 'build '
153
- ));
158
+ $ definition ->setFactory ([new Reference (sprintf ('besimple.soap.client.builder.%s ' , $ client )), 'build ' ]);
154
159
}
155
160
156
161
private function createWebServiceContext (array $ config , ContainerBuilder $ container )
@@ -159,7 +164,9 @@ private function createWebServiceContext(array $config, ContainerBuilder $contai
159
164
unset($ config ['binding ' ]);
160
165
161
166
$ contextId = 'besimple.soap.context. ' .$ config ['name ' ];
162
- $ definition = new DefinitionDecorator ('besimple.soap.context. ' .$ bindingSuffix );
167
+ $ childDefinitionClass = $ this ->getChildDefinitionClass ();
168
+ /** @var Definition $definition */
169
+ $ definition = new $ childDefinitionClass ('besimple.soap.context. ' .$ bindingSuffix );
163
170
$ container ->setDefinition ($ contextId , $ definition );
164
171
165
172
if (isset ($ config ['cache_type ' ])) {
@@ -189,4 +196,9 @@ private function getCacheType($type)
189
196
return Cache::TYPE_DISK_MEMORY ;
190
197
}
191
198
}
199
+
200
+ private function getChildDefinitionClass ()
201
+ {
202
+ return (class_exists (ChildDefinition::class)) ? ChildDefinition::class : DefinitionDecorator::class;
203
+ }
192
204
}
0 commit comments