From 21df7069d0622d30d823c9ea511a2e98b47e6b06 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 10 Nov 2015 15:30:15 +1300 Subject: [PATCH] Extension hooks for "restore to stage" and "archive" --- code/model/SiteTree.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/code/model/SiteTree.php b/code/model/SiteTree.php index abe79040..c793c63c 100755 --- a/code/model/SiteTree.php +++ b/code/model/SiteTree.php @@ -2534,6 +2534,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid * @return self */ public function doRestoreToStage() { + $this->invokeWithExtensions('onBeforeRestoreToStage', $this); + // Ensure that the parent page is restored, otherwise restore to root if($this->isParentArchived()) { $this->ParentID = 0; @@ -2562,6 +2564,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } Versioned::reading_stage($oldStage); + + $this->invokeWithExtensions('onAfterRestoreToStage', $this); return $result; } @@ -2572,10 +2576,15 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid * @return bool Success */ public function doArchive() { + $this->invokeWithExtensions('onBeforeArchive', $this); + if($this->doUnpublish()) { $this->delete(); + $this->invokeWithExtensions('onAfterArchive', $this); + return true; } + return false; }