Prado\TComponent::attachClassBehavior PHP 메소드

attachClassBehavior() 공개 정적인 메소드

This registers the behavior for future instances and pushes the changes to all the instances that are listening as well. The universal class behaviors are stored in an inverted stack with the latest class behavior being at the first position in the array. This is done so class behaviors are added last first.
부터: 3.2.3
public static attachClassBehavior ( $name, $behavior, $class = null, $priority = null )
    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);
    }