Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1ae191b

Browse files
committed
Removed capability to load/debug/update legacy translation directories
1 parent 9cc2a4e commit 1ae191b

File tree

9 files changed

+0
-174
lines changed

9 files changed

+0
-174
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -132,28 +132,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
132132
$domain = $input->getOption('domain');
133133
/** @var KernelInterface $kernel */
134134
$kernel = $this->getApplication()->getKernel();
135-
$rootDir = $kernel->getContainer()->getParameter('kernel.root_dir');
136135

137136
// Define Root Paths
138137
$transPaths = $this->transPaths;
139-
if (is_dir($dir = $rootDir.'/Resources/translations')) {
140-
if ($dir !== $this->defaultTransPath) {
141-
$notice = sprintf('Storing translations in the "%s" directory is deprecated since Symfony 4.2, ', $dir);
142-
@trigger_error($notice.($this->defaultTransPath ? sprintf('use the "%s" directory instead.', $this->defaultTransPath) : 'configure and use "framework.translator.default_path" instead.'), E_USER_DEPRECATED);
143-
}
144-
$transPaths[] = $dir;
145-
}
146138
if ($this->defaultTransPath) {
147139
$transPaths[] = $this->defaultTransPath;
148140
}
149141
$viewsPaths = $this->viewsPaths;
150-
if (is_dir($dir = $rootDir.'/Resources/views')) {
151-
if ($dir !== $this->defaultViewsPath) {
152-
$notice = sprintf('Loading Twig templates from the "%s" directory is deprecated since Symfony 4.2, ', $dir);
153-
@trigger_error($notice.($this->defaultViewsPath ? sprintf('use the "%s" directory instead.', $this->defaultViewsPath) : 'configure and use "twig.default_path" instead.'), E_USER_DEPRECATED);
154-
}
155-
$viewsPaths[] = $dir;
156-
}
157142
if ($this->defaultViewsPath) {
158143
$viewsPaths[] = $this->defaultViewsPath;
159144
}
@@ -166,39 +151,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
166151
if ($this->defaultTransPath) {
167152
$transPaths[] = $this->defaultTransPath;
168153
}
169-
if (is_dir($dir = sprintf('%s/Resources/%s/translations', $rootDir, $bundle->getName()))) {
170-
$transPaths[] = $dir;
171-
$notice = sprintf('Storing translations files for "%s" in the "%s" directory is deprecated since Symfony 4.2, ', $dir, $bundle->getName());
172-
@trigger_error($notice.($this->defaultTransPath ? sprintf('use the "%s" directory instead.', $this->defaultTransPath) : 'configure and use "framework.translator.default_path" instead.'), E_USER_DEPRECATED);
173-
}
174154
$viewsPaths = [$bundle->getPath().'/Resources/views'];
175155
if ($this->defaultViewsPath) {
176156
$viewsPaths[] = $this->defaultViewsPath;
177157
}
178-
if (is_dir($dir = sprintf('%s/Resources/%s/views', $rootDir, $bundle->getName()))) {
179-
$viewsPaths[] = $dir;
180-
$notice = sprintf('Loading Twig templates for "%s" from the "%s" directory is deprecated since Symfony 4.2, ', $bundle->getName(), $dir);
181-
@trigger_error($notice.($this->defaultViewsPath ? sprintf('use the "%s" directory instead.', $this->defaultViewsPath) : 'configure and use "twig.default_path" instead.'), E_USER_DEPRECATED);
182-
}
183158
} catch (\InvalidArgumentException $e) {
184159
// such a bundle does not exist, so treat the argument as path
185160
$path = $input->getArgument('bundle');
186161

187162
$transPaths = [$path.'/translations'];
188-
if (is_dir($dir = $path.'/Resources/translations')) {
189-
if ($dir !== $this->defaultTransPath) {
190-
@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);
191-
}
192-
$transPaths[] = $dir;
193-
}
194-
195163
$viewsPaths = [$path.'/templates'];
196-
if (is_dir($dir = $path.'/Resources/views')) {
197-
if ($dir !== $this->defaultViewsPath) {
198-
@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);
199-
}
200-
$viewsPaths[] = $dir;
201-
}
202164

203165
if (!is_dir($transPaths[0]) && !isset($transPaths[1])) {
204166
throw new InvalidArgumentException(sprintf('"%s" is neither an enabled bundle nor a directory.', $transPaths[0]));
@@ -207,17 +169,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
207169
} elseif ($input->getOption('all')) {
208170
foreach ($kernel->getBundles() as $bundle) {
209171
$transPaths[] = $bundle->getPath().'/Resources/translations';
210-
if (is_dir($deprecatedPath = sprintf('%s/Resources/%s/translations', $rootDir, $bundle->getName()))) {
211-
$transPaths[] = $deprecatedPath;
212-
$notice = sprintf('Storing translations files for "%s" in the "%s" directory is deprecated since Symfony 4.2, ', $bundle->getName(), $deprecatedPath);
213-
@trigger_error($notice.($this->defaultTransPath ? sprintf('use the "%s" directory instead.', $this->defaultTransPath) : 'configure and use "framework.translator.default_path" instead.'), E_USER_DEPRECATED);
214-
}
215172
$viewsPaths[] = $bundle->getPath().'/Resources/views';
216-
if (is_dir($deprecatedPath = sprintf('%s/Resources/%s/views', $rootDir, $bundle->getName()))) {
217-
$viewsPaths[] = $deprecatedPath;
218-
$notice = sprintf('Loading Twig templates for "%s" from the "%s" directory is deprecated since Symfony 4.2, ', $bundle->getName(), $deprecatedPath);
219-
@trigger_error($notice.($this->defaultViewsPath ? sprintf('use the "%s" directory instead.', $this->defaultViewsPath) : 'configure and use "twig.default_path" instead.'), E_USER_DEPRECATED);
220-
}
221173
}
222174
}
223175

src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -123,28 +123,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
123123
}
124124
/** @var KernelInterface $kernel */
125125
$kernel = $this->getApplication()->getKernel();
126-
$rootDir = $kernel->getContainer()->getParameter('kernel.root_dir');
127126

128127
// Define Root Paths
129128
$transPaths = $this->transPaths;
130-
if (is_dir($dir = $rootDir.'/Resources/translations')) {
131-
if ($dir !== $this->defaultTransPath) {
132-
$notice = sprintf('Storing translations in the "%s" directory is deprecated since Symfony 4.2, ', $dir);
133-
@trigger_error($notice.($this->defaultTransPath ? sprintf('use the "%s" directory instead.', $this->defaultTransPath) : 'configure and use "framework.translator.default_path" instead.'), E_USER_DEPRECATED);
134-
}
135-
$transPaths[] = $dir;
136-
}
137129
if ($this->defaultTransPath) {
138130
$transPaths[] = $this->defaultTransPath;
139131
}
140132
$viewsPaths = $this->viewsPaths;
141-
if (is_dir($dir = $rootDir.'/Resources/views')) {
142-
if ($dir !== $this->defaultViewsPath) {
143-
$notice = sprintf('Storing templates in the "%s" directory is deprecated since Symfony 4.2, ', $dir);
144-
@trigger_error($notice.($this->defaultViewsPath ? sprintf('use the "%s" directory instead.', $this->defaultViewsPath) : 'configure and use "twig.default_path" instead.'), E_USER_DEPRECATED);
145-
}
146-
$viewsPaths[] = $dir;
147-
}
148133
if ($this->defaultViewsPath) {
149134
$viewsPaths[] = $this->defaultViewsPath;
150135
}
@@ -158,40 +143,17 @@ protected function execute(InputInterface $input, OutputInterface $output)
158143
if ($this->defaultTransPath) {
159144
$transPaths[] = $this->defaultTransPath;
160145
}
161-
if (is_dir($dir = sprintf('%s/Resources/%s/translations', $rootDir, $foundBundle->getName()))) {
162-
$transPaths[] = $dir;
163-
$notice = sprintf('Storing translations files for "%s" in the "%s" directory is deprecated since Symfony 4.2, ', $foundBundle->getName(), $dir);
164-
@trigger_error($notice.($this->defaultTransPath ? sprintf('use the "%s" directory instead.', $this->defaultTransPath) : 'configure and use "framework.translator.default_path" instead.'), E_USER_DEPRECATED);
165-
}
166146
$viewsPaths = [$foundBundle->getPath().'/Resources/views'];
167147
if ($this->defaultViewsPath) {
168148
$viewsPaths[] = $this->defaultViewsPath;
169149
}
170-
if (is_dir($dir = sprintf('%s/Resources/%s/views', $rootDir, $foundBundle->getName()))) {
171-
$viewsPaths[] = $dir;
172-
$notice = sprintf('Storing templates for "%s" in the "%s" directory is deprecated since Symfony 4.2, ', $foundBundle->getName(), $dir);
173-
@trigger_error($notice.($this->defaultViewsPath ? sprintf('use the "%s" directory instead.', $this->defaultViewsPath) : 'configure and use "twig.default_path" instead.'), E_USER_DEPRECATED);
174-
}
175150
$currentName = $foundBundle->getName();
176151
} catch (\InvalidArgumentException $e) {
177152
// such a bundle does not exist, so treat the argument as path
178153
$path = $input->getArgument('bundle');
179154

180155
$transPaths = [$path.'/translations'];
181-
if (is_dir($dir = $path.'/Resources/translations')) {
182-
if ($dir !== $this->defaultTransPath) {
183-
@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);
184-
}
185-
$transPaths[] = $dir;
186-
}
187-
188156
$viewsPaths = [$path.'/templates'];
189-
if (is_dir($dir = $path.'/Resources/views')) {
190-
if ($dir !== $this->defaultViewsPath) {
191-
@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);
192-
}
193-
$viewsPaths[] = $dir;
194-
}
195157

196158
if (!is_dir($transPaths[0]) && !isset($transPaths[1])) {
197159
throw new InvalidArgumentException(sprintf('"%s" is neither an enabled bundle nor a directory.', $transPaths[0]));

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,19 +1116,12 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
11161116
$dirs[] = $transPaths[] = \dirname(\dirname($r->getFileName())).'/Resources/translations';
11171117
}
11181118
$defaultDir = $container->getParameterBag()->resolveValue($config['default_path']);
1119-
$rootDir = $container->getParameter('kernel.root_dir');
11201119
foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) {
11211120
if (\is_dir($dir = $bundle['path'].'/Resources/translations')) {
11221121
$dirs[] = $dir;
11231122
} else {
11241123
$nonExistingDirs[] = $dir;
11251124
}
1126-
if (\is_dir($dir = $rootDir.sprintf('/Resources/%s/translations', $name))) {
1127-
@trigger_error(sprintf('Translations directory "%s" is deprecated since Symfony 4.2, use "%s" instead.', $dir, $defaultDir), E_USER_DEPRECATED);
1128-
$dirs[] = $dir;
1129-
} else {
1130-
$nonExistingDirs[] = $dir;
1131-
}
11321125
}
11331126

11341127
foreach ($config['paths'] as $dir) {
@@ -1153,16 +1146,6 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
11531146
$nonExistingDirs[] = $defaultDir;
11541147
}
11551148

1156-
if (\is_dir($dir = $rootDir.'/Resources/translations')) {
1157-
if ($dir !== $defaultDir) {
1158-
@trigger_error(sprintf('Translations directory "%s" is deprecated since Symfony 4.2, use "%s" instead.', $dir, $defaultDir), E_USER_DEPRECATED);
1159-
}
1160-
1161-
$dirs[] = $dir;
1162-
} else {
1163-
$nonExistingDirs[] = $dir;
1164-
}
1165-
11661149
// Register translation resources
11671150
if ($dirs) {
11681151
$files = [];

src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,6 @@ public function testDebugDefaultDirectory()
6565
$this->assertRegExp('/unused/', $tester->getDisplay());
6666
}
6767

68-
/**
69-
* @group legacy
70-
* @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.
71-
* @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.
72-
*/
73-
public function testDebugLegacyDefaultDirectory()
74-
{
75-
$this->fs->mkdir($this->translationDir.'/Resources/translations');
76-
$this->fs->mkdir($this->translationDir.'/Resources/views');
77-
78-
$tester = $this->createCommandTester(['foo' => 'foo'], ['bar' => 'bar']);
79-
$tester->execute(['locale' => 'en']);
80-
81-
$this->assertRegExp('/missing/', $tester->getDisplay());
82-
$this->assertRegExp('/unused/', $tester->getDisplay());
83-
}
84-
8568
public function testDebugDefaultRootDirectory()
8669
{
8770
$this->fs->remove($this->translationDir);

src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,6 @@ public function testWriteMessagesInRootDirectory()
8181
$this->assertRegExp('/Translation files were successfully updated./', $tester->getDisplay());
8282
}
8383

84-
/**
85-
* @group legacy
86-
* @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.
87-
* @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.
88-
*/
89-
public function testWriteMessagesInLegacyRootDirectory()
90-
{
91-
$this->fs->remove($this->translationDir);
92-
$this->translationDir = sys_get_temp_dir().'/'.uniqid('sf_translation', true);
93-
$this->fs->mkdir($this->translationDir.'/Resources/translations');
94-
$this->fs->mkdir($this->translationDir.'/Resources/views');
95-
96-
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo']]);
97-
$tester->execute(['command' => 'translation:update', 'locale' => 'en', '--force' => true]);
98-
$this->assertRegExp('/Translation files were successfully updated./', $tester->getDisplay());
99-
}
100-
10184
public function testWriteMessagesForSpecificDomain()
10285
{
10386
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo'], 'mydomain' => ['bar' => 'bar']]);

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/Resources/translations/test_default.en.xlf

Whitespace-only changes.

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
use Symfony\Component\Validator\DependencyInjection\AddConstraintValidatorsPass;
5757
use Symfony\Component\Validator\Mapping\Loader\PropertyInfoLoader;
5858
use Symfony\Component\Validator\Util\LegacyTranslatorProxy;
59-
use Symfony\Component\Validator\Validation;
6059
use Symfony\Component\Workflow;
6160

6261
abstract class FrameworkExtensionTest extends TestCase
@@ -842,20 +841,6 @@ function ($directory) {
842841
}
843842
}
844843

845-
/**
846-
* @group legacy
847-
* @expectedDeprecation Translations directory "%s/Resources/translations" is deprecated since Symfony 4.2, use "%s/translations" instead.
848-
*/
849-
public function testLegacyTranslationsDirectory()
850-
{
851-
$container = $this->createContainerFromFile('full', ['kernel.root_dir' => __DIR__.'/Fixtures']);
852-
$options = $container->getDefinition('translator.default')->getArgument(4);
853-
$files = array_map('realpath', $options['resource_files']['en']);
854-
855-
$dir = str_replace('/', \DIRECTORY_SEPARATOR, __DIR__.'/Fixtures/Resources/translations/test_default.en.xlf');
856-
$this->assertContains($dir, $files, '->registerTranslatorConfiguration() finds translation resources in legacy directory');
857-
}
858-
859844
public function testTranslatorMultipleFallbacks()
860845
{
861846
$container = $this->createContainerFromFile('translator_fallbacks');

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/DependencyInjection/TranslationDebugPass.php

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/TestBundle.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,5 @@ public function build(ContainerBuilder $container)
3030
$extension->setCustomConfig(new CustomConfig());
3131

3232
$container->addCompilerPass(new AnnotationReaderPass(), PassConfig::TYPE_AFTER_REMOVING);
33-
$container->addCompilerPass(new TranslationDebugPass());
3433
}
3534
}

0 commit comments

Comments
 (0)