How do I get Zend Di to use setter injection with RuntimeDefinition -
i have class setters , i'd setter injection used, runtimedefinition it's not triggering. thought might not possible, upgraded zend 2.1.0 , started getting error zend\db\adapter\adapter getting injected in other classes because new setprofiler() method introduced , it's trying setter injection on (while using default runtimedefinition). looked @ code adapter , difference saw between code , mine setprofiler() method had doc comments @param in it, thought maybe reflection uses this. added code , doesn't work. i'm missing something. when compile di definition file, can see zend\db\adapter\adapter has entry under definition:
'methods' => array ( '__construct' => true, 'setprofiler' => true, ) whereas definition looks this:
'methods' => array ( 'setmyvalue' => false, ) how di correctly identify setter functions used inject necessary values?
after much looking internals of compilerdefinition class, i've figured out.
the reason setter gets called in case of zend\db\adapter\adapter because of profiler\profilerawareinterface.
it appears if class implements interface , there's setter in interface, setter called. it's of import implemented interface name matches regex /\w*aware\w*/.
you can see illustration of logic in ralphschindler's zend\di examples.
zend-framework2
No comments:
Post a Comment