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

[DI] added possibility to define services with abstract arguments#35076

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

Conversation

fu22ybear
Copy link
Contributor

@fu22ybearfu22ybear commentedDec 21, 2019
edited by nicolas-grekas
Loading

QA
Branch?master
Bug fix?no
New feature?yes
Deprecations?no
TicketsFix#31769
LicenseMIT
Doc PRn/a

feature caused by rfc#31769 from issues list
I hope, this PR will be useful

Abstract argument have to replaced by one of compiler passes or exception will be thrown.
Example:
This service definition

... <serviceid="App\Test\Test">    <argumentkey="$a"type="abstract">should be defined by TestPass</argument> </service>...

or this for yaml

App\Test\Test:arguments:$a:!abstract should be defined by TestPass

causes exception likeArgument "$a" of service "App\Test\Test" is abstract (should be defined by TestPass), did you forget to define it?
if argument was not replaced by compiler pass

... publicfunctionprocess(ContainerBuilder$container) {$test =$container->getDefinition(Test::class);$test->setArgument('$a','test'); }...

andrew-demb, linaori, Koc, ro0NL, jvasseur, maxhelias, and alexander-schranz reacted with thumbs up emoji
@carsonbotcarsonbot added Status: Needs Review RFCRFC = Request For Comments (proposals about features that you want to be discussed) DependencyInjection Feature labelsDec 21, 2019
@nicolas-grekasnicolas-grekas added this to thenext milestoneDec 21, 2019
@nicolas-grekasnicolas-grekas changed the title[RFC][DI] added possibility to define service with abstract argument …[DI] added possibility to define services with abstract argumentsDec 21, 2019
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.

the YamlLoader and YamlDumper should also be able to deal with abstract arguments
and ContainerBuilder should throw an exception when it encounters one when creating a service.

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedDec 26, 2019
edited
Loading

Before spending more time here: is it worth it?
This looks like a lot of code, for something that is of low value to me.

@fu22ybear
Copy link
ContributorAuthor

fu22ybear commentedDec 26, 2019
edited
Loading

most part of changes are tests.
abstract argument definition looks more clear and obvious and I'd like to continue

@fu22ybear
Copy link
ContributorAuthor

fu22ybear commentedDec 29, 2019
edited
Loading

and ContainerBuilder should throw an exception when it encounters one when creating a service.

@nicolas-grekas, what if specific pass will be registered in removing passes list, like DefinitionErrorExceptionPass, to check an abstract argument existence? and this pass will throw an exception, if an abstract argument is not replaced yet

if this behavior is suitable, do dumpers still have to able to deal with abstract arguments?

@fu22ybear
Copy link
ContributorAuthor

the YamlLoader and YamlDumper should also be able to deal with abstract arguments

example for yaml config

    App\Test\Test:        arguments:            $a: !abstract should be defined by TestPass

tags functionality looks suitable

@fu22ybearfu22ybearforce-pushed theticket-31769_abstarct-arguments-in-xml-config branch from8ea71a0 todd1f2cbCompareJanuary 4, 2020 18:15
@fu22ybearfu22ybearforce-pushed theticket-31769_abstarct-arguments-in-xml-config branch fromdd1f2cb to767e456CompareJanuary 18, 2020 14:41
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.

some final comments :)

@fu22ybearfu22ybearforce-pushed theticket-31769_abstarct-arguments-in-xml-config branch from767e456 to5982780CompareJanuary 25, 2020 08:38
@nicolas-grekasnicolas-grekasforce-pushed theticket-31769_abstarct-arguments-in-xml-config branch from5982780 to62fefaaCompareFebruary 5, 2020 19:16
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.

Looks good to me! (I made some minor tweak FYI)

Copy link
Contributor

@maxheliasmaxhelias left a comment

Choose a reason for hiding this comment

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

Interesting :)

@alexander-schranz
Copy link
Contributor

@Islam93 Nice 👍 thank you having a look at this issue.

@fabpot
Copy link
Member

Thank you@Islam93.

fabpot added a commit that referenced this pull requestFeb 6, 2020
…t arguments (Islam93)This PR was merged into the 5.1-dev branch.Discussion----------[DI] added possibility to define services with abstract arguments| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| Deprecations? | no| Tickets       |Fix#31769| License       | MIT| Doc PR        | n/afeature caused by rfc#31769 from issues listI hope, this PR will be useful   Abstract argument have to replaced by one of compiler passes or exception will be thrown.   Example:   This service definition   ```xml   ...    <service>       <argument key="$a" type="abstract">should be defined by TestPass</argument>    </service>   ...   ```or this for yaml```yaml    App\Test\Test:        arguments:            $a: !abstract should be defined by TestPass```   causes exception like `Argument "$a" of service "App\Test\Test" is abstract (should be defined by TestPass), did you forget to define it?`   if argument was not replaced by compiler pass   ```php   ...    public function process(ContainerBuilder $container)    {        $test = $container->getDefinition(Test::class);        $test->setArgument('$a', 'test');    }   ...   ```Commits-------62fefaa [DI] added possibility to define services with abstract arguments
@fabpotfabpot merged commit62fefaa intosymfony:masterFeb 6, 2020
@nicolas-grekasnicolas-grekas modified the milestones:next,5.1May 4, 2020
@fabpotfabpot mentioned this pull requestMay 5, 2020
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@fabpotfabpotfabpot approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@maxheliasmaxheliasmaxhelias approved these changes

Assignees
No one assigned
Labels
DependencyInjectionFeatureRFCRFC = Request For Comments (proposals about features that you want to be discussed)Status: Reviewed
Projects
None yet
Milestone
5.1
Development

Successfully merging this pull request may close these issues.

[RFC] [DI] Abstract arguments
6 participants
@fu22ybear@nicolas-grekas@alexander-schranz@fabpot@maxhelias@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp