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;
}