summaryrefslogtreecommitdiff
path: root/framework/Util
diff options
context:
space:
mode:
authorjavalizard <>2010-04-18 01:36:04 +0000
committerjavalizard <>2010-04-18 01:36:04 +0000
commita77f444bbc8059c0bededc47a50f8fd9c05a1549 (patch)
tree5ce41a7988c75fdaedf7da97ef20945d0ea86785 /framework/Util
parent98c48b76b2fdf4b99c9fad1631e52d027b965be4 (diff)
TComponent- adds a blank __construct function to unify the constructor call path for all objects.
TApplication- Adds final attribute to the parameters in the config so folder config.xml cannot override if set to true. Adds a mergeParameter function to unify parameter setting. Fixed a bug where loadParametersPhp wasn't getting the properties correctly. TControl- calls the parent::__construct, Adds render blocking. (the PRADO class using this will be added in a week or two) TParameterModule- Adds final attribute to the parameter option so folder configs cannot override if set to true. Uses the application mergeParameter function. Adds final to the php parameter loader
Diffstat (limited to 'framework/Util')
-rw-r--r--framework/Util/TParameterModule.php58
1 files changed, 35 insertions, 23 deletions
diff --git a/framework/Util/TParameterModule.php b/framework/Util/TParameterModule.php
index 0109ca32..265bdd38 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-2008 PradoSoft
+ * @copyright Copyright &copy; 2005-2010 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Util
@@ -24,6 +24,7 @@
* <parameters>
* <parameter id="param1" value="paramValue1" />
* <parameter id="param2" Property1="Value1" Property2="Value2" ... />
+ * <parameter id="param3" value="cannot be changed" final="true" />
* </parameters>
* </code>
*
@@ -33,12 +34,19 @@
* <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$
@@ -93,7 +101,7 @@ class TParameterModule extends TModule
/**
* Loads parameters into application.
- * @param mixed XML of PHP representation of the parameters
+ * @param mixed XML or PHP representation of the parameters
* @throws TConfigurationException if the parameter file format is invalid
*/
protected function loadParameters($config)
@@ -103,10 +111,23 @@ class TParameterModule extends TModule
{
foreach($config as $id => $parameter)
{
- if(is_array($parameter) && isset($parameter['class']))
+ if(is_array($parameter))
{
- $properties = isset($parameter['properties'])?$parameter['properties']:array();
- $parameters[$id]=array($parameter['class'],$properties);
+ $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);
+ }
+ }
}
else
{
@@ -121,31 +142,22 @@ 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]=$node;
+ $parameters[$id]=array('type'=>1, 'value' => $node, 'final' => $final);
else
- $parameters[$id]=$value;
+ $parameters[$id]=array('type'=>2, 'value' => $value, 'final' => $final);
+ }
+ else {
+ $parameters[$id]=array('type'=>0, 'class' => $type, 'properties' => $properties->toArray(),
+ 'final' => $final, 'value' => $node);
}
- 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);
}
/**