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

loadStateRecursive() защищенный Метод

This method should only be used by framework developers.
protected loadStateRecursive ( &$state, $needViewState = true )
    protected function loadStateRecursive(&$state, $needViewState = true)
    {
        if (is_array($state)) {
            // A null state means the stateful properties all take default values.
            // So if the state is enabled, we have to assign the null value.
            $needViewState = $needViewState && !($this->_flags & self::IS_DISABLE_VIEWSTATE);
            if (isset($state[1])) {
                $this->_rf[self::RF_CONTROLSTATE] =& $state[1];
                unset($state[1]);
            } else {
                unset($this->_rf[self::RF_CONTROLSTATE]);
            }
            if ($needViewState) {
                if (isset($state[0])) {
                    $this->_viewState =& $state[0];
                } else {
                    $this->_viewState = array();
                }
            }
            unset($state[0]);
            if ($this->getHasControls()) {
                foreach ($this->_rf[self::RF_CONTROLS] as $control) {
                    if ($control instanceof TControl) {
                        if (isset($state[$control->_id])) {
                            $control->loadStateRecursive($state[$control->_id], $needViewState);
                            unset($state[$control->_id]);
                        }
                    }
                }
            }
            if (!empty($state)) {
                $this->_rf[self::RF_CHILD_STATE] =& $state;
            }
        }
        $this->_stage = self::CS_STATE_LOADED;
        if (isset($this->_rf[self::RF_ADAPTER])) {
            $this->_rf[self::RF_ADAPTER]->loadState();
        } else {
            $this->loadState();
        }
    }

Usage Example

Пример #1
0
 /**
  * Loads state (viewstate and controlstate) into a control and its children.
  * This method overrides the parent implementation by loading
  * cached state if available.
  * This method should only be used by framework developers.
  * @param array the collection of the state
  * @param boolean whether the viewstate should be loaded
  */
 protected function loadStateRecursive(&$state, $needViewState = true)
 {
     $st = unserialize($state);
     parent::loadStateRecursive($st, $needViewState);
 }
TControl