View Source

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFPROP:Proposal Zone Template}

{zone-data:component-name}
Zend_Config_Configurable (interface)
{zone-data}

{zone-data:proposer-list}
[Lars Strojny|mailto:lars@strojny.net]
{zone-data}

{zone-data:liaison}
[~matthew]
{zone-data}

{zone-data:revision}
0.1 - 26 December 2007: Initial submission.
{zone-data}

{zone-data:overview}
Zend_Config_Configurable is an interface indicating configuration facilities of a component. It will unify all components which consume Zend_Config objects for their internal configuration.
{zone-data}

{zone-data:references}
* [Inversion of Control Containers and the Dependency Injection pattern (used in examples)|http://martinfowler.com/articles/injection.html]
* [Repository pattern (used in the examples)|http://martinfowler.com/eaaCatalog/repository.html]
{zone-data}

{zone-data:requirements}
* This interface *will* enforce the way components handle configuration
* This interface *will* unify the way components handle configuration
* This interface allows other Zend components/user defined classes to find out weither an object is configurable
* This interface *is implemented* by various current classes
* This interface *will* direct others how to implement configurability with Zend_Config
{zone-data}

{zone-data:dependencies}
* Zend_Config (for type hinting)
* Zend_Db_Adapter_Abstract
* Zend_Layout
* Zend_Filter_Inflector
* Zend_Controller_Router_Rewrite
* Zend_Controller_Router_Route_Interface
* Zend_Controller_Router_Route_Regex
* Zend_Controller_Router_Route_Module
* Zend_Controller_Router_Route_Static
{zone-data}

{zone-data:operation}

{zone-data}

{zone-data:milestones}
* Milestone 1: Get feedback
* Milestone 2: Implement interface Zend_Config_Configurable and commit to incubator
* Milestone 3: Edit implementors to handle configurations the way Zend_Config_Configurable enforces it (in incubator)
* Milestone 4: Edit unit test of the implementers
* Milestone 5: Document Zend_Config_Configurable with good examples
{zone-data}

{zone-data:class-list}
* Zend_Config_Configurable
{zone-data}

{zone-data:use-cases}
||UC-01||
{code}
/**
* An example repository object which uses the interface to decide whether
* to set an config object or not
*/
class Repository
{
public function retrieveObject(Criteria $criteria)
{
$object = $this->_retrieve($criteria);
if ($object instanceof Zend_Config_Configurable) {
$object->setConfig($this->getConfig());
}
return $object;
}

[...]
}
{code}
{zone-data}

{zone-data:skeletons}
{code}
interface Zend_Config_Configurable
{
/**
* Add configuration object
*
* Add a configuration object to the component. Optionally you can specify
* a configuration section in which the basic configuration object resides.
*
* @param Zend_Config $config Configuration object
* @param string $section Section of the configuration (optionally)
*/
public function setConfig(Zend_Config $config, $section = null);

/**
* Get configuration object
*
* @return Zend_Config|void
*/
public function getConfig();

/**
* Instanciate component from configuration object
*
* @param Zend_Config $config Configuration object
* @param string $section Section of the configuration (optionally)
* @return object Instance of the configured component
*/
public static function configure(Zend_Config $config, $section = null);
}
{code}
{zone-data}

{zone-template-instance}]]></ac:plain-text-body></ac:macro>