Skip to content

[DependencyInjection] Add service_closure() to the PHP-DSL #42625

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 20, 2021
Merged

[DependencyInjection] Add service_closure() to the PHP-DSL #42625

merged 1 commit into from
Aug 20, 2021

Conversation

HypeMC
Copy link
Contributor

@HypeMC HypeMC commented Aug 18, 2021

Q A
Branch? 5.4
Bug fix? no
New feature? yes
Deprecations? no
Tickets -
License MIT
Doc PR symfony/symfony-docs#15730 and symfony/symfony-docs#15731

Adds a service_closure() function to the PHP-DSL.

->args([service_closure(service('foo'))]);

$s->set('service_closure_invalid', 'Bar')
->args([service_closure(service('invalid_service')->nullOnInvalid())]);
Copy link
Member

Choose a reason for hiding this comment

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

it'd be great to be able to do this instead:
service_closure('invalid_service')->nullOnInvalid()

maybe with a new ClosureReferenceConfigurator?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nicolas-grekas Done. The fabbot failure is unrelated to my changes, I can apply it if you want.

@fabpot
Copy link
Member

fabpot commented Aug 18, 2021

@HypeMC Can you submit a PR on the docs? Or at least, give a full usage example in the PR description to help the doc team? Thank you.

@HypeMC
Copy link
Contributor Author

HypeMC commented Aug 18, 2021

@fabpot Sure, I'll submit a PR sometime tomorrow.

@HypeMC
Copy link
Contributor Author

HypeMC commented Aug 19, 2021

@fabpot PR(s) on the docs added: symfony/symfony-docs#15730 and symfony/symfony-docs#15731

@nicolas-grekas
Copy link
Member

Thank you @HypeMC.

@nicolas-grekas nicolas-grekas merged commit a42062d into symfony:5.4 Aug 20, 2021
@HypeMC HypeMC deleted the add-service-closure-to-php-dsl-2 branch August 20, 2021 11:52
This was referenced Nov 5, 2021
OskarStark added a commit to symfony/symfony-docs that referenced this pull request Mar 9, 2023
…es (HypeMC)

This PR was merged into the 5.4 branch.

Discussion
----------

[DependencyInjection] Add section about Service Closures

Documents service closures added in symfony/symfony#21770 and symfony/symfony#41176, and the `service_closure()` PHP-DSL function added in symfony/symfony#42625 .

Commits
-------

f2b2fdb [DI] Add section about Service Closures
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants