Prado\TComponent::attachBehavior PHP Метод

attachBehavior() публичный Метод

This method will create the behavior object based on the given configuration. After that, the behavior object will be initialized by calling its {@link IBehavior::attach} method. Already attached behaviors may implement the function: public function dyAttachBehavior($name,$behavior[, $chain]) { } to be executed when attachBehavior is called. All attached behaviors are notified through dyAttachBehavior.
С версии: 3.2.3
public attachBehavior ( $name, $behavior, $priority = null ) : Prado\Util\IBehavior
Результат Prado\Util\IBehavior the behavior object
    public function attachBehavior($name, $behavior, $priority = null)
    {
        if (is_string($behavior)) {
            $behavior = Prado::createComponent($behavior);
        }
        if (!$behavior instanceof IBaseBehavior) {
            throw new TInvalidDataTypeException('component_not_a_behavior', get_class($behavior));
        }
        if ($behavior instanceof IBehavior) {
            $behavior->setEnabled(true);
        }
        if ($this->_m === null) {
            $this->_m = new TPriorityMap();
        }
        $behavior->attach($this);
        $this->dyAttachBehavior($name, $behavior);
        $this->_m->add($name, $behavior, $priority);
        return $behavior;
    }