ZF-346: Implement Zend_Hash from Zend_Config

Description

As Zend_Config provides a property based interface to an array, we should rename it Zend_Hash.

We then need a new Zend_Config with a single factory method:

class Zend_config { static public function factory($adapterName, $adapterConfig = array(), $allowModifications = false); }

Comments

Pasting Rob's message to fw-general:

The idea is that Zend_Config is renamed to Zend_Hash and a new Zend_Config is written that mimics Zend_Db's factory().

The rationale is already in the comments for Zend_Config:


    /**
     * Zend_Config provides a property based interface to
     * an array. The data are read only unless $allowModifications
     * is set to true on construction.
     *
     * Zend_Hash [sic] also implements Countable and Iterator to
     * facilitate easy access to the data.

The new interface to Zend_Config will be pretty much identical to how Zend_Db's factory() works:


$adapterConfig = array($filename, $section);
$config = Zend_Config::factory('INI', $adapterConfig,
              $allowModifications);

(The returned {{$config}} is of type Zend_Hash.)

This would mean that the current method of creating a Zend_Config would no longer work. i.e.


    $config = new Zend_Config(new Zend_Config_Ini(...));

would fail and you would need to change the code to:


    $config = new Zend_Hash(new Zend_Config_Ini(...));

As discussed on the mailing list, Zend_Hash is the wrong name! Need a better one...

The current consensus is that we need not extract the referred functionality from Zend_Config into a separate "container" component intended to provide appropriate functionality for the generalized problem. Other framework components and applications are instead encouraged to implement such functionality according to their own specific needs, and opportunities for refactoring can be examined later with respect to actual needs.

I was re-reading the lists again today and I thought common consensus was that a primitive container was a good idea. It had comments from Christopher, myself, Ralph, Ralf, Nico, Alexander and Matthew that indicated a more positive impression.

I think Christopher's summary was pretty good. All it needs is:-

  • property access __get()/__set()/__isset() and get()/set()/has()
  • array access and iteration
  • allows control of the types of variables that can be stored
  • allows overwrite or no-overwrite
  • allows duplicates or no duplicates (mainly for objects)

...and currently Zend_Config has most of that.

Rob - have you progressed on any of the refactoring you had mentioned? I would be keen to rework ACL/Environment in the meantime to perform some preliminary testing on the suitability of Zend_Hash/Zend_Container/Zend_Array