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] deprecate theinline()
function from the PHP-DSL in favor ofservice()
#36388
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 tasks
fabpot approved these changesApr 12, 2020
Thank you@nicolas-grekas. |
fabpot added a commit that referenced this pull requestApr 24, 2020
This PR was merged into the 5.1-dev branch.Discussion----------[DI] add syntax to stack decorators| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes| Deprecations? | no| Tickets |Fix#30599| License | MIT| Doc PR | -Declare this:```yamlservices: my_stack_of_decorators: stack: - class: App\ExternalDecorator - class: App\InternalDecorator - class: App\DecoratoredClass```And get this:The PR is now ready with support for Yaml, XML and the PHP-DSL. It needs#36388,#36392 and#36389 to pass, and relates to#36390 to be DX-friendly.The new syntax now supports composable stacks - i.e stack you can reuse in the middle of another stack.RIP middleware, simple decorators FTW :)From the test cases:```yamlservices: reusable_stack: stack: - class: stdClass properties: label: A inner: '@.inner' - class: stdClass properties: label: B inner: '@.inner' concrete_stack: stack: - parent: reusable_stack - class: stdClass properties: label: C```This will create a service similar to:```php(object) [ 'label' => 'A', 'inner' => (object) [ 'label' => 'B', 'inner' => (object) [ 'label' => 'C', ] ],];```When used together with autowiring, this is enough to declare a stack of decorators:```yamlservices: my_processing_stack: stack: - App\ExternalDecorator: ~ - App\InternalDecorator: ~ - App\TheDecoratedClass: ~```See fixtures for the other configuration formats.See alsohttps://twitter.com/nicolasgrekas/status/1248198573998604288Todo:- [x] rebase on top of#36388,#36392 and#36389 once they are merged- [x] test declaring deeper nested stacksCommits-------98eeeae [DI] add syntax to stack decorators
Merged
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In the PHP-DSL, the
inline()
function helps declaring ... inline services.I'm proposing to rename it to
service()
, for consistency with yaml tags. All other helpers but this one have the same name as the yaml tag.Let's do this while "nobody" uses this format yet :)