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][Translator] Make the Translator works with any PSR-11 container#22010

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:masterfromchalasr:psr11-translator
Mar 22, 2017

Conversation

@chalasr
Copy link
Member

@chalasrchalasr commentedMar 15, 2017
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?yes
Tests pass?yes
Fixed ticketsn/a
LicenseMIT
Doc PRn/a

Uses a service-locator for collected translation loaders and replace the single call ofgetParameter() by an optional constructor argument.

Nek- and Koc reacted with thumbs up emoji
* @throws InvalidArgumentException
*/
publicfunction__construct(ContainerInterface$container,MessageSelector$selector,$loaderIds =array(),array$options =array())
publicfunction__construct(ContainerInterface$container,MessageSelector$selector,$defaultLocale =null,$loaderIds =array(),array$options =array())

Choose a reason for hiding this comment

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

missing "array" type hint for $loaderIds

$loaderIds =$defaultLocale;

if (!$containerinstanceof SymfonyContainerInterface) {
thrownew \InvalidArgumentException(sprintf('A default locale must be passed as 3rd argument of %s() since version 3.3, the argument will be mandatory in 4.0.',__METHOD__));

Choose a reason for hiding this comment

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

I'd suggest moving this before the trigger_error, and making the message simpler:
Missing third $defaultLocale argument.

@chalasrchalasrforce-pushed thepsr11-translator branch 2 times, most recently from5bec128 tobd666f8CompareMarch 16, 2017 08:50
@chalasr
Copy link
MemberAuthor

@nicolas-grekas comments addressed

@chalasrchalasrforce-pushed thepsr11-translator branch 2 times, most recently from7d881cc to94073dfCompareMarch 16, 2017 09:17
Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

👍

<argumenttype="service-locator" /><!-- translation loaders-->
<argumenttype="service"id="translator.selector" />
<argumenttype="collection" /><!-- translation loaders-->
<argument>%kernel.default_locale%</argument>
Copy link
Member

Choose a reason for hiding this comment

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

Why not pass the default locale as an option instead?

Copy link
MemberAuthor

@chalasrchalasrMar 16, 2017
edited
Loading

Choose a reason for hiding this comment

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

The argument exists in the parent constructor with getter/setter (unlike other options), I find consistent to have it here. An option would be fine too

@chalasrchalasrforce-pushed thepsr11-translator branch 4 times, most recently from7faf677 toc5d9781CompareMarch 16, 2017 23:43
@chalasr
Copy link
MemberAuthor

$defaultLocale argument replaced by an option.

@nicolas-grekas
Copy link
Member

Not sure about the change: the option is not optional (it's required ;) ), which means the 4th arg is now mandatory also, but the signature tells the contrary. WDYT@fabpot ? Was that what you had in mind?

@fabpot
Copy link
Member

My point was just that we already have an$options array with 3 different keys and that adding a 4th one for the locale seemed natural to me and allowed to keep BC.

@chalasrchalasrforce-pushed thepsr11-translator branch 5 times, most recently froma8f4c75 toef8c191CompareMarch 17, 2017 15:09
@chalasr
Copy link
MemberAuthor

Given it would be the only mandatory option and we would have to provide an equivalent BC layer in both cases, I changed it back to an argument.

@chalasrchalasrforce-pushed thepsr11-translator branch 5 times, most recently from240639a to58e3db1CompareMarch 18, 2017 09:41
@chalasr
Copy link
MemberAuthor

rebased

;

$translator =newTranslator($container,newMessageSelector());
$container =$this->getMockBuilder('Psr\Container\ContainerInterface')->getMock();
Copy link
Member

Choose a reason for hiding this comment

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

Psr\Container\ContainerInterface::class ?

@chalasrchalasrforce-pushed thepsr11-translator branch 3 times, most recently fromaead0cd tof9f7f3fCompareMarch 22, 2017 15:35
@chalasr
Copy link
MemberAuthor

Tests green, ready.

@fabpot
Copy link
Member

Thank you@chalasr.

@fabpotfabpot merged commit85177a6 intosymfony:masterMar 22, 2017
fabpot added a commit that referenced this pull requestMar 22, 2017
…s with any PSR-11 container (chalasr)This PR was merged into the 3.3-dev branch.Discussion----------[FrameworkBundle][Translator] Make the Translator works with any PSR-11 container| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | yes| Tests pass?   | yes| Fixed tickets | n/a| License       | MIT| Doc PR        | n/aUses a service-locator for collected translation loaders and replace the single call of `getParameter()` by an optional constructor argument.Commits-------85177a6 [FrameworkBundle] Make Translator works with any PSR-11 container
@chalasrchalasr deleted the psr11-translator branchMarch 22, 2017 16:33
@fabpotfabpot mentioned this pull requestMay 1, 2017
nicolas-grekas added a commit that referenced this pull requestMay 21, 2017
…sses (chalasr)This PR was merged into the 4.0-dev branch.Discussion----------Remove deprecated container injections and compiler passes| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | no| BC breaks?    | yes| Deprecations? | no| Tests pass?   | yes| Fixed tickets | ~~#21451#21625#21284#22010~~#22805| License       | MIT| Doc PR        | n/aCommits-------16a2fcf Remove deprecated container injections and compiler passes
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot left review comments

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

+1 more reviewer

@keraduskeraduskeradus left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

3.3

Development

Successfully merging this pull request may close these issues.

5 participants

@chalasr@nicolas-grekas@fabpot@keradus@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp