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

[DependencyInjection] Allow array for the value of Autowire attribute#47801

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:6.2fromwillemverspyck:6.2
Oct 18, 2022
Merged

[DependencyInjection] Allow array for the value of Autowire attribute#47801

fabpot merged 1 commit intosymfony:6.2fromwillemverspyck:6.2
Oct 18, 2022

Conversation

@willemverspyck
Copy link
Contributor

QA
Branch?6.2
Bug fix?no
New feature?yes
Deprecations?no
LicenseMIT
Doc PRsymfony/symfony-docs#...

Since Symfony 6.1 it's possible to use #[Autowire] for the service autowiring logic. Array as autowire parameters is not supported yet. In YAML or the attribute Autoconfigure it worked.

#[Autoconfigure(bind: ['$parameters' => ['PARAMETER_DAY_START' =>'%env(string:PARAMETER_DAY_START)%','PARAMETER_DAY_END' =>'%env(string:PARAMETER_DAY_END)%','FILTER_LIMIT' =>'%env(int:FILTER_LIMIT)%','FILTER_OFFSET' =>'%env(int:FILTER_OFFSET)%',    ],])]class WidgetService{publicfunction__construct(privatereadonlyarray$parameters)    {    }}

After this PR there is support for an array (including some extra tests):

class WidgetService{publicfunction__construct(#[Autowire(['PARAMETER_DAY_START' =>'%env(string:PARAMETER_DAY_START)%','PARAMETER_DAY_END' =>'%env(string:PARAMETER_DAY_END)%','FILTER_LIMIT' =>'%env(int:FILTER_LIMIT)%','FILTER_OFFSET' =>'%env(int:FILTER_OFFSET)%',    ])]privatereadonlyarray$parameters)    {    }}

@carsonbotcarsonbot added this to the6.2 milestoneOct 6, 2022
@nicolas-grekasnicolas-grekas changed the title[DependencyInjecten] Allow array for the value of Autowire attribute[DependencyInjection] Allow array for the value of Autowire attributeOct 17, 2022
@carsonbotcarsonbot changed the title[DependencyInjection] Allow array for the value of Autowire attributeAllow array for the value of Autowire attributeOct 17, 2022
@carsonbotcarsonbot changed the titleAllow array for the value of Autowire attribute[DependencyInjection] Allow array for the value of Autowire attributeOct 17, 2022
@fabpot
Copy link
Member

Thank you@willemverspyck.

}

if (null !==$value &&str_starts_with($value,'@')) {
if (\is_string($value) &&str_starts_with($value,'@')) {
Copy link
Member

Choose a reason for hiding this comment

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

For an array, wouldn't this need to process the strings inside that array to convert their prefixes too ?

Choose a reason for hiding this comment

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

I don't think we want to allow nesting services into arrays.

Copy link
Member

Choose a reason for hiding this comment

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

We do allow that in Yaml or XML (which is how you passed an array of objects indexed by some keys for instance)

@willemverspyck
Copy link
ContributorAuthor

Thanks for reviewing@fabpot and@nicolas-grekas 👍

@fabpotfabpot mentioned this pull requestOct 24, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@stofstofstof left review comments

@fabpotfabpotfabpot approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

6.2

Development

Successfully merging this pull request may close these issues.

5 participants

@willemverspyck@fabpot@nicolas-grekas@stof@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp