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

Skip to content

Commit 828570d

Browse files
committed
feature #20070 [FrameworkBundle] removed the Translation component dependency on FrameworkBundle (fabpot)
This PR was merged into the 3.2-dev branch. Discussion ---------- [FrameworkBundle] removed the Translation component dependency on FrameworkBundle | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no (except for people using FrameworkBundle without requiring symfony/symfony which should be pretty rare; and fixing this is easy by adding symfony/translation explicitly) | Deprecations? | no | Tests pass? | yes | Fixed tickets | #15748 partially | License | MIT | Doc PR | n/a Another PR to reduce the number of required dependencies on FrameworkBundle. This PR removes the Translation component from the list. Commits ------- a496a2a [FrameworkBundle] removed the Translation component dependency on FrameworkBundle
2 parents 6acf54f + a496a2a commit 828570d

File tree

9 files changed

+55
-14
lines changed

9 files changed

+55
-14
lines changed

UPGRADE-3.2.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ UPGRADE FROM 3.1 to 3.2
44
FrameworkBundle
55
---------------
66

7+
* The `symfony/translation` dependency has been removed; require it via `composer
8+
require symfony/translation` if you depend on it and don't already depend on
9+
`symfony/symfony`
710
* The `symfony/asset` dependency has been removed; require it via `composer
811
require symfony/asset` if you depend on it and don't already depend on
912
`symfony/symfony`

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CHANGELOG
44
3.2.0
55
-----
66

7+
* Removed `symfony/translation` from the list of required dependencies in `composer.json`
78
* Removed `symfony/asset` from the list of required dependencies in `composer.json`
89
* The `Resources/public/images/*` files have been removed.
910
* The `Resources/public/css/*.css` files have been removed (they are now inlined in TwigBundle).

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,18 @@ protected function configure()
8484
;
8585
}
8686

87+
/**
88+
* {@inheritdoc}
89+
*/
90+
public function isEnabled()
91+
{
92+
if (!class_exists('Symfony\Component\Translation\Translator')) {
93+
return false;
94+
}
95+
96+
return parent::isEnabled();
97+
}
98+
8799
/**
88100
* {@inheritdoc}
89101
*/

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,18 @@ protected function configure()
6666
;
6767
}
6868

69+
/**
70+
* {@inheritdoc}
71+
*/
72+
public function isEnabled()
73+
{
74+
if (!class_exists('Symfony\Component\Translation\Translator')) {
75+
return false;
76+
}
77+
78+
return parent::isEnabled();
79+
}
80+
6981
/**
7082
* {@inheritdoc}
7183
*/

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

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,6 @@ public function load(array $configs, ContainerBuilder $container)
7070
$loader->load('services.xml');
7171
$loader->load('fragment_renderer.xml');
7272

73-
// A translator must always be registered (as support is included by
74-
// default in the Form component). If disabled, an identity translator
75-
// will be used and everything will still work as expected.
76-
$loader->load('translation.xml');
77-
7873
// Property access is used by both the Form and the Validator component
7974
$loader->load('property_access.xml');
8075

@@ -84,6 +79,17 @@ public function load(array $configs, ContainerBuilder $container)
8479
$configuration = $this->getConfiguration($configs, $container);
8580
$config = $this->processConfiguration($configuration, $configs);
8681

82+
// A translator must always be registered (as support is included by
83+
// default in the Form component). If disabled, an identity translator
84+
// will be used and everything will still work as expected.
85+
if (class_exists('Symfony\Component\Translation\Translator') || $this->isConfigEnabled($container, $config['form'])) {
86+
if (!class_exists('Symfony\Component\Translation\Translator')) {
87+
throw new LogicException('Form support cannot be enabled as the Translation component is not installed.');
88+
}
89+
90+
$loader->load('translation.xml');
91+
}
92+
8793
if (isset($config['secret'])) {
8894
$container->setParameter('kernel.secret', $config['secret']);
8995
}
@@ -762,6 +768,11 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
762768
if (!$this->isConfigEnabled($container, $config)) {
763769
return;
764770
}
771+
772+
if (!class_exists('Symfony\Component\Translation\Translator')) {
773+
throw new LogicException('Translation support cannot be enabled as the Translator component is not installed.');
774+
}
775+
765776
$this->translationConfigEnabled = true;
766777

767778
// Use the "real" translator instead of the identity default

src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ public function build(ContainerBuilder $container)
8585
$container->addCompilerPass(new AddCacheWarmerPass());
8686
$container->addCompilerPass(new AddCacheClearerPass());
8787
$container->addCompilerPass(new AddExpressionLanguageProvidersPass());
88-
$container->addCompilerPass(new TranslationExtractorPass());
89-
$container->addCompilerPass(new TranslationDumperPass());
88+
if (class_exists('Symfony\Component\Translation\Translator')) {
89+
$container->addCompilerPass(new TranslationExtractorPass());
90+
$container->addCompilerPass(new TranslationDumperPass());
91+
}
9092
$container->addCompilerPass(new FragmentRendererPass(), PassConfig::TYPE_AFTER_REMOVING);
9193
$container->addCompilerPass(new SerializerPass());
9294
$container->addCompilerPass(new PropertyInfoPass());

src/Symfony/Bundle/FrameworkBundle/Resources/config/translation.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,5 +131,11 @@
131131
<argument type="service" id="translator" />
132132
<tag name="kernel.cache_warmer" />
133133
</service>
134+
135+
<service id="translator_listener" class="Symfony\Component\HttpKernel\EventListener\TranslatorListener">
136+
<argument type="service" id="translator" />
137+
<argument type="service" id="request_stack" />
138+
<tag name="kernel.event_subscriber" />
139+
</service>
134140
</services>
135141
</container>

src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,6 @@
5656
<argument type="service" id="router" on-invalid="ignore" />
5757
</service>
5858

59-
<service id="translator_listener" class="Symfony\Component\HttpKernel\EventListener\TranslatorListener">
60-
<argument type="service" id="translator" />
61-
<argument type="service" id="request_stack" />
62-
<tag name="kernel.event_subscriber" />
63-
</service>
64-
6559
<service id="validate_request_listener" class="Symfony\Component\HttpKernel\EventListener\ValidateRequestListener">
6660
<tag name="kernel.event_subscriber" />
6761
</service>

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"symfony/security-csrf": "~2.8|~3.0",
3333
"symfony/stopwatch": "~2.8|~3.0",
3434
"symfony/templating": "~2.8|~3.0",
35-
"symfony/translation": "~2.8|~3.0",
3635
"doctrine/cache": "~1.0",
3736
"doctrine/annotations": "~1.0"
3837
},
@@ -48,6 +47,7 @@
4847
"symfony/expression-language": "~2.8|~3.0",
4948
"symfony/process": "~2.8|~3.0",
5049
"symfony/serializer": "~2.8|~3.0",
50+
"symfony/translation": "~2.8|~3.0",
5151
"symfony/validator": "~3.2",
5252
"symfony/yaml": "~3.2",
5353
"symfony/property-info": "~2.8|~3.0",

0 commit comments

Comments
 (0)