Sprig_Core::state PHP Метод

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

Setting the model status can have side effects. Changing the state to "loaded" will merge the currently changed data with the original data. Changing to "new" will reset the original data to the default values. Setting a "deleted" state will reset the changed data. Possible model states: - new: record has not been created - deleted: record has been deleted - loaded: record has been loaded
public state ( $state = NULL ) : string
Результат string when getting
    public function state($state = NULL)
    {
        if ($state) {
            switch ($state) {
                case 'new':
                    // Reset original data
                    $this->_original = Sprig::factory($this->_model)->as_array();
                    break;
                case 'loaded':
                    // Merge the changed data into the original data
                    $this->_original = array_merge($this->_original, $this->_changed);
                    $this->_changed = array();
                    break;
                case 'deleted':
                case 'loading':
                    // Pass
                    break;
                default:
                    throw new Sprig_Exception('Unknown model state: :state', array(':state' => $state));
                    break;
            }
            // Set the new state
            $this->_state = $state;
            return $this;
        }
        return $this->_state;
    }