[FrameworkBundle] removed the Translation component dependency on FrameworkBundle

This commit is contained in:
Fabien Potencier 2016-09-27 21:49:39 -07:00
parent 6acf54f26b
commit a496a2a1ad
9 changed files with 55 additions and 14 deletions

View File

@ -4,6 +4,9 @@ UPGRADE FROM 3.1 to 3.2
FrameworkBundle
---------------
* The `symfony/translation` dependency has been removed; require it via `composer
require symfony/translation` if you depend on it and don't already depend on
`symfony/symfony`
* The `symfony/asset` dependency has been removed; require it via `composer
require symfony/asset` if you depend on it and don't already depend on
`symfony/symfony`

View File

@ -4,6 +4,7 @@ CHANGELOG
3.2.0
-----
* Removed `symfony/translation` from the list of required dependencies in `composer.json`
* Removed `symfony/asset` from the list of required dependencies in `composer.json`
* The `Resources/public/images/*` files have been removed.
* The `Resources/public/css/*.css` files have been removed (they are now inlined in TwigBundle).

View File

@ -84,6 +84,18 @@ EOF
;
}
/**
* {@inheritdoc}
*/
public function isEnabled()
{
if (!class_exists('Symfony\Component\Translation\Translator')) {
return false;
}
return parent::isEnabled();
}
/**
* {@inheritdoc}
*/

View File

@ -66,6 +66,18 @@ EOF
;
}
/**
* {@inheritdoc}
*/
public function isEnabled()
{
if (!class_exists('Symfony\Component\Translation\Translator')) {
return false;
}
return parent::isEnabled();
}
/**
* {@inheritdoc}
*/

View File

@ -70,11 +70,6 @@ class FrameworkExtension extends Extension
$loader->load('services.xml');
$loader->load('fragment_renderer.xml');
// A translator must always be registered (as support is included by
// default in the Form component). If disabled, an identity translator
// will be used and everything will still work as expected.
$loader->load('translation.xml');
// Property access is used by both the Form and the Validator component
$loader->load('property_access.xml');
@ -84,6 +79,17 @@ class FrameworkExtension extends Extension
$configuration = $this->getConfiguration($configs, $container);
$config = $this->processConfiguration($configuration, $configs);
// A translator must always be registered (as support is included by
// default in the Form component). If disabled, an identity translator
// will be used and everything will still work as expected.
if (class_exists('Symfony\Component\Translation\Translator') || $this->isConfigEnabled($container, $config['form'])) {
if (!class_exists('Symfony\Component\Translation\Translator')) {
throw new LogicException('Form support cannot be enabled as the Translation component is not installed.');
}
$loader->load('translation.xml');
}
if (isset($config['secret'])) {
$container->setParameter('kernel.secret', $config['secret']);
}
@ -762,6 +768,11 @@ class FrameworkExtension extends Extension
if (!$this->isConfigEnabled($container, $config)) {
return;
}
if (!class_exists('Symfony\Component\Translation\Translator')) {
throw new LogicException('Translation support cannot be enabled as the Translator component is not installed.');
}
$this->translationConfigEnabled = true;
// Use the "real" translator instead of the identity default

View File

@ -85,8 +85,10 @@ class FrameworkBundle extends Bundle
$container->addCompilerPass(new AddCacheWarmerPass());
$container->addCompilerPass(new AddCacheClearerPass());
$container->addCompilerPass(new AddExpressionLanguageProvidersPass());
$container->addCompilerPass(new TranslationExtractorPass());
$container->addCompilerPass(new TranslationDumperPass());
if (class_exists('Symfony\Component\Translation\Translator')) {
$container->addCompilerPass(new TranslationExtractorPass());
$container->addCompilerPass(new TranslationDumperPass());
}
$container->addCompilerPass(new FragmentRendererPass(), PassConfig::TYPE_AFTER_REMOVING);
$container->addCompilerPass(new SerializerPass());
$container->addCompilerPass(new PropertyInfoPass());

View File

@ -131,5 +131,11 @@
<argument type="service" id="translator" />
<tag name="kernel.cache_warmer" />
</service>
<service id="translator_listener" class="Symfony\Component\HttpKernel\EventListener\TranslatorListener">
<argument type="service" id="translator" />
<argument type="service" id="request_stack" />
<tag name="kernel.event_subscriber" />
</service>
</services>
</container>

View File

@ -56,12 +56,6 @@
<argument type="service" id="router" on-invalid="ignore" />
</service>
<service id="translator_listener" class="Symfony\Component\HttpKernel\EventListener\TranslatorListener">
<argument type="service" id="translator" />
<argument type="service" id="request_stack" />
<tag name="kernel.event_subscriber" />
</service>
<service id="validate_request_listener" class="Symfony\Component\HttpKernel\EventListener\ValidateRequestListener">
<tag name="kernel.event_subscriber" />
</service>

View File

@ -32,7 +32,6 @@
"symfony/security-csrf": "~2.8|~3.0",
"symfony/stopwatch": "~2.8|~3.0",
"symfony/templating": "~2.8|~3.0",
"symfony/translation": "~2.8|~3.0",
"doctrine/cache": "~1.0",
"doctrine/annotations": "~1.0"
},
@ -48,6 +47,7 @@
"symfony/expression-language": "~2.8|~3.0",
"symfony/process": "~2.8|~3.0",
"symfony/serializer": "~2.8|~3.0",
"symfony/translation": "~2.8|~3.0",
"symfony/validator": "~3.2",
"symfony/yaml": "~3.2",
"symfony/property-info": "~2.8|~3.0",