From 762e3a15e7c24ca12caf879aa3b31331f1d1f185 Mon Sep 17 00:00:00 2001 From: Jens Klaer Date: Mon, 1 Jun 2015 10:07:13 +0200 Subject: Allow class behavior setter on templates if a class behavior is attached to a control used on a template, behavior setter could not be called since the parse method did not recognize the method. --- framework/Web/UI/TTemplateManager.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'framework/Web') diff --git a/framework/Web/UI/TTemplateManager.php b/framework/Web/UI/TTemplateManager.php index 0ffb6bec..7e1b9c84 100644 --- a/framework/Web/UI/TTemplateManager.php +++ b/framework/Web/UI/TTemplateManager.php @@ -938,7 +938,7 @@ class TTemplate extends TApplicationComponent implements ITemplate else { // a simple property - if (! ($class->hasMethod('set'.$name) || $class->hasMethod('setjs'.$name)) ) + if (! ($class->hasMethod('set'.$name) || $class->hasMethod('setjs'.$name) || $this->isClassBehaviorMethod($class,$name)) ) { if ($class->hasMethod('get'.$name) || $class->hasMethod('getjs'.$name)) throw new TConfigurationException('template_property_readonly',$type,$name); @@ -1068,5 +1068,29 @@ class TTemplate extends TApplicationComponent implements ITemplate return $input; } + + /** + * Checks if the given method belongs to a previously attached class behavior. + * @param ReflectionClass $class + * @param string $method + * @return boolean + */ + protected function isClassBehaviorMethod(ReflectionClass $class,$method) + { + $component=new ReflectionClass('TComponent'); + $behaviors=$component->getStaticProperties(); + if(!isset($behaviors['_um'])) + return false; + foreach($behaviors['_um'] as $name=>$list) + { + if(!$class->isSubclassOf($name)) continue; + foreach($list as $param) + { + if(method_exists($param->getBehavior(),'set'.$method)) + return true; + } + } + return false; + } } -- cgit v1.2.3