James, On Mon, Aug 16, 2010 at 8:29 PM, James Pic <[email protected]> wrote: > On Mon, Aug 16, 2010 at 6:19 PM, Jerome Renard <[email protected]> > wrote: >> James, >> >> On Mon, Aug 16, 2010 at 5:52 PM, James Pic <[email protected]> wrote: >>> On Mon, Aug 16, 2010 at 3:47 PM, Jerome Renard <[email protected]> >>> wrote: >>>> Jame,s >>>> >>>> On Mon, Aug 16, 2010 at 3:27 PM, James Pic <[email protected]> wrote: >>>>> Hello Jerome, >>>>> >>>>> ie. >>>>> >>>>> $final = ezcConfigurationMerger::merge(array( >>>>> $parent, >>>>> // [...] >>>>> $child, >>>>> )); >>>>> >>>> >>>> I would not use an array here, but only 2 arguments, like $parent and >>>> $child. >>>> >>> >>> I though you wanted to have configuration in multiple directories? ie. >>> >>> array( // in order of importance >>> '/path/to/project/etc/dev', >>> '/path/to/app1/etc/dev', >>> '/path/to/app1/etc/default', >>> '/path/to/app2/etc/dev', >>> '/path/to/app2/etc/default', >>> ) >>> >>> Didn't what you want look like something like that? >> >> Ideally yes, but if we split features in two different components, >> then we can keep >> the merge feature only in Configuration and all the rest in the other >> component. >> As long as Configuration provide a merge mechanism between multilple >> configuration groups, then >> you can use this feature for entire files, no matter their location. >> This gives us an interesting flexibility :) > > Do you mean that you recommand such a usage: > > foreach( $myConfigs as $config ) { > if ( isset( $previousConfig ) ) { > $final = mergeFunc( $previousConfig, $config ); > } > $previousConfig = $config; > } >
More or less but encapsulated of course. > Instead of: > > $final = mergeFunc( $myConfigs ); > > What flexibility does it brings? If you can do an operation on a small set (a configuration group in that case) you can do exactly the same for larger chunks of data with a simple loop. As long as everything is encapsulated it is OK. > > Doesn't the first use case look like boilerplate code? > What do you mean ? :) -- Jérôme Renard http://39web.fr | http://jrenard.info
