added compiler pass to register TypeConverter implementations in ConverterRepository

This commit is contained in:
Christian Kerl 2011-08-24 18:11:29 +02:00 committed by Francis Besset
parent 5d8d7b4ad5
commit f62a8bdd67
2 changed files with 38 additions and 0 deletions

View File

@ -11,6 +11,7 @@
namespace BeSimple\SoapBundle; namespace BeSimple\SoapBundle;
use BeSimple\SoapBundle\DependencyInjection\Compiler\WebServiceResolverPass; use BeSimple\SoapBundle\DependencyInjection\Compiler\WebServiceResolverPass;
use BeSimple\SoapBundle\DependencyInjection\Compiler\TypeConverterPass;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle; use Symfony\Component\HttpKernel\Bundle\Bundle;
@ -27,5 +28,6 @@ class BeSimpleSoapBundle extends Bundle
parent::build($container); parent::build($container);
$container->addCompilerPass(new WebServiceResolverPass()); $container->addCompilerPass(new WebServiceResolverPass());
$container->addCompilerPass(new TypeConverterPass());
} }
} }

View File

@ -0,0 +1,36 @@
<?php
/*
* This file is part of the BeSimpleSoapBundle.
*
* (c) Christian Kerl <christian-kerl@web.de>
*
* 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 <christian-kerl@web.de>
*/
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)));
}
}
}