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

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

This method should only be used by framework developers.
protected saveStateRecursive ( $needViewState = true ) : array
Результат array the collection of the control state (including its children's state).
    protected function &saveStateRecursive($needViewState = true)
    {
        if (isset($this->_rf[self::RF_ADAPTER])) {
            $this->_rf[self::RF_ADAPTER]->saveState();
        } else {
            $this->saveState();
        }
        $needViewState = $needViewState && !($this->_flags & self::IS_DISABLE_VIEWSTATE);
        $state = array();
        if ($this->getHasControls()) {
            foreach ($this->_rf[self::RF_CONTROLS] as $control) {
                if ($control instanceof TControl) {
                    if (count($tmp =& $control->saveStateRecursive($needViewState))) {
                        $state[$control->_id] = $tmp;
                    }
                }
            }
        }
        if ($needViewState && !empty($this->_viewState)) {
            $state[0] =& $this->_viewState;
        }
        if (isset($this->_rf[self::RF_CONTROLSTATE])) {
            $state[1] =& $this->_rf[self::RF_CONTROLSTATE];
        }
        return $state;
    }

Usage Example

Пример #1
0
 /**
  * Saves all control state (viewstate and controlstate) as a collection.
  * This method overrides the parent implementation by saving state
  * into cache if needed.
  * This method should only be used by framework developers.
  * @param boolean whether the viewstate should be saved
  * @return array the collection of the control state (including its children's state).
  */
 protected function &saveStateRecursive($needViewState = true)
 {
     if ($this->_dataCached) {
         return $this->_state;
     } else {
         $st = parent::saveStateRecursive($needViewState);
         // serialization is needed to avoid undefined classes when loading state
         $this->_state = serialize($st);
         return $this->_state;
     }
 }
TControl