compatibility with Security component split

The FrameworkBundle in version 2.3 can be used with recent versions of
the Security component. However, after the Security component has been
split with Symfony 2.4, translations resources have been moved to the
`symfony/security-core` package. Thus, the changed location must be
taken into account.
This commit is contained in:
Christian Flothmann 2015-10-05 23:04:03 +02:00
parent 136722c9b0
commit 7bc836cc72
1 changed files with 10 additions and 1 deletions

View File

@ -553,7 +553,16 @@ class FrameworkExtension extends Extension
if (class_exists('Symfony\Component\Security\Core\Exception\AuthenticationException')) {
$r = new \ReflectionClass('Symfony\Component\Security\Core\Exception\AuthenticationException');
$dirs[] = dirname($r->getFilename()).'/../../Resources/translations';
$legacyTranslationsDir = dirname($r->getFilename()).'/../../Resources/translations';
if (file_exists($legacyTranslationsDir)) {
// in Symfony 2.3, translations are located in the symfony/security package
$dirs[] = $legacyTranslationsDir;
} else {
// with Symfony 2.4, the Security component was split into several subpackages
// and the translations have been moved to the symfony/security-core package
$dirs[] = dirname($r->getFilename()).'/../Resources/translations';
}
}
$overridePath = $container->getParameter('kernel.root_dir').'/Resources/%s/translations';
foreach ($container->getParameter('kernel.bundles') as $bundle => $class) {