src/Extensions/UserPreviewPreference.php
public function onBeforeWrite() {
        parent::onBeforeWrite();
        
        if(empty($this->owner->DefaultPreviewMode)) {
            $this->owner->DefaultPreviewMode=Config::inst()->get('UserPreviewPreference', 'DefaultMode');
        }
        
        
        //If changed ensure their is a session message
        if($this->owner->isChanged('DefaultPreviewMode')) {
            Controller::curr()->getRequest()->getSession()->set('ShowPreviewSettingChangeReload', true);
            $this->isSaving=true;
        }
    }
public function onBeforeWrite() {
        parent::onBeforeWrite();
        
        if(empty($this->owner->DefaultPreviewMode)) {
            $this->owner->DefaultPreviewMode=Config::inst()->get('UserPreviewPreference', 'DefaultMode');
        }
        
        
        //If changed ensure their is a session message
        if($this->owner->isChanged('DefaultPreviewMode')) {
            Controller::curr()->getRequest()->getSession()->set('ShowPreviewSettingChangeReload', true);
            $this->isSaving=true;
        }
    }
public function onBeforeWrite ( ) { parent :: onBeforeWrite ( ) ; if ( empty ( $ this -> owner -> DefaultPreviewMode ) ) { $ this -> owner -> DefaultPreviewMode = Config :: inst ( ) -> get ( 'UserPreviewPreference' , 'DefaultMode' ) ; } //If changed ensure their is a session message if ( $ this -> owner -> isChanged ( 'DefaultPreviewMode' ) ) { Controller :: curr ( ) -> getRequest ( ) -> getSession ( ) -> set ( 'ShowPreviewSettingChangeReload' , true ) ; $ this -> isSaving = true ; } }
Ensures config defaults are enforced on write
Ensures config defaults are enforced on write