View Source

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

{zone-data:component-name}
Zend_Config_Xml Attribute Support - Ben Scholzen
{zone-data}

{zone-data:proposer-list}
[Ben Scholzen|mailto:mail@dasprids.de]
Zend Liaison - [~ralph]
{zone-data}

{zone-data:revision}
1.0 - 20 February 2008: Initial proposal.
1.1 - 20 February 2008: Prototype and unit tests finished.
{zone-data}

{zone-data:overview}
This proposal will extend Zend_Config_Xml to be able to use node attributes. This will make config files not only more readable, but also easier to handle and quite smaller.
{zone-data}

{zone-data:references}
{zone-data}

{zone-data:requirements}
* This component *will* keep the compatibility with prior xml config files.
* This component *will* allow values given by parent nodes.
* This component *will* allow a short form of parameter values.
{zone-data}

{zone-data:dependencies}
* Zend_Config
{zone-data}

{zone-data:operation}
The Config is instantiated like before, and the usage nor the data structure will change in any way. Programmers just get the ability to write their configurations in a shorter way.

Parameters of a node can either be attribute values in a parent node (which may contain childs, but doesn't have to), or as sub-nodes of the parent. In this case, either the the classic style can be used (<key>value</key>) or one of the two new styles (<key value="value"/> or <param name="key" value="value"/>). To keep things backward compatible, a parameter with the key "extend" is not permitted in parent node attributes.
{zone-data}

{zone-data:milestones}
* Milestone 1: [DONE] Proposal finished
* Milestone 2: [DONE] Working prototype checked into http://zend.svn.dasprids.de
* Milestone 3: [DONE] Unit tests exist, work, and are checked into http://zend.svn.dasprids.de
* Milestone 4: [DONE] Proposal confirmation
* Milestone 5: [DONE] Initial documentation exists.
* Milestone 6: [DONE] Everything checked into incubator
{zone-data}

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

{zone-data:use-cases}
The following examples will all result in the same data structure

||UC-01||
Classic XML layout

{code}
<database>
<adapter>pdo_mysql</adapter>
<params>
<host>localhost</host>
<username></username>
<password></password>
<dbname></dbname>
</params>
</database>
{code}

||UC-02||
Parent node attributes

{code}
<database adapter="pdo_mysql">
<params>
<host>localhost</host>
<username></username>
<password></password>
<dbname></dbname>
</params>
</database>
{code}

||UC-03||
Short params (variant 1)

{code}
<database adapter="pdo_mysql">
<params>
<host value="localhost"/>
<username value=""/>
<password value=""/>
<dbname value=""/>
</params>
</database>
{code}

||UC-04||
Short params (variant 2)

{code}
<database adapter="pdo_mysql">
<params>
<param name="host" value="localhost"/>
<param name="username" value=""/>
<param name="password" value=""/>
<param name="dbname" value=""/>
</params>
</database>
{code}

||UC-05||
Short params (variant 3)

{code}
<database adapter="pdo_mysql">
<params host="localhost" username="" password="" dbname=""/>
</database>
{code}
{zone-data}

{zone-data:skeletons}
{code}
<?php
class Zend_Config_Xml extends Zend_Config
{
public function __construct($filename, $section = null, $allowModifications = false)
{}

protected function _processExtends($element, $section, $config = array())
{}

protected function _toArray($xmlObject)
{}

protected function _arrayMergeRecursive($array1, $array2)
{}
}
{code}
{zone-data}

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