diff options
author | Jens Klaer <kj.landwehr.software@gmail.com> | 2015-06-01 10:07:13 +0200 |
---|---|---|
committer | Jens Klaer <kj.landwehr.software@gmail.com> | 2015-06-01 10:07:13 +0200 |
commit | 762e3a15e7c24ca12caf879aa3b31331f1d1f185 (patch) | |
tree | 0575586105c1fae3a17e67751d6041b28235a459 /framework/Web/UI | |
parent | 2ae8ccd03b5e765e983e6c8cd263304013757dfb (diff) |
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.
Diffstat (limited to 'framework/Web/UI')
-rw-r--r-- | framework/Web/UI/TTemplateManager.php | 26 |
1 files changed, 25 insertions, 1 deletions
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; + } } |