public function __call($method, $args)
{
$getset = substr($method, 0, 3);
if ($getset == 'get' || $getset == 'set') {
$propname = substr($method, 3);
$jsmethod = $getset . 'js' . $propname;
if (method_exists($this, $jsmethod)) {
if (count($args) > 0) {
if ($args[0] && !$args[0] instanceof TJavaScriptString) {
$args[0] = new TJavaScriptString($args[0]);
}
}
return call_user_func_array(array($this, $jsmethod), $args);
}
if ($getset == 'set' && method_exists($this, 'getjs' . $propname)) {
throw new TInvalidOperationException('component_property_readonly', get_class($this), $method);
}
}
if ($this->_m !== null && $this->_behaviorsenabled) {
if (strncasecmp($method, 'dy', 2) === 0) {
$callchain = new TCallChain($method);
foreach ($this->_m->toArray() as $behavior) {
if ((!$behavior instanceof IBehavior || $behavior->getEnabled()) && (method_exists($behavior, $method) || $behavior instanceof IDynamicMethods)) {
$behavior_args = $args;
if ($behavior instanceof IClassBehavior) {
array_unshift($behavior_args, $this);
}
$callchain->addCall(array($behavior, $method), $behavior_args);
}
}
if ($callchain->getCount() > 0) {
return call_user_func_array(array($callchain, 'call'), $args);
}
} else {
foreach ($this->_m->toArray() as $behavior) {
if ((!$behavior instanceof IBehavior || $behavior->getEnabled()) && method_exists($behavior, $method)) {
if ($behavior instanceof IClassBehavior) {
array_unshift($args, $this);
}
return call_user_func_array(array($behavior, $method), $args);
}
}
}
}
if (strncasecmp($method, 'dy', 2) === 0 || strncasecmp($method, 'fx', 2) === 0) {
if ($this instanceof IDynamicMethods) {
return $this->__dycall($method, $args);
}
return isset($args[0]) ? $args[0] : null;
}
// don't thrown an exception for __magicMethods() or any other weird methods natively implemented by php
if (!method_exists($this, $method)) {
throw new TApplicationException('component_method_undefined', get_class($this), $method);
}
}