blob: 4020a078895b4bf6cebc2c3862d787782e37edaa [file] [log] [blame]
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +02001<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Translation\DependencyInjection;
13
14use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15use Symfony\Component\DependencyInjection\ContainerBuilder;
16use Symfony\Component\DependencyInjection\Reference;
17
18/**
19 * Adds tagged translation.formatter services to translation writer.
20 */
21class TranslationDumperPass implements CompilerPassInterface
22{
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020023 public function process(ContainerBuilder $container)
24 {
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010025 if (!$container->hasDefinition('translation.writer')) {
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020026 return;
27 }
28
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010029 $definition = $container->getDefinition('translation.writer');
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020030
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010031 foreach ($container->findTaggedServiceIds('translation.dumper', true) as $id => $attributes) {
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020032 $definition->addMethodCall('addDumper', [$attributes[0]['alias'], new Reference($id)]);
33 }
34 }
35}