Hi Ralph, You bring up some interesting points here, and I agree that we should abide by some conventions (the ones you describe here seem reasonable to me) in order to allow developers to seamlessly couple components with respect to configuration options.
I very much look forward to seeing the additional examples you mention, especially regarding your real-world use cases and the limitations you encounter with programatically wiring framework components. Accompanied by information on how you have handled these situations, I think we can come up with ideas on how to solve such problems. Best regards, Darby Ralph Schindler wrote: > > I am proposing that all components that use/require configuration that > applies to all instantiated objects of that component type follow a > simple convention for setting those options. > > This is important for a few reasons: > - consistency in code and expectations > - allow for pragmatic (or automagic) setting of options in boostrap > - greater levels of ease of use when coupling with Zend_Config > > The convention is as follows for components requiring configs: > - components implement a method named self::setOptions(Array $options); > - if multiple calls to setOptions are made, changes to previously set > options that do not exist is current calls should not be overwritten > - if the static method setOptions is not an option due to __call() > namespace clashing, there should be a public static property named > $options that exists. > > > > Aside from the reasons listed above, my personal reasons for this are > simple. I am not afraid of __autoload() ;) B/c honestly, whats the > point of having this beautiful component structure if we can't expoit > it! That being said, I do use it in my applications. The one thing > that I would/do enjoy from the components I've written that have this > convention is that I can assure that through my autoload class, when the > class is loaded, options directly after the call to Zend::loadClass(). > This being the case, I know that if my config file has the following: > > [component_options] > > .. > Zend_Session_Core.name = 'ZFSESSION' > Zend_Session_Core.path = '../application/var/sessions/' > .. > > > That the session core will automatically have these options passed to it > after loading time and before object instantiation time. I will have > more examples of this in the near future and will put my autoload class > in my repository for whoever wants to use it. > > -ralph > >
