Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 74c951f

Browse filesBrowse files
committed
[FrameworkBundle][Translation] Move translation compiler pass
1 parent 30e817a commit 74c951f
Copy full SHA for 74c951f

18 files changed

+444
-83
lines changed

‎UPGRADE-3.4.md

Copy file name to clipboardExpand all lines: UPGRADE-3.4.md
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@ FrameworkBundle
3838
will be removed in 4.0. Use the `--prefix` option with an empty string as value
3939
instead (e.g. `--prefix=""`)
4040

41+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslationDumperPass`
42+
class has been deprecated and will be removed in 4.0. Use the
43+
`Symfony\Component\Translation\DependencyInjection\TranslationDumperPass` class instead.
44+
45+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslationExtractorPass`
46+
class has been deprecated and will be removed in 4.0. Use the
47+
`Symfony\Component\Translation\DependencyInjection\TranslationExtractorPass` class instead.
48+
49+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslatorPass`
50+
class has been deprecated and will be removed in 4.0. Use the
51+
`Symfony\Component\Translation\DependencyInjection\TranslatorPass` class instead.
52+
4153
Process
4254
-------
4355

‎UPGRADE-4.0.md

Copy file name to clipboardExpand all lines: UPGRADE-4.0.md
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,18 @@ FrameworkBundle
348348
* The `--no-prefix` option of the `translation:update` command has
349349
been removed.
350350

351+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslationDumperPass`
352+
class has been removed. Use the
353+
`Symfony\Component\Translation\DependencyInjection\TranslationDumperPass` class instead.
354+
355+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslationExtractorPass`
356+
class has been removed. Use the
357+
`Symfony\Component\Translation\DependencyInjection\TranslationExtractorPass` class instead.
358+
359+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslatorPass`
360+
class has been removed. Use the
361+
`Symfony\Component\Translation\DependencyInjection\TranslatorPass` class instead.
362+
351363
HttpFoundation
352364
--------------
353365

‎src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ CHANGELOG
1010
require symfony/stopwatch` in your `dev` environment.
1111
* Deprecated using the `KERNEL_DIR` environment variable with `KernelTestCase::getKernelClass()`.
1212
* Deprecated the `KernelTestCase::getPhpUnitXmlDir()` and `KernelTestCase::getPhpUnitCliConfigArgument()` methods.
13+
* Deprecated `TranslationDumperPass`, use
14+
`Symfony\Component\Translation\DependencyInjection\TranslationDumperPass` instead
15+
* Deprecated `TranslationExtractorPass`, use
16+
`Symfony\Component\Translation\DependencyInjection\TranslationExtractorPass` instead
17+
* Deprecated `TranslatorPass`, use
18+
`Symfony\Component\Translation\DependencyInjection\TranslatorPass` instead
1319

1420
3.3.0
1521
-----

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TranslationDumperPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TranslationDumperPass.php
+6-16Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,15 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
1313

14-
use Symfony\Component\DependencyInjection\Reference;
15-
use Symfony\Component\DependencyInjection\ContainerBuilder;
16-
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
14+
@trigger_error(sprintf('The %s class is deprecated since version 3.4 and will be removed in 4.0. Use Symfony\Component\Translation\DependencyInjection\TranslationDumperPass instead.', TranslationDumperPass::class), E_USER_DEPRECATED);
15+
16+
use Symfony\Component\Translation\DependencyInjection\TranslationDumperPass as BaseTranslationDumperPass;
1717

1818
/**
1919
* Adds tagged translation.formatter services to translation writer.
20+
*
21+
* @deprecated since version 3.4, to be removed in 4.0. Use {@link BaseTranslationDumperPass instead}.
2022
*/
21-
class TranslationDumperPass implements CompilerPassInterface
23+
class TranslationDumperPass extends BaseTranslationDumperPass
2224
{
23-
public function process(ContainerBuilder $container)
24-
{
25-
if (!$container->hasDefinition('translation.writer')) {
26-
return;
27-
}
28-
29-
$definition = $container->getDefinition('translation.writer');
30-
31-
foreach ($container->findTaggedServiceIds('translation.dumper', true) as $id => $attributes) {
32-
$definition->addMethodCall('addDumper', array($attributes[0]['alias'], new Reference($id)));
33-
}
34-
}
3525
}

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TranslationExtractorPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TranslationExtractorPass.php
+7-22Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,15 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
1313

14-
use Symfony\Component\DependencyInjection\Reference;
15-
use Symfony\Component\DependencyInjection\ContainerBuilder;
16-
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
17-
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
14+
@trigger_error(sprintf('The %s class is deprecated since version 3.4 and will be removed in 4.0. Use Symfony\Component\Translation\DependencyInjection\TranslationExtractorPass instead.', TranslationExtractorPass::class), E_USER_DEPRECATED);
15+
16+
use Symfony\Component\Translation\DependencyInjection\TranslationExtractorPass as BaseTranslationExtractorPass;
1817

1918
/**
20-
* Adds tagged translation.extractor services to translation extractor.
19+
* Adds tagged translation.formatter services to translation writer.
20+
*
21+
* @deprecated since version 3.4, to be removed in 4.0. Use {@link BaseTranslationDumperPass instead}.
2122
*/
22-
class TranslationExtractorPass implements CompilerPassInterface
23+
class TranslationExtractorPass extends BaseTranslationExtractorPass
2324
{
24-
public function process(ContainerBuilder $container)
25-
{
26-
if (!$container->hasDefinition('translation.extractor')) {
27-
return;
28-
}
29-
30-
$definition = $container->getDefinition('translation.extractor');
31-
32-
foreach ($container->findTaggedServiceIds('translation.extractor', true) as $id => $attributes) {
33-
if (!isset($attributes[0]['alias'])) {
34-
throw new RuntimeException(sprintf('The alias for the tag "translation.extractor" of service "%s" must be set.', $id));
35-
}
36-
37-
$definition->addMethodCall('addExtractor', array($attributes[0]['alias'], new Reference($id)));
38-
}
39-
}
4025
}

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TranslatorPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TranslatorPass.php
+9-36Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,15 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
1313

14-
use Symfony\Component\DependencyInjection\Reference;
15-
use Symfony\Component\DependencyInjection\ContainerBuilder;
16-
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
17-
use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass;
14+
@trigger_error(sprintf('The %s class is deprecated since version 3.4 and will be removed in 4.0. Use Symfony\Component\Translation\DependencyInjection\TranslatorPass instead.', TranslatorPass::class), E_USER_DEPRECATED);
1815

19-
class TranslatorPass implements CompilerPassInterface
20-
{
21-
public function process(ContainerBuilder $container)
22-
{
23-
if (!$container->hasDefinition('translator.default')) {
24-
return;
25-
}
26-
27-
$loaders = array();
28-
$loaderRefs = array();
29-
foreach ($container->findTaggedServiceIds('translation.loader', true) as $id => $attributes) {
30-
$loaderRefs[$id] = new Reference($id);
31-
$loaders[$id][] = $attributes[0]['alias'];
32-
if (isset($attributes[0]['legacy-alias'])) {
33-
$loaders[$id][] = $attributes[0]['legacy-alias'];
34-
}
35-
}
36-
37-
if ($container->hasDefinition('translation.loader')) {
38-
$definition = $container->getDefinition('translation.loader');
39-
foreach ($loaders as $id => $formats) {
40-
foreach ($formats as $format) {
41-
$definition->addMethodCall('addLoader', array($format, $loaderRefs[$id]));
42-
}
43-
}
44-
}
16+
use Symfony\Component\Translation\DependencyInjection\TranslatorPass as BaseTranslatorPass;
4517

46-
$container
47-
->findDefinition('translator.default')
48-
->replaceArgument(0, ServiceLocatorTagPass::register($container, $loaderRefs))
49-
->replaceArgument(3, $loaders)
50-
;
51-
}
18+
/**
19+
* Adds tagged translation.formatter services to translation writer.
20+
*
21+
* @deprecated since version 3.4, to be removed in 4.0. Use {@link BaseTranslatorPass instead}.
22+
*/
23+
class TranslatorPass extends BaseTranslatorPass
24+
{
5225
}

‎src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,11 @@
1919
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\DataCollectorTranslatorPass;
2020
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TemplatingPass;
2121
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ProfilerPass;
22-
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslatorPass;
2322
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\LoggingTranslatorPass;
2423
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheWarmerPass;
2524
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheClearerPass;
2625
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddExpressionLanguageProvidersPass;
2726
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ContainerBuilderDebugDumpPass;
28-
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslationExtractorPass;
29-
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslationDumperPass;
3027
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\UnusedTagsPass;
3128
use Symfony\Component\Config\DependencyInjection\ConfigCachePass;
3229
use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass;
@@ -45,6 +42,9 @@
4542
use Symfony\Component\HttpFoundation\Request;
4643
use Symfony\Component\HttpKernel\Bundle\Bundle;
4744
use Symfony\Component\Config\Resource\ClassExistenceResource;
45+
use Symfony\Component\Translation\DependencyInjection\TranslationDumperPass;
46+
use Symfony\Component\Translation\DependencyInjection\TranslationExtractorPass;
47+
use Symfony\Component\Translation\DependencyInjection\TranslatorPass;
4848
use Symfony\Component\Validator\DependencyInjection\AddConstraintValidatorsPass;
4949
use Symfony\Component\Validator\DependencyInjection\AddValidatorInitializersPass;
5050
use Symfony\Component\Workflow\DependencyInjection\ValidateWorkflowsPass;
@@ -93,13 +93,13 @@ public function build(ContainerBuilder $container)
9393
$container->addCompilerPass(new AddAnnotationsCachedReaderPass(), PassConfig::TYPE_BEFORE_REMOVING);
9494
$this->addCompilerPassIfExists($container, AddValidatorInitializersPass::class);
9595
$this->addCompilerPassIfExists($container, AddConsoleCommandPass::class);
96-
$container->addCompilerPass(new TranslatorPass());
96+
$this->addCompilerPassIfExists($container, TranslatorPass::class);
9797
$container->addCompilerPass(new LoggingTranslatorPass());
9898
$container->addCompilerPass(new AddCacheWarmerPass());
9999
$container->addCompilerPass(new AddCacheClearerPass());
100100
$container->addCompilerPass(new AddExpressionLanguageProvidersPass());
101-
$container->addCompilerPass(new TranslationExtractorPass());
102-
$container->addCompilerPass(new TranslationDumperPass());
101+
$this->addCompilerPassIfExists($container, TranslationExtractorPass::class);
102+
$this->addCompilerPassIfExists($container, TranslationDumperPass::class);
103103
$container->addCompilerPass(new FragmentRendererPass(), PassConfig::TYPE_AFTER_REMOVING);
104104
$this->addCompilerPassIfExists($container, SerializerPass::class);
105105
$this->addCompilerPassIfExists($container, PropertyInfoPass::class);

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/TranslatorPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/TranslatorPassTest.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
use Symfony\Component\DependencyInjection\Definition;
1919
use Symfony\Component\DependencyInjection\Reference;
2020

21+
/**
22+
* @group legacy
23+
*/
2124
class TranslatorPassTest extends TestCase
2225
{
2326
public function testValidCollector()

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection;
1313

1414
use Doctrine\Common\Annotations\Annotation;
15-
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslatorPass;
1615
use Symfony\Bundle\FullStack;
1716
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
1817
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddAnnotationsCachedReaderPass;
@@ -41,6 +40,7 @@
4140
use Symfony\Component\Serializer\Normalizer\DataUriNormalizer;
4241
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
4342
use Symfony\Component\Serializer\Normalizer\JsonSerializableNormalizer;
43+
use Symfony\Component\Translation\DependencyInjection\TranslatorPass;
4444
use Symfony\Component\Validator\DependencyInjection\AddConstraintValidatorsPass;
4545

4646
abstract class FrameworkExtensionTest extends TestCase

‎src/Symfony/Bundle/FrameworkBundle/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/composer.json
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"symfony/security-csrf": "~2.8|~3.0|~4.0",
4848
"symfony/serializer": "~3.3|~4.0",
4949
"symfony/stopwatch": "~2.8|~3.0|~4.0",
50-
"symfony/translation": "~3.2|~4.0",
50+
"symfony/translation": "~3.4|~4.0",
5151
"symfony/templating": "~2.8|~3.0|~4.0",
5252
"symfony/validator": "~3.4|~4.0",
5353
"symfony/var-dumper": "~3.3|~4.0",
@@ -68,7 +68,7 @@
6868
"symfony/form": "<3.3",
6969
"symfony/property-info": "<3.3",
7070
"symfony/serializer": "<3.3",
71-
"symfony/translation": "<3.2",
71+
"symfony/translation": "<3.4",
7272
"symfony/validator": "<3.4",
7373
"symfony/workflow": "<3.3"
7474
},

‎src/Symfony/Component/Translation/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Translation/CHANGELOG.md
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
CHANGELOG
22
=========
33

4+
3.4.0
5+
-----
6+
7+
* Added `TranslationDumperPass`
8+
* Added `TranslationExtractorPass`
9+
* Added `TranslatorPass`
10+
411
3.2.0
512
-----
613

+44Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Translation\DependencyInjection;
13+
14+
use Symfony\Component\DependencyInjection\Reference;
15+
use Symfony\Component\DependencyInjection\ContainerBuilder;
16+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
17+
18+
/**
19+
* Adds tagged translation.formatter services to translation writer.
20+
*/
21+
class TranslationDumperPass implements CompilerPassInterface
22+
{
23+
private $writerServiceId;
24+
private $dumperTag;
25+
26+
public function __construct($writerServiceId = 'translation.writer', $dumperTag = 'translation.dumper')
27+
{
28+
$this->writerServiceId = $writerServiceId;
29+
$this->dumperTag = $dumperTag;
30+
}
31+
32+
public function process(ContainerBuilder $container)
33+
{
34+
if (!$container->hasDefinition($this->writerServiceId)) {
35+
return;
36+
}
37+
38+
$definition = $container->getDefinition($this->writerServiceId);
39+
40+
foreach ($container->findTaggedServiceIds($this->dumperTag, true) as $id => $attributes) {
41+
$definition->addMethodCall('addDumper', array($attributes[0]['alias'], new Reference($id)));
42+
}
43+
}
44+
}
+49Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Translation\DependencyInjection;
13+
14+
use Symfony\Component\DependencyInjection\Reference;
15+
use Symfony\Component\DependencyInjection\ContainerBuilder;
16+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
17+
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
18+
19+
/**
20+
* Adds tagged translation.extractor services to translation extractor.
21+
*/
22+
class TranslationExtractorPass implements CompilerPassInterface
23+
{
24+
private $extractorServiceId;
25+
private $extractorTag;
26+
27+
public function __construct($extractorServiceId = 'translation.extractor', $extractorTag = 'translation.extractor')
28+
{
29+
$this->extractorServiceId = $extractorServiceId;
30+
$this->extractorTag = $extractorTag;
31+
}
32+
33+
public function process(ContainerBuilder $container)
34+
{
35+
if (!$container->hasDefinition($this->extractorServiceId)) {
36+
return;
37+
}
38+
39+
$definition = $container->getDefinition($this->extractorServiceId);
40+
41+
foreach ($container->findTaggedServiceIds($this->extractorTag, true) as $id => $attributes) {
42+
if (!isset($attributes[0]['alias'])) {
43+
throw new RuntimeException(sprintf('The alias for the tag "translation.extractor" of service "%s" must be set.', $id));
44+
}
45+
46+
$definition->addMethodCall('addExtractor', array($attributes[0]['alias'], new Reference($id)));
47+
}
48+
}
49+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.