Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[FrameworkBundle] removed the Translation component dependency on FrameworkBundle#20070

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletionsUPGRADE-3.2.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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`
Expand Down
1 change: 1 addition & 0 deletionssrc/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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).
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -84,6 +84,18 @@ protected function configure()
;
}

/**
* {@inheritdoc}
*/
public function isEnabled()
{
if (!class_exists('Symfony\Component\Translation\Translator')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

You can use::class notation here

return false;
}

return parent::isEnabled();
}

/**
* {@inheritdoc}
*/
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,6 +66,18 @@ protected function configure()
;
}

/**
* {@inheritdoc}
*/
public function isEnabled()
{
if (!class_exists('Symfony\Component\Translation\Translator')) {
return false;
}

return parent::isEnabled();
}

/**
* {@inheritdoc}
*/
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -70,11 +70,6 @@ public function load(array $configs, ContainerBuilder $container)
$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');

Expand All@@ -84,6 +79,17 @@ public function load(array $configs, ContainerBuilder $container)
$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']);
}
Expand DownExpand Up@@ -762,6 +768,11 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
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
Expand Down
6 changes: 4 additions & 2 deletionssrc/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -85,8 +85,10 @@ public function build(ContainerBuilder $container)
$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')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

all other compiler passes are always registered, and return early when the service does not exist (accounting for disabling by configuration too). Shouldn't it be done here too ?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

And for those as well. It was more about not even registering them if the translation component is not installed. But that's probably not really needed as this is for build only. I'm going to revert this change.

$container->addCompilerPass(new TranslationExtractorPass());
$container->addCompilerPass(new TranslationDumperPass());
}
$container->addCompilerPass(new FragmentRendererPass(), PassConfig::TYPE_AFTER_REMOVING);
$container->addCompilerPass(new SerializerPass());
$container->addCompilerPass(new PropertyInfoPass());
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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>
Expand Down
2 changes: 1 addition & 1 deletionsrc/Symfony/Bundle/FrameworkBundle/composer.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
},
Expand All@@ -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",
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp