From a77f444bbc8059c0bededc47a50f8fd9c05a1549 Mon Sep 17 00:00:00 2001 From: javalizard <> Date: Sun, 18 Apr 2010 01:36:04 +0000 Subject: 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 --- framework/Util/TParameterModule.php | 58 ++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 23 deletions(-) (limited to 'framework/Util') 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 * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2010 PradoSoft * @license http://www.pradosoft.com/license/ * @version $Id$ * @package System.Util @@ -24,6 +24,7 @@ * * * + * * * * @@ -33,12 +34,19 @@ * * * + * * * * + * 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 * @author Carl G. Mathisen * @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); } /** -- cgit v1.2.3