public static function attachClassBehavior($name, $behavior, $class = null, $priority = null)
{
if (!$class && function_exists('get_called_class')) {
$class = get_called_class();
}
if (!$class) {
throw new TInvalidOperationException('component_no_class_provided_nor_late_binding');
}
if (!is_string($name)) {
$name = get_class($name);
}
$class = strtolower($class);
if ($class === 'tcomponent') {
throw new TInvalidOperationException('component_no_tcomponent_class_behaviors');
}
if (empty(self::$_um[$class])) {
self::$_um[$class] = array();
}
if (isset(self::$_um[$class][$name])) {
throw new TInvalidOperationException('component_class_behavior_defined', $class, $name);
}
$param = new TClassBehaviorEventParameter($class, $name, $behavior, $priority);
self::$_um[$class] = array($name => $param) + self::$_um[$class];
$behaviorObject = is_string($behavior) ? new $behavior() : $behavior;
return $behaviorObject->raiseEvent('fxAttachClassBehavior', null, $param);
}