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
Allow use factories and OM for creating objects with variadic arguments in constructor #24556
Allow use factories and OM for creating objects with variadic arguments in constructor #24556
Conversation
…ts in constructor
Hi @adrian-martinez-interactiv4. Thank you for your contribution
For more details, please, review the Magento Contributor Guide documentation. |
Nice improvement. Did you have a chance to check if it would be possible to specify arguments in |
@buskamuza I tested it here: https://github.com/magento/magento2/pull/24556/files#diff-3fe7b0651b076e3b1c628181bb34eca0R298, but having a second look at it, it may not work with real defined di.xml parameters, I'll review it. |
@buskamuza After reviewed, it seems it should work. About Database Compare build failing, there are no build reports available. |
Hi @ihor-sviziev, thank you for the review.
|
@magento run Database Compare build |
✔️ QA Passed |
…iadic arguments in constructor #24556
Hi @adrian-martinez-interactiv4, thank you for your contribution! |
…ts in constructor Related with magento#24556. That PR allowed to inject scalar values as variadic parameters, but do not work for objects injections. Object definitions don't get instantiated, and target class constructor receives an array of strings instead (with '_instance' key, that should have been transformed into real object)
…ts in constructor Related with magento#24556. That PR allowed to inject scalar values as variadic parameters, but do not work for objects injections. Object definitions don't get instantiated, and target class constructor receives an array of strings instead (with '_instance' key, that should have been transformed into real object)
…ts in constructor Related with magento#24556. That PR allowed to inject scalar values as variadic parameters, but do not work for objects injections. Object definitions don't get instantiated, and target class constructor receives an array of strings instead (with '_instance' key, that should have been transformed into real object)
Description (*)
Currently, if you have a class using a variadic argument in constructor, it is not possible to use generated factories or OM to instantiate it. Having this as example, there is no way to instantiate it using CustomObjectPoolFactory generated class:
This is a test snippet, that fails with a type error exception:
With provided changes, variadic arguments are supported, including building without arguments:
Or defining them as an array:
Or defining a single one in a simple way:
Or injecting them from di.xml config.
Fixed Issues (if relevant)
None AFAIK, improvement
Manual testing scenarios (*)
Use provided snippet.
Questions or comments
Contribution checklist (*)