On Thu, Oct 10, 2013 at 8:53 PM, Stefano Torresi
<[email protected]>wrote:
>
> TL:DR; what would you recommend between the two for dynamic module
> configuration?
>From Config\Config doc block:
> Provides a property based interface to an array.
> To be more precise, is there any difference between the two when dealing with
dynamically assigned values, i.e. merged data from a persistence layer?
Well, for "dynamic" data you're better off using containers such as
ArrayObject (in general). Config\Config is meant to hold general
configuration stuff, however it's been a little bit forgotten in ZF2 in
favor of Options.
As you've already noticed, AbstractOptions and its subclasses are used for
enforcing strict set of options for components, based on accessors. This is
good for the sanity of component developers, good for end users as they can
catch config errors earlier, it's good for IDEs because you get full
hinting ("code-intelligence"). Accessors are also able to validate values
and throw exceptions in case of invalid values.
So:
- Options are meant to be used together with components, be "strict" in
nature, well-defined, documented and easy to use.
- Config is a "dumb" container with a few nice toys (such as reading
different formats, merging, writing, etc.) which replaces arrays-of-arrays.
- ArrayObject is a basic building block for general containers when you
want to replace arrays (i.e. for easy referencing).
A.
--
[email protected]
+48 695 600 936
http://thinkscape.pro