TranslationDumperPass.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Translation\DependencyInjection;
  11. use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
  12. use Symfony\Component\DependencyInjection\ContainerBuilder;
  13. use Symfony\Component\DependencyInjection\Reference;
  14. /**
  15. * Adds tagged translation.formatter services to translation writer.
  16. */
  17. class TranslationDumperPass implements CompilerPassInterface
  18. {
  19. /**
  20. * @return void
  21. */
  22. public function process(ContainerBuilder $container)
  23. {
  24. if (!$container->hasDefinition('translation.writer')) {
  25. return;
  26. }
  27. $definition = $container->getDefinition('translation.writer');
  28. foreach ($container->findTaggedServiceIds('translation.dumper', true) as $id => $attributes) {
  29. $definition->addMethodCall('addDumper', [$attributes[0]['alias'], new Reference($id)]);
  30. }
  31. }
  32. }