Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[DependencyInjection] [POC] allowServiceSubscriberTrait to autowire properties#46617
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
ServiceSubscriberTrait to autowire propertiesServiceSubscriberTrait to autowire properties187925e todeeb6fdCompare
nicolas-grekas left a comment
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.
Many interesting challenges here, that's very much R&D :)
| $this->container =$container; | ||
| if ($containerinstanceof ServiceProviderInterface) { | ||
| // TODO: what if this isn't an instance of ServiceProviderInterface? |
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.
We should use reflection instead of relying on ServiceProviderInterface and unset only the properties that have the attribute
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.
This would be at runtime, that ok?
Uh oh!
There was an error while loading.Please reload this page.
| { | ||
| // TODO: ensure cannot be called from outside of the scope of the object? | ||
| // TODO: what if class has a child/parent that allows this? | ||
| // TODO: call parent::__get()? |
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.
LazyGhostObjectTrait to the rescue somehow?
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.
I'm not very familiar with this trait. How could it be used?
src/Symfony/Contracts/Tests/Service/ServiceSubscriberTraitTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
56b0944 to573b694Compare573b694 toe2fb640Comparenicolas-grekas commentedSep 13, 2023 • 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.
I'm closing here because while this is an interesting topic, I feel like this would bring too much complexity in comparison to other approaches based on Autowire attributes, especially since#51392 |
Uh oh!
There was an error while loading.Please reload this page.
This comes from a slack discussion with@nicolas-grekas.
This PR allows
ServiceSubscriberInterfaceservices using theServiceSubscribertrait toautowire properties marked with theSubscribedServiceattribute.TODO: