Debian Codegraph @

lib/3rdParty/composer/symfony/translation/DependencyInjection/DataCollectorTranslatorPass.php

raw symbols SCIP
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <[email protected]>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\Translation\DependencyInjection;
13
14 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15 use Symfony\Component\DependencyInjection\ContainerBuilder;
16 use Symfony\Component\Translation\TranslatorBagInterface;
17
18 /**
19 * @author Christian Flothmann <[email protected]>
20 */
21 class DataCollectorTranslatorPass implements CompilerPassInterface
22 {
23 public function process(ContainerBuilder $container): void
24 {
25 if (!$container->has('translator')) {
26 return;
27 }
28
29 $translatorClass = $container->getParameterBag()->resolveValue($container->findDefinition('translator')->getClass());
30
31 if (!is_subclass_of($translatorClass, TranslatorBagInterface::class)) {
32 $container->removeDefinition('translator.data_collector');
33 $container->removeDefinition('data_collector.translation');
34 }
35 }
36 }