Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[DI] fix definition and usage of AbstractArgument#36545
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
javiereguiluz commentedApr 23, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Thanks for simplifying this feature. This is thebefore: <serviceid="maker.generator"class="Symfony\Bundle\MakerBundle\Generator"> <argumenttype="service"id="maker.file_manager" /> <argumenttype="abstract"key="$rootNamespace">defined in MakerPass</argument></service> maker.generator:class:Symfony\Bundle\MakerBundle\Generatorarguments:$rootNamespace:!abstract defined in MakerPass $builder->register('maker.generator', Generator::class) ->addArgument(newAbstractArgument('maker.generator','$rootNamespace','defined in MakerPass')); Could you please show theafter config? Thanks! |
before: after: the rest is untouched. But the example in PHP should be this actually if we want the equivalent of yaml/xml: |
wouterj commentedApr 23, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
So I used this feature in the Security PR (see e.g.https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/SecurityBundle/Resources/config/security_authenticator.xml#L17) as |
nicolas-grekas commentedApr 23, 2020 • edited by chalasr
Loading Uh oh!
There was an error while loading.Please reload this page.
edited by chalasr
Uh oh!
There was an error while loading.Please reload this page.
nope: we don't use named arguments in core
nothing changes here (but this is argument 3, not 1) |
wouterj commentedApr 23, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Hmm, but then I think this feature might still not be generic enough (or at least, it doesn't fit Symfony's usage). If I read the code correctly, the XML currently used in Security will result in this error message: This is imho weird in 2 ways:
(Btw, I agree with the changes in this PR, but I feel like the feature itself is not 100% correct yet) |
The message would be: I get what you mean@wouterj, but I don't have any better proposal. |
Note that what matters is that the message is actionable. In this regard, I think it is. |
Updated to use positional numbers: |
@javiereguiluz Can you update the blog post? |
Thank you@nicolas-grekas. |
Yes! I've just updated the blog post 👍 |
Readinghttps://symfony.com/blog/new-in-symfony-5-1-abstract-service-arguments and the comments there made me realize that the current implementation is not generic enough. Abstract arguments can be found anywhere, not only as service arguments. Also,
AbstractArgument
instances should not convey the key/id since that makes them harder to use in the PHP-DSL.