From f62a8bdd67f3c526e8a9e141c2ecc4bfbff8dfe5 Mon Sep 17 00:00:00 2001 From: Christian Kerl Date: Wed, 24 Aug 2011 18:11:29 +0200 Subject: [PATCH] added compiler pass to register TypeConverter implementations in ConverterRepository --- BeSimpleSoapBundle.php | 2 ++ .../Compiler/TypeConverterPass.php | 36 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 DependencyInjection/Compiler/TypeConverterPass.php diff --git a/BeSimpleSoapBundle.php b/BeSimpleSoapBundle.php index e6c692d..06797a8 100644 --- a/BeSimpleSoapBundle.php +++ b/BeSimpleSoapBundle.php @@ -11,6 +11,7 @@ namespace BeSimple\SoapBundle; use BeSimple\SoapBundle\DependencyInjection\Compiler\WebServiceResolverPass; +use BeSimple\SoapBundle\DependencyInjection\Compiler\TypeConverterPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -27,5 +28,6 @@ class BeSimpleSoapBundle extends Bundle parent::build($container); $container->addCompilerPass(new WebServiceResolverPass()); + $container->addCompilerPass(new TypeConverterPass()); } } diff --git a/DependencyInjection/Compiler/TypeConverterPass.php b/DependencyInjection/Compiler/TypeConverterPass.php new file mode 100644 index 0000000..be97bb6 --- /dev/null +++ b/DependencyInjection/Compiler/TypeConverterPass.php @@ -0,0 +1,36 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace BeSimple\SoapBundle\DependencyInjection\Compiler; + +use Symfony\Component\DependencyInjection\Reference; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; + +/** + * Adds tagged besimple.soap.converter services to besimple.soap.converter.repository service + * + * @author Christian Kerl + */ +class TypeConverterPass implements CompilerPassInterface +{ + public function process(ContainerBuilder $container) + { + if (false === $container->hasDefinition('besimple.soap.converter.repository')) { + return; + } + + $definition = $container->getDefinition('besimple.soap.converter.repository'); + + foreach ($container->findTaggedServiceIds('besimple.soap.converter') as $id => $attributes) { + $definition->addMethodCall('addTypeConverter', array(new Reference($id))); + } + } +}