Skip to content

Commit 60617c6

Browse files
committed
replace definition cloning with ChildDefinition
1 parent 536fc5d commit 60617c6

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

DependencyInjection/HttplugExtension.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
use Http\Message\Authentication\Wsse;
1717
use Psr\Http\Message\UriInterface;
1818
use Symfony\Component\Config\FileLocator;
19+
use Symfony\Component\DependencyInjection\ChildDefinition;
1920
use Symfony\Component\DependencyInjection\ContainerBuilder;
2021
use Symfony\Component\DependencyInjection\ContainerInterface;
2122
use Symfony\Component\DependencyInjection\Definition;
23+
use Symfony\Component\DependencyInjection\DefinitionDecorator;
2224
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
2325
use Symfony\Component\DependencyInjection\Reference;
2426
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
@@ -271,8 +273,12 @@ private function configureClient(ContainerBuilder $container, $clientName, array
271273
$plugins = array_merge($plugins, $this->configureAuthentication($container, $pluginConfig, $serviceId.'.authentication'));
272274
} else {
273275
$pluginServiceId = $serviceId.'.plugin.'.$pluginName;
274-
$definition = clone $container->getDefinition('httplug.plugin'.'.'.$pluginName);
275-
$definition->setAbstract(false);
276+
277+
$definition = class_exists(ChildDefinition::class)
278+
? new ChildDefinition('httplug.plugin'.'.'.$pluginName)
279+
: new DefinitionDecorator('httplug.plugin'.'.'.$pluginName)
280+
;
281+
276282
$this->configurePluginByName($pluginName, $definition, $pluginConfig, $container, $pluginServiceId);
277283
$container->setDefinition($pluginServiceId, $definition);
278284
$plugins[] = $pluginServiceId;
@@ -301,8 +307,11 @@ private function configureClient(ContainerBuilder $container, $clientName, array
301307
}
302308

303309
// Add the newstack plugin
304-
$definition = clone $container->getDefinition('httplug.plugin.stack');
305-
$definition->setAbstract(false);
310+
$definition = class_exists(ChildDefinition::class)
311+
? new ChildDefinition('httplug.plugin.stack')
312+
: new DefinitionDecorator('httplug.plugin.stack')
313+
;
314+
306315
$definition->addArgument($clientName);
307316
$container->setDefinition($serviceId.'.plugin.newstack', $definition);
308317
array_unshift($plugins, $serviceId.'.plugin.newstack');

0 commit comments

Comments
 (0)