Removed capability to load/debug/update legacy translation directories
This commit is contained in:
parent
9cc2a4ecd1
commit
b6eb1f4979
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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]));
|
||||
|
@ -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 = [];
|
||||
|
@ -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);
|
||||
|
@ -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']]);
|
||||
|
@ -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');
|
||||
|
@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
|
||||
/**
|
||||
* Remove in Symfony 5.0 when the templates directory deprecation is gone.
|
||||
*/
|
||||
class TranslationDebugPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
if ($container->hasDefinition('console.command.translation_debug')) {
|
||||
// skipping the /Resources/views path deprecation
|
||||
$container->getDefinition('console.command.translation_debug')
|
||||
->setArgument(4, '%kernel.project_dir%/Resources/views');
|
||||
}
|
||||
}
|
||||
}
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user