skip compiler pass if interface doesn't exist

The FrameworkBundle doesn't depend on the `symfony/translation`
component and therefore does not enforce a high enough version of this
package. Thus, with `symfony/translation` versions before `2.6`, the
`translator` service does exist, but the `TranslatorBagInterface` is
not present.
This commit is contained in:
Christian Flothmann 2014-12-17 21:06:22 +01:00
parent c18cb4c7b2
commit beff6fa3e6

View File

@ -25,6 +25,11 @@ class LoggingTranslatorPass implements CompilerPassInterface
return;
}
// skip if the symfony/translation version is lower than 2.6
if (!interface_exists('Symfony\Component\Translation\TranslatorBagInterface')) {
return;
}
if ($container->getParameter('translator.logging')) {
$translatorAlias = $container->getAlias('translator');
$definition = $container->getDefinition((string) $translatorAlias);