Configuration data are made accessible to the Zend_Config
constructor
through an associative array, which may be multidimensional, in order to support
organizing the data from general to specific. Concrete adapter classes function
to adapt configuration data from storage to produce the associative array for the
Zend_Config
constructor. User scripts may provide such arrays directly
to the Zend_Config
constructor, without using an adapter class, since
it may be appropriate to do so in certain situations.
Zend_Config
implements the Countable
and Iterator
interfaces in order to facilitate simple access to configuration data.
Thus, one may use the count()
function and PHP constructs such as
foreach
upon
Zend_Config
objects.
By default, configuration data made available through Zend_Config
are read-only, and an assignment (e.g.,
$config->database->host = 'example.com'
)
results in a thrown exception. This default behavior may be overridden through the constructor,
however, to allow modification of data values.
Nota | |
---|---|
It is important not to confuse such in-memory modifications with saving configuration
data out to specific storage media. Tools for creating and modifying configuration
data for various storage media are out of scope with respect to |
Adapter classes inherit from the Zend_Config
class since they utilize its functionality.
The Zend_Config
family of classes enables configuration data to be
organized into sections. Zend_Config
adapter objects may be loaded
with a single specified section, multiple specified sections, or all sections
(if none are specified).
Zend_Config
adapter classes support a single inheritance model that
enables configuration data to be inherited from one section of configuration data
into another. This is provided in order to reduce or eliminate the need for
duplicating configuration data for different purposes. An inheriting section
may also override the values that it inherits through its parent section.
Like PHP class inheritance, a section may inherit from a parent section,
which may inherit from a grandparent section, and so on, but multiple inheritance
(i.e., section C inheriting directly from parent sections A and B) is not supported.