summaryrefslogtreecommitdiff
path: root/framework/Util/TParameterModule.php
diff options
context:
space:
mode:
authorctrlaltca@gmail.com <>2011-06-20 10:48:45 +0000
committerctrlaltca@gmail.com <>2011-06-20 10:48:45 +0000
commit656c339879a071f2f875831281ed833b876e4361 (patch)
treeb6f11d3ad8cb1f61b10b4e3b9fcb0a7d4d30f9e1 /framework/Util/TParameterModule.php
parent0956370d34e2eefd0b5e556a6aaca6297ce1e3ce (diff)
removed useless calls to empty contructor; reverted some additional undocumented changes; upported the "cgi workaround" to trunk/; large (fake) changeset are due to mixed cr/crlf used previously
Diffstat (limited to 'framework/Util/TParameterModule.php')
-rw-r--r--framework/Util/TParameterModule.php58
1 files changed, 23 insertions, 35 deletions
diff --git a/framework/Util/TParameterModule.php b/framework/Util/TParameterModule.php
index 265bdd38..0109ca32 100644
--- a/framework/Util/TParameterModule.php
+++ b/framework/Util/TParameterModule.php
@@ -4,7 +4,7 @@
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2010 PradoSoft
+ * @copyright Copyright &copy; 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Util
@@ -24,7 +24,6 @@
* <parameters>
* <parameter id="param1" value="paramValue1" />
* <parameter id="param2" Property1="Value1" Property2="Value2" ... />
- * <parameter id="param3" value="cannot be changed" final="true" />
* </parameters>
* </code>
*
@@ -34,19 +33,12 @@
* <module class="System.Util.TParameterModule">
* <parameter id="param1" value="paramValue1" />
* <parameter id="param2" Property1="Value1" Property2="Value2" ... />
- * <parameter id="param3" value="cannot be changed" final="true" />
* </module>
* </code>
*
- * Setting the final attribute to true will cause that parameter to be unchangable
- * by any future mergeParameters.
- *
* If a parameter is defined both in the external file and within the module
* tag, the former takes precedence.
*
- * the application parameters are processed first before the modules parameters
- * are processed.
- *
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Carl G. Mathisen <carlgmathisen@gmail.com>
* @version $Id$
@@ -101,7 +93,7 @@ class TParameterModule extends TModule
/**
* Loads parameters into application.
- * @param mixed XML or PHP representation of the parameters
+ * @param mixed XML of PHP representation of the parameters
* @throws TConfigurationException if the parameter file format is invalid
*/
protected function loadParameters($config)
@@ -111,23 +103,10 @@ class TParameterModule extends TModule
{
foreach($config as $id => $parameter)
{
- if(is_array($parameter))
+ if(is_array($parameter) && isset($parameter['class']))
{
- $final = TPropertyValue::ensureBoolean($parameter['final']);
- unset($parameter['final']);
- if(isset($parameter['class']))
- {
- $properties = isset($parameter['properties']) ? $parameter['properties'] : array();
- $properties['id'] = $id;
- $parameters[$id] = array('type'=>0, 'class' => $parameter['class'], 'properties' => $properties,
- 'final' => $final, 'value' => $parameter);
- } else {
- if(!isset($parameter['value'])) {
- $parameters[$id]=array('type'=>1, 'value' => $parameter, 'final' => $final);
- } else {
- $parameters[$id]=array('type'=>2, 'value' => $value, 'final' => $final);
- }
- }
+ $properties = isset($parameter['properties'])?$parameter['properties']:array();
+ $parameters[$id]=array($parameter['class'],$properties);
}
else
{
@@ -142,22 +121,31 @@ class TParameterModule extends TModule
$properties=$node->getAttributes();
if(($id=$properties->remove('id'))===null)
throw new TConfigurationException('parametermodule_parameterid_required');
- $final = TPropertyValue::ensureBoolean($properties->remove('final'));
if(($type=$properties->remove('class'))===null)
{
if(($value=$properties->remove('value'))===null)
- $parameters[$id]=array('type'=>1, 'value' => $node, 'final' => $final);
+ $parameters[$id]=$node;
else
- $parameters[$id]=array('type'=>2, 'value' => $value, 'final' => $final);
- }
- else {
- $parameters[$id]=array('type'=>0, 'class' => $type, 'properties' => $properties->toArray(),
- 'final' => $final, 'value' => $node);
+ $parameters[$id]=$value;
}
+ else
+ $parameters[$id]=array($type,$properties->toArray());
+ }
+ }
+
+ $appParams=$this->getApplication()->getParameters();
+ foreach($parameters as $id=>$parameter)
+ {
+ if(is_array($parameter))
+ {
+ $component=Prado::createComponent($parameter[0]);
+ foreach($parameter[1] as $name=>$value)
+ $component->setSubProperty($name,$value);
+ $appParams->add($id,$component);
}
+ else
+ $appParams->add($id,$parameter);
}
-
- $this->getApplication()->mergeParameters($parameters);
}
/**