8000 [Translation] added LoggingTranslator. by aitboudad · Pull Request #10887 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Translation] added LoggingTranslator. #10887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Prev Previous commit
Next Next commit
Use LoggableTranslator only if the translator implements TranslatorIn…
…terface and TranslatorBagInterface.
  • Loading branch information
aitboudad committed Sep 24, 2014
commit 8af5171a5f8c2ee9d78cab00ac8540e5aa15c948
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ public function process(ContainerBuilder $container)
}

if ($container->getParameter('translator.logging')) {
$container->getDefinition('translator.loggable')->setDecoratedService('translator');
$translatorAlias = $container->getAlias('translator');
$definition = $container->getDefinition((string) $translatorAlias);
$class = $container->getParameterBag()->resolveValue($definition->getClass());

$refClass = new \ReflectionClass($class);
if ($refClass->implementsInterface('Symfony\Component\Translation\TranslatorInterface') && $refClass->implementsInterface('Symfony\Component\Translation\TranslatorBagInterface')) {
$container->getDefinition('translator.loggable')->setDecoratedService('translator');
}
}
}
}
0