public function onBeforeWrite()
    {
        // Prepare blank manipulation
        $manipulations = new AssetManipulationList();

        // Mark overwritten object as deleted
        if ($this->owner->isInDB()) {
            $priorRecord = DataObject::get(get_class($this->owner))->byID($this->owner->ID);
            if ($priorRecord) {
                $this->addAssetsFromRecord($manipulations, $priorRecord, AssetManipulationList::STATE_DELETED);
            }
        }

        // Add assets from new record with the correct visibility rules
        $state = $this->getRecordState($this->owner);
        $this->addAssetsFromRecord($manipulations, $this->owner, $state);

        // Whitelist assets that exist in other stages
        $this->addAssetsFromOtherStages($manipulations);

        // Apply visibility rules based on the final manipulation
        $this->processManipulation($manipulations);
    }
public function onBeforeWrite()
    {
        // Prepare blank manipulation
        $manipulations = new AssetManipulationList();

        // Mark overwritten object as deleted
        if ($this->owner->isInDB()) {
            $priorRecord = DataObject::get(get_class($this->owner))->byID($this->owner->ID);
            if ($priorRecord) {
                $this->addAssetsFromRecord($manipulations, $priorRecord, AssetManipulationList::STATE_DELETED);
            }
        }

        // Add assets from new record with the correct visibility rules
        $state = $this->getRecordState($this->owner);
        $this->addAssetsFromRecord($manipulations, $this->owner, $state);

        // Whitelist assets that exist in other stages
        $this->addAssetsFromOtherStages($manipulations);

        // Apply visibility rules based on the final manipulation
        $this->processManipulation($manipulations);
    }
public function onBeforeWrite ( ) { // Prepare blank manipulation $ manipulations = new AssetManipulationList ( ) ; // Mark overwritten object as deleted if ( $ this -> owner -> isInDB ( ) ) { $ priorRecord = DataObject :: get ( get_class ( $ this -> owner ) ) -> byID ( $ this -> owner -> ID ) ; if ( $ priorRecord ) { $ this -> addAssetsFromRecord ( $ manipulations , $ priorRecord , AssetManipulationList :: STATE_DELETED ) ; } } // Add assets from new record with the correct visibility rules $ state = $ this -> getRecordState ( $ this -> owner ) ; $ this -> addAssetsFromRecord ( $ manipulations , $ this -> owner , $ state ) ; // Whitelist assets that exist in other stages $ this -> addAssetsFromOtherStages ( $ manipulations ) ; // Apply visibility rules based on the final manipulation $ this -> processManipulation ( $ manipulations ) ; }
Ensure that changes to records flush overwritten files, and update the visibility
of other assets.
Ensure that changes to records flush overwritten files and update the visibility of other assets .