zanderwar
zanderwar

Reputation: 3730

How to get the page that was unpublished in onAfterUnpublish()

As per title, I am trying to figure out how I can obtain the URLSegment for the Page that was Unpublished.

Also need to do the same for when a Page was saved as draft

Though these extension points don't provide any variables like they do on say onAfterPublish() and onBeforePublish()

Upvotes: 1

Views: 94

Answers (1)

3dgoo
3dgoo

Reputation: 15794

In our onAfterUnpublish function we can access any of the page variables by calling $this->owner. Here is how to retrieve the page URLSegment:

class CustomSiteTree extends SiteTreeExtension {

    public function onAfterUnpublish() {
        $this->owner->URLSegment;
    }

}

Upvotes: 2

Related Questions