src/Versioned.php
public function doUnpublish()
    {
        $owner = $this->owner;
        // Skip if this record isn't saved
        if (!$owner->isInDB()) {
            return false;
        }

        // Skip if this record isn't on live
        if (!$owner->isPublished()) {
            return false;
        }

        $owner->invokeWithExtensions('onBeforeUnpublish');

        // Modify in isolated mode
        static::withVersionedMode(function () use ($owner) {
            static::set_stage(static::LIVE);

            // This way our ID won't be unset
            $clone = clone $owner;
            $clone->delete();
        });

        $owner->invokeWithExtensions('onAfterUnpublish');
        return true;
    }
public function doUnpublish()
    {
        $owner = $this->owner;
        // Skip if this record isn't saved
        if (!$owner->isInDB()) {
            return false;
        }

        // Skip if this record isn't on live
        if (!$owner->isPublished()) {
            return false;
        }

        $owner->invokeWithExtensions('onBeforeUnpublish');

        // Modify in isolated mode
        static::withVersionedMode(function () use ($owner) {
            static::set_stage(static::LIVE);

            // This way our ID won't be unset
            $clone = clone $owner;
            $clone->delete();
        });

        $owner->invokeWithExtensions('onAfterUnpublish');
        return true;
    }
public function doUnpublish ( ) { $ owner = $ this -> owner ; // Skip if this record isn't saved if ( ! $ owner -> isInDB ( ) ) { return false ; } // Skip if this record isn't on live if ( ! $ owner -> isPublished ( ) ) { return false ; } $ owner -> invokeWithExtensions ( 'onBeforeUnpublish' ) ; // Modify in isolated mode static :: withVersionedMode ( function ( ) use ( $ owner ) { static :: set_stage ( static :: LIVE ) ; // This way our ID won't be unset $ clone = clone $ owner ; $ clone -> delete ( ) ; } ) ; $ owner -> invokeWithExtensions ( 'onAfterUnpublish' ) ; return true ; }
Removes this record from the live site

User code should call {@see canUnpublish()} prior to invoking this method.

@return bool Flag whether the unpublish was successful
Removes this record from the live site