Prado\Web\UI\TControl::addedControl PHP Метод

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

Control lifecycles will be caught up during the addition. Only framework developers should use this method.
public addedControl ( $control )
    public function addedControl($control)
    {
        if ($control->_parent) {
            $control->_parent->getControls()->remove($control);
        }
        $control->_parent = $this;
        $control->_page = $this->getPage();
        $namingContainer = $this instanceof INamingContainer ? $this : $this->_namingContainer;
        if ($namingContainer) {
            $control->_namingContainer = $namingContainer;
            if ($control->_id === '') {
                $control->generateAutomaticID();
            } else {
                $namingContainer->clearNameTable();
            }
            $control->clearCachedUniqueID($control instanceof INamingContainer);
        }
        if ($this->_stage >= self::CS_CHILD_INITIALIZED) {
            $control->initRecursive($namingContainer);
            if ($this->_stage >= self::CS_STATE_LOADED) {
                if (isset($this->_rf[self::RF_CHILD_STATE][$control->_id])) {
                    $state = $this->_rf[self::RF_CHILD_STATE][$control->_id];
                    unset($this->_rf[self::RF_CHILD_STATE][$control->_id]);
                } else {
                    $state = null;
                }
                $control->loadStateRecursive($state, !($this->_flags & self::IS_DISABLE_VIEWSTATE));
                if ($this->_stage >= self::CS_LOADED) {
                    $control->loadRecursive();
                    if ($this->_stage >= self::CS_PRERENDERED) {
                        $control->preRenderRecursive();
                    }
                }
            }
        }
    }

Usage Example

Пример #1
0
 /**
  * Inserts an item at the specified position.
  * This overrides the parent implementation by performing additional
  * operations for each newly added child control.
  * @param integer the speicified position.
  * @param mixed new item
  * @throws TInvalidDataTypeException if the item to be inserted is neither a string nor a TControl.
  */
 public function insertAt($index, $item)
 {
     if ($item instanceof TControl) {
         parent::insertAt($index, $item);
         $this->_o->addedControl($item);
     } else {
         if (is_string($item) || $item instanceof IRenderable) {
             parent::insertAt($index, $item);
         } else {
             throw new TInvalidDataTypeException('controlcollection_control_required');
         }
     }
 }
TControl