final public function save($forceSaveRegardlessOfState = false)
    {
        try {
            $this->isConsistent();
        } catch (ModelConsistencyValidationException $er) {
            // If the model isn't consistent we don't let it get into the database.
            throw $er;
        }

        if (!$forceSaveRegardlessOfState && !$this->isNewRecord() && !$this->hasChanged()) {
            return $this->uniqueIdentifier;
        }

        $this->beforeSave();
        $this->raiseEvent("BeforeSave");

        $repository = $this->getRepository();
        $repository->saveObject($this);

        $this->newRecord = false;

        $this->callAfterSaveCallbacks();

        $this->afterSave();
        $this->raiseEvent("AfterSave");

        $this->takeChangeSnapshot();

        return $this->uniqueIdentifier;
    }
final public function save($forceSaveRegardlessOfState = false)
    {
        try {
            $this->isConsistent();
        } catch (ModelConsistencyValidationException $er) {
            // If the model isn't consistent we don't let it get into the database.
            throw $er;
        }

        if (!$forceSaveRegardlessOfState && !$this->isNewRecord() && !$this->hasChanged()) {
            return $this->uniqueIdentifier;
        }

        $this->beforeSave();
        $this->raiseEvent("BeforeSave");

        $repository = $this->getRepository();
        $repository->saveObject($this);

        $this->newRecord = false;

        $this->callAfterSaveCallbacks();

        $this->afterSave();
        $this->raiseEvent("AfterSave");

        $this->takeChangeSnapshot();

        return $this->uniqueIdentifier;
    }
final public function save ( $ forceSaveRegardlessOfState = false ) { try { $ this -> isConsistent ( ) ; } catch ( ModelConsistencyValidationException $ er ) { // If the model isn't consistent we don't let it get into the database. throw $ er ; } if ( ! $ forceSaveRegardlessOfState && ! $ this -> isNewRecord ( ) && ! $ this -> hasChanged ( ) ) { return $ this -> uniqueIdentifier ; } $ this -> beforeSave ( ) ; $ this -> raiseEvent ( "BeforeSave" ) ; $ repository = $ this -> getRepository ( ) ; $ repository -> saveObject ( $ this ) ; $ this -> newRecord = false ; $ this -> callAfterSaveCallbacks ( ) ; $ this -> afterSave ( ) ; $ this -> raiseEvent ( "AfterSave" ) ; $ this -> takeChangeSnapshot ( ) ; return $ this -> uniqueIdentifier ; }
Persists the model data associated with this data object with the relevant repository.

Calls beforeSave() and afterSave() as appropriate.

@param bool $forceSaveRegardlessOfState If set, the repository save will be forced even if hasChanged() returns false
@return mixed
@throws ModelConsistencyValidationException
@throws \Rhubarb\Stem\Exceptions\ModelException
Persists the model data associated with this data object with the relevant repository .