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] don't load translator services if not required#20928

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
fabpot merged 1 commit intosymfony:masterfromxabbuh:issue-20791
Dec 16, 2016

Conversation

@xabbuh
Copy link
Member

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#20791
LicenseMIT
Doc PR

One step further could be to remove all the loader services (or not register them at all) if only the identity translator is used (i.e. when only forms are enabled, but not translations), but that could be seen as a BC break.

if (class_exists('Symfony\Component\Translation\Translator') ||$this->isConfigEnabled($container,$config['form'])) {
if ($this->isConfigEnabled($container,$config['translator']) ||$this->isConfigEnabled($container,$config['form'])) {
if (!class_exists('Symfony\Component\Translation\Translator')) {
thrownewLogicException('Form support cannot be enabled as the Translation component is not installed.');
Copy link
Member

Choose a reason for hiding this comment

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

The error message should probably be different for the first case.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Indeed, updated it.

// 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')) {
if ($this->isConfigEnabled($container,$config['translator']) ||$this->isConfigEnabled($container,$config['form'])) {
Copy link
Member

Choose a reason for hiding this comment

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

What about remove this condition then?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

We still need it to not always load thetranslation.xml file (in case both theform and thetranslator section are not enabled).

Copy link
Member

Choose a reason for hiding this comment

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

ah right, Github did not show the whole if code, so I as confused.

@fabpot
Copy link
Member

I would indeed go one step further and only register the identity iftranslator is not enabled explicitly. We should then document this change in the CHANGELOG, but I think we should avoid as much as possible auto-registration like we have now. This will be even more important with Symfony Flex as we don't requiresymfony/symfony and ask users to explicitly register anything they want to use.

linaori, BPScott, pamil, and inelgnu reacted with thumbs up emoji

@xabbuhxabbuhforce-pushed theissue-20791 branch 2 times, most recently from8711b67 to1f86628CompareDecember 15, 2016 12:58
@xabbuh
Copy link
MemberAuthor

Fair enough, I included that change too.

@BPScott
Copy link
Contributor

BPScott commentedDec 16, 2016
edited
Loading

Woo, thank you@xabbuh! The identity translation stuff seemed a little fiddly and I'm totally unfamiliar with it so I didn't dare open a PR myself :)

A small review: I spy the class already hasformConfigEnabled andtranslationConfigEnabled properties that are set elsewhere, could the translation activation checks be done a little later in this file after those values are set to avoid repeated calls to isConfigEnabled()? It might also be adding an extra level of nesting to the if structuring to avoid multiple calls toclass_exists('Symfony\Component\Translation\Translator') too. Something like:

if ($this->isConfigEnabled($container,$config['translator']) ||$this->isConfigEnabled($container,$config['form']) ||$this->isConfigEnabled($container,$config['validation'])) {if (!class_exists('Symfony\Component\Translation\Translator') {if ($this->isConfigEnabled($container,$config['translator'])) {thrownewLogicException('Translation support cannot be enabled as the Translation component is not installed.');        }if ($this->isConfigEnabled($container,$config['form'])) {thrownewLogicException('Form support cannot be enabled as the Translation component is not installed.');        }if ($this->isConfigEnabled($container,$config['validation'])) {thrownewLogicException('Validator support cannot be enabled as the Translation component is not installed.');        }    }$loader->load('identity_translator.xml');}

@xabbuh
Copy link
MemberAuthor

@BPScott I don't think that's necessary as this code is only executed during compilation.

@linaori
Copy link
Contributor

linaori commentedDec 16, 2016
edited
Loading

@xabbuh could this cause issues related to:#20949 ?

@xabbuh
Copy link
MemberAuthor

@iltar This would solve#20949. Well, at least it will provide a more meaningful error message.

Copy link
Contributor

@aitboudadaitboudad left a comment

Choose a reason for hiding this comment

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

LGTM

@fabpot
Copy link
Member

Thank you@xabbuh.

@fabpotfabpot merged commit1e67155 intosymfony:masterDec 16, 2016
fabpot added a commit that referenced this pull requestDec 16, 2016
…t required (xabbuh)This PR was merged into the 3.3-dev branch.Discussion----------[FrameworkBundle] don't load translator services if not required| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#20791| License       | MIT| Doc PR        |One step further could be to remove all the loader services (or not register them at all) if only the identity translator is used (i.e. when only forms are enabled, but not translations), but that could be seen as a BC break.Commits-------1e67155 don't load translator services if not required
@xabbuhxabbuh deleted the issue-20791 branchDecember 16, 2016 16:38
@inelgnu
Copy link
Contributor

@xabbuh "templating.helper.translator" service has a dependency on translator and will not work if templating engine is set to "php" (see templating_php.xml)
cc@fabpot@aitboudad

@aitboudad
Copy link
Contributor

@inalgnu can you provide a PR that fixes the issue ?

@inelgnu
Copy link
Contributor

@aitboudad done here#21374

@xabbuh
Copy link
MemberAuthor

see#22006

fabpot added a commit that referenced this pull requestMar 17, 2017
…s disabled (xabbuh)This PR was merged into the 3.3-dev branch.Discussion----------[FrameworkBundle] remove translator helper if Translator is disabled| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#20928 (comment),#21374| License       | MIT| Doc PR        |Commits-------25ea510 remove translator helper if Translator is disabled
symfony-splitter pushed a commit to symfony/framework-bundle that referenced this pull requestMar 17, 2017
…s disabled (xabbuh)This PR was merged into the 3.3-dev branch.Discussion----------[FrameworkBundle] remove translator helper if Translator is disabled| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |symfony/symfony#20928 (comment), #21374| License       | MIT| Doc PR        |Commits-------25ea510ba4 remove translator helper if Translator is disabled
@fabpotfabpot mentioned this pull requestMay 1, 2017
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot left review comments

+1 more reviewer

@aitboudadaitboudadaitboudad approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

7 participants

@xabbuh@fabpot@BPScott@linaori@inelgnu@aitboudad@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp