You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.
MyClass will be created during Di::newInstance by Di::createInstanceViaCallback().
If the instantiator method is "__construct" the "__construct"-method will be removed from the array of possible injection methods ($injectionMethods). If the instantiator is something different, the method (in the example "create") will NOT be removed. So the method is called again from Di::handleInjectionMethodForInstance() which results in a second instance of MyClass.
The text was updated successfully, but these errors were encountered:
(Originally posted by: ralphschindler on 06/25/12)
I am closing the related pull request, with the information above, this is hard to follow your use case, can you provide more information and/or a unit test?
Honestly I'm not using DI anymore since ZF2 switched to the ServiceLocator. But it looks like your PR prevents that the static factory method is added to the injectionMethods array. (I assume that getMethods() will not return any static functions anymore.)
Jira Information
Description
When using a factory method with a parameter definition to create a class the factory method will be called twice:
Example:
MyClass will be created during Di::newInstance by Di::createInstanceViaCallback().
If the instantiator method is "__construct" the "__construct"-method will be removed from the array of possible injection methods ($injectionMethods). If the instantiator is something different, the method (in the example "create") will NOT be removed. So the method is called again from Di::handleInjectionMethodForInstance() which results in a second instance of MyClass.
The text was updated successfully, but these errors were encountered: