Skip to content

Commit

Permalink
No longer keep DirectoryResources for translation dirs in container
Browse files Browse the repository at this point in the history
Now that the translator keeps track of its own directories for caching
the container no longer needs to it. This means that when a translation
changes or is added the container no longer needs to be fully rebuilt,
saving a considerable amount of time.
  • Loading branch information
rpkamp committed Dec 16, 2018
1 parent 0656723 commit 28da4d2
Showing 1 changed file with 4 additions and 5 deletions.
Expand Up @@ -1022,29 +1022,28 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
$defaultDir = $container->getParameterBag()->resolveValue($config['default_path']);
$rootDir = $container->getParameter('kernel.root_dir');
foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) {
if ($container->fileExists($dir = $bundle['path'].'/Resources/translations')) {
if ($container->fileExists($dir = $bundle['path'].'/Resources/translations', false)) {
$dirs[] = $dir;
} else {
$nonExistingDirs[] = $dir;
}
if ($container->fileExists($dir = $rootDir.sprintf('/Resources/%s/translations', $name))) {
if ($container->fileExists($dir = $rootDir.sprintf('/Resources/%s/translations', $name), false)) {
@trigger_error(sprintf('Translations directory "%s" is deprecated since Symfony 4.2, use "%s" instead.', $dir, $defaultDir), E_USER_DEPRECATED);

$dirs[] = $dir;
} else {
$nonExistingDirs[] = $dir;
}
}

foreach ($config['paths'] as $dir) {
if ($container->fileExists($dir)) {
if ($container->fileExists($dir, false)) {
$dirs[] = $dir;
} else {
throw new \UnexpectedValueException(sprintf('%s defined in translator.paths does not exist or is not a directory', $dir));
}
}

if ($container->fileExists($defaultDir)) {
if ($container->fileExists($defaultDir, false)) {
$dirs[] = $defaultDir;
} else {
$nonExistingDirs[] = $defaultDir;
Expand Down

0 comments on commit 28da4d2

Please sign in to comment.