From b6eb1f4979db346ffe9fe7f6a5f335323f0c7175 Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Tue, 28 May 2019 17:53:22 -0400 Subject: [PATCH] Removed capability to load/debug/update legacy translation directories --- .../Command/TranslationDebugCommand.php | 48 ------------------- .../Command/TranslationUpdateCommand.php | 38 --------------- .../FrameworkExtension.php | 17 ------- .../Command/TranslationDebugCommandTest.php | 17 ------- .../Command/TranslationUpdateCommandTest.php | 17 ------- .../translations/test_default.en.xlf | 0 .../FrameworkExtensionTest.php | 15 ------ .../TranslationDebugPass.php | 21 -------- .../Bundle/TestBundle/TestBundle.php | 2 - 9 files changed, 175 deletions(-) delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/Resources/translations/test_default.en.xlf delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/DependencyInjection/TranslationDebugPass.php diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php index 86280c1cc8..7fdd1dbca2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php @@ -132,28 +132,13 @@ EOF $domain = $input->getOption('domain'); /** @var KernelInterface $kernel */ $kernel = $this->getApplication()->getKernel(); - $rootDir = $kernel->getContainer()->getParameter('kernel.root_dir'); // Define Root Paths $transPaths = $this->transPaths; - if (is_dir($dir = $rootDir.'/Resources/translations')) { - if ($dir !== $this->defaultTransPath) { - $notice = sprintf('Storing translations in the "%s" directory is deprecated since Symfony 4.2, ', $dir); - @trigger_error($notice.($this->defaultTransPath ? sprintf('use the "%s" directory instead.', $this->defaultTransPath) : 'configure and use "framework.translator.default_path" instead.'), E_USER_DEPRECATED); - } - $transPaths[] = $dir; - } if ($this->defaultTransPath) { $transPaths[] = $this->defaultTransPath; } $viewsPaths = $this->viewsPaths; - if (is_dir($dir = $rootDir.'/Resources/views')) { - if ($dir !== $this->defaultViewsPath) { - $notice = sprintf('Loading Twig templates from the "%s" directory is deprecated since Symfony 4.2, ', $dir); - @trigger_error($notice.($this->defaultViewsPath ? sprintf('use the "%s" directory instead.', $this->defaultViewsPath) : 'configure and use "twig.default_path" instead.'), E_USER_DEPRECATED); - } - $viewsPaths[] = $dir; - } if ($this->defaultViewsPath) { $viewsPaths[] = $this->defaultViewsPath; } @@ -166,39 +151,16 @@ EOF if ($this->defaultTransPath) { $transPaths[] = $this->defaultTransPath; } - if (is_dir($dir = sprintf('%s/Resources/%s/translations', $rootDir, $bundle->getName()))) { - $transPaths[] = $dir; - $notice = sprintf('Storing translations files for "%s" in the "%s" directory is deprecated since Symfony 4.2, ', $dir, $bundle->getName()); - @trigger_error($notice.($this->defaultTransPath ? sprintf('use the "%s" directory instead.', $this->defaultTransPath) : 'configure and use "framework.translator.default_path" instead.'), E_USER_DEPRECATED); - } $viewsPaths = [$bundle->getPath().'/Resources/views']; if ($this->defaultViewsPath) { $viewsPaths[] = $this->defaultViewsPath; } - if (is_dir($dir = sprintf('%s/Resources/%s/views', $rootDir, $bundle->getName()))) { - $viewsPaths[] = $dir; - $notice = sprintf('Loading Twig templates for "%s" from the "%s" directory is deprecated since Symfony 4.2, ', $bundle->getName(), $dir); - @trigger_error($notice.($this->defaultViewsPath ? sprintf('use the "%s" directory instead.', $this->defaultViewsPath) : 'configure and use "twig.default_path" instead.'), E_USER_DEPRECATED); - } } catch (\InvalidArgumentException $e) { // such a bundle does not exist, so treat the argument as path $path = $input->getArgument('bundle'); $transPaths = [$path.'/translations']; - if (is_dir($dir = $path.'/Resources/translations')) { - if ($dir !== $this->defaultTransPath) { - @trigger_error(sprintf('Storing translations in the "%s" directory is deprecated since Symfony 4.2, use the "%s" directory instead.', $dir, $path.'/translations'), E_USER_DEPRECATED); - } - $transPaths[] = $dir; - } - $viewsPaths = [$path.'/templates']; - if (is_dir($dir = $path.'/Resources/views')) { - if ($dir !== $this->defaultViewsPath) { - @trigger_error(sprintf('Loading Twig templates from the "%s" directory is deprecated since Symfony 4.2, use the "%s" directory instead.', $dir, $path.'/templates'), E_USER_DEPRECATED); - } - $viewsPaths[] = $dir; - } if (!is_dir($transPaths[0]) && !isset($transPaths[1])) { throw new InvalidArgumentException(sprintf('"%s" is neither an enabled bundle nor a directory.', $transPaths[0])); @@ -207,17 +169,7 @@ EOF } elseif ($input->getOption('all')) { foreach ($kernel->getBundles() as $bundle) { $transPaths[] = $bundle->getPath().'/Resources/translations'; - if (is_dir($deprecatedPath = sprintf('%s/Resources/%s/translations', $rootDir, $bundle->getName()))) { - $transPaths[] = $deprecatedPath; - $notice = sprintf('Storing translations files for "%s" in the "%s" directory is deprecated since Symfony 4.2, ', $bundle->getName(), $deprecatedPath); - @trigger_error($notice.($this->defaultTransPath ? sprintf('use the "%s" directory instead.', $this->defaultTransPath) : 'configure and use "framework.translator.default_path" instead.'), E_USER_DEPRECATED); - } $viewsPaths[] = $bundle->getPath().'/Resources/views'; - if (is_dir($deprecatedPath = sprintf('%s/Resources/%s/views', $rootDir, $bundle->getName()))) { - $viewsPaths[] = $deprecatedPath; - $notice = sprintf('Loading Twig templates for "%s" from the "%s" directory is deprecated since Symfony 4.2, ', $bundle->getName(), $deprecatedPath); - @trigger_error($notice.($this->defaultViewsPath ? sprintf('use the "%s" directory instead.', $this->defaultViewsPath) : 'configure and use "twig.default_path" instead.'), E_USER_DEPRECATED); - } } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php index ded71fd60e..6e6b991f64 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php @@ -123,28 +123,13 @@ EOF } /** @var KernelInterface $kernel */ $kernel = $this->getApplication()->getKernel(); - $rootDir = $kernel->getContainer()->getParameter('kernel.root_dir'); // Define Root Paths $transPaths = $this->transPaths; - if (is_dir($dir = $rootDir.'/Resources/translations')) { - if ($dir !== $this->defaultTransPath) { - $notice = sprintf('Storing translations in the "%s" directory is deprecated since Symfony 4.2, ', $dir); - @trigger_error($notice.($this->defaultTransPath ? sprintf('use the "%s" directory instead.', $this->defaultTransPath) : 'configure and use "framework.translator.default_path" instead.'), E_USER_DEPRECATED); - } - $transPaths[] = $dir; - } if ($this->defaultTransPath) { $transPaths[] = $this->defaultTransPath; } $viewsPaths = $this->viewsPaths; - if (is_dir($dir = $rootDir.'/Resources/views')) { - if ($dir !== $this->defaultViewsPath) { - $notice = sprintf('Storing templates in the "%s" directory is deprecated since Symfony 4.2, ', $dir); - @trigger_error($notice.($this->defaultViewsPath ? sprintf('use the "%s" directory instead.', $this->defaultViewsPath) : 'configure and use "twig.default_path" instead.'), E_USER_DEPRECATED); - } - $viewsPaths[] = $dir; - } if ($this->defaultViewsPath) { $viewsPaths[] = $this->defaultViewsPath; } @@ -158,40 +143,17 @@ EOF if ($this->defaultTransPath) { $transPaths[] = $this->defaultTransPath; } - if (is_dir($dir = sprintf('%s/Resources/%s/translations', $rootDir, $foundBundle->getName()))) { - $transPaths[] = $dir; - $notice = sprintf('Storing translations files for "%s" in the "%s" directory is deprecated since Symfony 4.2, ', $foundBundle->getName(), $dir); - @trigger_error($notice.($this->defaultTransPath ? sprintf('use the "%s" directory instead.', $this->defaultTransPath) : 'configure and use "framework.translator.default_path" instead.'), E_USER_DEPRECATED); - } $viewsPaths = [$foundBundle->getPath().'/Resources/views']; if ($this->defaultViewsPath) { $viewsPaths[] = $this->defaultViewsPath; } - if (is_dir($dir = sprintf('%s/Resources/%s/views', $rootDir, $foundBundle->getName()))) { - $viewsPaths[] = $dir; - $notice = sprintf('Storing templates for "%s" in the "%s" directory is deprecated since Symfony 4.2, ', $foundBundle->getName(), $dir); - @trigger_error($notice.($this->defaultViewsPath ? sprintf('use the "%s" directory instead.', $this->defaultViewsPath) : 'configure and use "twig.default_path" instead.'), E_USER_DEPRECATED); - } $currentName = $foundBundle->getName(); } catch (\InvalidArgumentException $e) { // such a bundle does not exist, so treat the argument as path $path = $input->getArgument('bundle'); $transPaths = [$path.'/translations']; - if (is_dir($dir = $path.'/Resources/translations')) { - if ($dir !== $this->defaultTransPath) { - @trigger_error(sprintf('Storing translations in the "%s" directory is deprecated since Symfony 4.2, use the "%s" directory instead.', $dir, $path.'/translations'), E_USER_DEPRECATED); - } - $transPaths[] = $dir; - } - $viewsPaths = [$path.'/templates']; - if (is_dir($dir = $path.'/Resources/views')) { - if ($dir !== $this->defaultViewsPath) { - @trigger_error(sprintf('Storing templates in the "%s" directory is deprecated since Symfony 4.2, use the "%s" directory instead.', $dir, $path.'/templates'), E_USER_DEPRECATED); - } - $viewsPaths[] = $dir; - } if (!is_dir($transPaths[0]) && !isset($transPaths[1])) { throw new InvalidArgumentException(sprintf('"%s" is neither an enabled bundle nor a directory.', $transPaths[0])); diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index a1d03e7280..4598ed9532 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -1116,19 +1116,12 @@ class FrameworkExtension extends Extension $dirs[] = $transPaths[] = \dirname(\dirname($r->getFileName())).'/Resources/translations'; } $defaultDir = $container->getParameterBag()->resolveValue($config['default_path']); - $rootDir = $container->getParameter('kernel.root_dir'); foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) { if (\is_dir($dir = $bundle['path'].'/Resources/translations')) { $dirs[] = $dir; } else { $nonExistingDirs[] = $dir; } - if (\is_dir($dir = $rootDir.sprintf('/Resources/%s/translations', $name))) { - @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) { @@ -1153,16 +1146,6 @@ class FrameworkExtension extends Extension $nonExistingDirs[] = $defaultDir; } - if (\is_dir($dir = $rootDir.'/Resources/translations')) { - if ($dir !== $defaultDir) { - @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; - } - // Register translation resources if ($dirs) { $files = []; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php index 7253215c55..22158daf0f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php @@ -65,23 +65,6 @@ class TranslationDebugCommandTest extends TestCase $this->assertRegExp('/unused/', $tester->getDisplay()); } - /** - * @group legacy - * @expectedDeprecation Storing translations in the "%ssf_translation%s/Resources/translations" directory is deprecated since Symfony 4.2, use the "%ssf_translation%s/translations" directory instead. - * @expectedDeprecation Loading Twig templates from the "%ssf_translation%s/Resources/views" directory is deprecated since Symfony 4.2, use the "%ssf_translation%s/templates" directory instead. - */ - public function testDebugLegacyDefaultDirectory() - { - $this->fs->mkdir($this->translationDir.'/Resources/translations'); - $this->fs->mkdir($this->translationDir.'/Resources/views'); - - $tester = $this->createCommandTester(['foo' => 'foo'], ['bar' => 'bar']); - $tester->execute(['locale' => 'en']); - - $this->assertRegExp('/missing/', $tester->getDisplay()); - $this->assertRegExp('/unused/', $tester->getDisplay()); - } - public function testDebugDefaultRootDirectory() { $this->fs->remove($this->translationDir); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php index 1ec04fd970..65a4d801c5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php @@ -81,23 +81,6 @@ class TranslationUpdateCommandTest extends TestCase $this->assertRegExp('/Translation files were successfully updated./', $tester->getDisplay()); } - /** - * @group legacy - * @expectedDeprecation Storing translations in the "%ssf_translation%s/Resources/translations" directory is deprecated since Symfony 4.2, use the "%ssf_translation%s/translations" directory instead. - * @expectedDeprecation Storing templates in the "%ssf_translation%s/Resources/views" directory is deprecated since Symfony 4.2, use the "%ssf_translation%s/templates" directory instead. - */ - public function testWriteMessagesInLegacyRootDirectory() - { - $this->fs->remove($this->translationDir); - $this->translationDir = sys_get_temp_dir().'/'.uniqid('sf_translation', true); - $this->fs->mkdir($this->translationDir.'/Resources/translations'); - $this->fs->mkdir($this->translationDir.'/Resources/views'); - - $tester = $this->createCommandTester(['messages' => ['foo' => 'foo']]); - $tester->execute(['command' => 'translation:update', 'locale' => 'en', '--force' => true]); - $this->assertRegExp('/Translation files were successfully updated./', $tester->getDisplay()); - } - public function testWriteMessagesForSpecificDomain() { $tester = $this->createCommandTester(['messages' => ['foo' => 'foo'], 'mydomain' => ['bar' => 'bar']]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/Resources/translations/test_default.en.xlf b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/Resources/translations/test_default.en.xlf deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index 25b7353523..322bcd1305 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -56,7 +56,6 @@ use Symfony\Component\Translation\TranslatorInterface; use Symfony\Component\Validator\DependencyInjection\AddConstraintValidatorsPass; use Symfony\Component\Validator\Mapping\Loader\PropertyInfoLoader; use Symfony\Component\Validator\Util\LegacyTranslatorProxy; -use Symfony\Component\Validator\Validation; use Symfony\Component\Workflow; abstract class FrameworkExtensionTest extends TestCase @@ -842,20 +841,6 @@ abstract class FrameworkExtensionTest extends TestCase } } - /** - * @group legacy - * @expectedDeprecation Translations directory "%s/Resources/translations" is deprecated since Symfony 4.2, use "%s/translations" instead. - */ - public function testLegacyTranslationsDirectory() - { - $container = $this->createContainerFromFile('full', ['kernel.root_dir' => __DIR__.'/Fixtures']); - $options = $container->getDefinition('translator.default')->getArgument(4); - $files = array_map('realpath', $options['resource_files']['en']); - - $dir = str_replace('/', \DIRECTORY_SEPARATOR, __DIR__.'/Fixtures/Resources/translations/test_default.en.xlf'); - $this->assertContains($dir, $files, '->registerTranslatorConfiguration() finds translation resources in legacy directory'); - } - public function testTranslatorMultipleFallbacks() { $container = $this->createContainerFromFile('translator_fallbacks'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/DependencyInjection/TranslationDebugPass.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/DependencyInjection/TranslationDebugPass.php deleted file mode 100644 index b8b53c2504..0000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/DependencyInjection/TranslationDebugPass.php +++ /dev/null @@ -1,21 +0,0 @@ -hasDefinition('console.command.translation_debug')) { - // skipping the /Resources/views path deprecation - $container->getDefinition('console.command.translation_debug') - ->setArgument(4, '%kernel.project_dir%/Resources/views'); - } - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/TestBundle.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/TestBundle.php index d90041213c..83dd4dc781 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/TestBundle.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/TestBundle.php @@ -13,7 +13,6 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle; use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\DependencyInjection\AnnotationReaderPass; use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\DependencyInjection\Config\CustomConfig; -use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\DependencyInjection\TranslationDebugPass; use Symfony\Component\DependencyInjection\Compiler\PassConfig; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -30,6 +29,5 @@ class TestBundle extends Bundle $extension->setCustomConfig(new CustomConfig()); $container->addCompilerPass(new AnnotationReaderPass(), PassConfig::TYPE_AFTER_REMOVING); - $container->addCompilerPass(new TranslationDebugPass()); } }