Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.2k
Add note about not using autowire with ServiceSubscriber#20961
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
base:7.2
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -140,6 +140,18 @@ count and iterate over the services of the locator:: | ||||||
The :class:`Symfony\\Contracts\\Service\\ServiceCollectionInterface` was | ||||||
introduced in Symfony 7.1. | ||||||
Without autowire | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. maybe this? Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. or a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. is it possible to add code block in a note ? | ||||||
~~~~~~~~~~~~~~~~ | ||||||
If you are not using autowire you need to require either ``Psr\Container\ContainerInterface`` or ``Symfony\Contracts\Service\ServiceProviderInterface`` as a ``__construct`` argument or as a method call like ``setContainer(Psr\Container\ContainerInterface $container)``. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Suggested change
| ||||||
.. code-block:: diff | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I guess a | ||||||
$services->set('my_service', SomeClass::class) | ||||||
+ ->call('setContainer', [service(ContainerInterface::class)]) | ||||||
+ ->tag('container.service_subscriber') | ||||||
; | ||||||
Including Services | ||||||
------------------ | ||||||