Chris@14: Chris@14: * Chris@14: * For the full copyright and license information, please view the LICENSE Chris@14: * file that was distributed with this source code. Chris@14: */ Chris@14: Chris@14: namespace Symfony\Component\Translation\DependencyInjection; Chris@14: Chris@17: use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; Chris@17: use Symfony\Component\DependencyInjection\ContainerBuilder; Chris@14: use Symfony\Component\DependencyInjection\Reference; Chris@14: Chris@14: /** Chris@14: * Adds tagged translation.formatter services to translation writer. Chris@14: */ Chris@14: class TranslationDumperPass implements CompilerPassInterface Chris@14: { Chris@14: private $writerServiceId; Chris@14: private $dumperTag; Chris@14: Chris@14: public function __construct($writerServiceId = 'translation.writer', $dumperTag = 'translation.dumper') Chris@14: { Chris@14: $this->writerServiceId = $writerServiceId; Chris@14: $this->dumperTag = $dumperTag; Chris@14: } Chris@14: Chris@14: public function process(ContainerBuilder $container) Chris@14: { Chris@14: if (!$container->hasDefinition($this->writerServiceId)) { Chris@14: return; Chris@14: } Chris@14: Chris@14: $definition = $container->getDefinition($this->writerServiceId); Chris@14: Chris@14: foreach ($container->findTaggedServiceIds($this->dumperTag, true) as $id => $attributes) { Chris@17: $definition->addMethodCall('addDumper', [$attributes[0]['alias'], new Reference($id)]); Chris@14: } Chris@14: } Chris@14: }