DataCollectorTranslatorPass.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  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\Bundle\FrameworkBundle\DependencyInjection\Compiler;
  11. use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
  12. use Symfony\Component\DependencyInjection\ContainerBuilder;
  13. /**
  14. * @author Christian Flothmann <christian.flothmann@sensiolabs.de>
  15. */
  16. class DataCollectorTranslatorPass implements CompilerPassInterface
  17. {
  18. public function process(ContainerBuilder $container)
  19. {
  20. if (!$container->has('translator')) {
  21. return;
  22. }
  23. $translatorClass = $container->getParameterBag()->resolveValue($container->findDefinition('translator')->getClass());
  24. if (!is_subclass_of($translatorClass, 'Symfony\Component\Translation\TranslatorBagInterface')) {
  25. $container->removeDefinition('translator.data_collector');
  26. $container->removeDefinition('data_collector.translation');
  27. }
  28. }
  29. }