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