Jame,s On Mon, Aug 16, 2010 at 3:27 PM, James Pic <[email protected]> wrote: > Hello Jerome, > > On Mon, Aug 16, 2010 at 3:11 PM, Jerome Renard <[email protected]> > wrote: >> Hi James, >> >> I think the merge mechanism on Configuration should work like this : >> >> $parent = new ezcConfigurationIniReader() // init validate and load etc ... >> $child = new ezcConfigurationIniReader() // init, validae and load etc ... >> > > Why not use simple ezcConfiguration objects? those can be generated > from different backends ie. php, ini .... >
Sure, but the ezcConfiguration is just a higher view of what's going under the hood with the Ini or the array reader. So "designing" for the ini ready (for example) make it obviously available for the higher level ezConfiguration object :) Sorry for the too-short-shortcut ;) >> // and then we have a few options >> // option 1: >> $mergedGroup = new ezcConfigurationIniMergedGroup($parent, $child, >> 'ConfigGroupName'); >> [...] >> >> // option2: >> $mergedGroup = $parent->mergeWith($child, 'ConfigGroupName'); >> // and then $mergedGroup is an ezcConfigurationIniMergedGroup >> [...] >> > > Again, why not just generate a fresh ezcConfiguration object? See above. > > ie. > > $final = ezcConfigurationMerger::merge(array( > $parent, > // [...] > $child, > )); > I would not use an array here, but only 2 arguments, like $parent and $child. >> What I am wondering is if ezcConfigurationIniMergedGroup should be an >> ezcBaseStruct >> or something else. That would make sense to me to get it as an >> ezcBaseStruct but maybe >> I overlook something here. >> >> Merging by group gives a more granular control on what you want, and >> by simply looping over >> each group in a file, that would make it possible to merge a complete file. >> >> I used the INI reader as an example, that should work the same way >> with the Array reader. >> >> What do you think ? > > I think we could just make a simple merge function that generates a > final ezcConfiguration object from a set of ezcConfiguration objects, > and make some trivial & sexy shortcut functions ie: > > $cfg = ezcConfigurationMerger::refresh( > $writer, // ie. new ezcConfigurationArrayWriter() > $pathToFinalConfiguration, > array( > $pathToDefaultConfiguration, // parent > // [...] > $pathToOverrideConfiguration, // child > ), > ) > The line below are dedicated to the configuration write I believe. If yes I agree with the function prototype, if no then I do not agree :p > What do you think? Did i convince you or do we plainly disagree? hahaha We are making progress on that topic ;) -- Jérôme Renard http://39web.fr | http://jrenard.info
