-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[DependencyInjection] Add section about Service Closures #15730
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
Conversation
374088f
to
0da6fc7
Compare
…-DSL (HypeMC) This PR was merged into the 5.4 branch. Discussion ---------- [DependencyInjection] Add service_closure() to the PHP-DSL | 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. Commits ------- f333fa0 [DI] Add service_closure() to the PHP-DSL
…-DSL (HypeMC) This PR was merged into the 5.4 branch. Discussion ---------- [DependencyInjection] Add service_closure() to the PHP-DSL | 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. Commits ------- f333fa0e05 [DI] Add service_closure() to the PHP-DSL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for documenting this!
/** | ||
* @var \Closure | ||
*/ | ||
private $mailer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** | |
* @var \Closure | |
*/ | |
private $mailer; | |
/** | |
* @var callable(): MailerInterface | |
*/ | |
private \Closure $mailer; |
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
$services = $configurator->services(); | ||
|
||
$services->set(MyService::class) | ||
->args([new ServiceClosureArgument(new Reference('mailer'))]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to mergers: this should be updated to:
->args([new ServiceClosureArgument(new Reference('mailer'))]); | |
->args([service_closure('mailer')]); |
when merged up in 5.4.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a separate PR for that #15731
722e76e
to
73125ee
Compare
As 4.4 is not maintained anymore we should only work on 5.4, can you merge the two PRs? |
@OskarStark Done, #15731 should be good to go. |
Documents service closures added in symfony/symfony#21770 and symfony/symfony#41176.