Extension hooks for "restore to stage" and "archive"

This commit is contained in:
Ingo Schommer 2015-11-10 15:30:15 +13:00
parent 3dbe5f278d
commit 21df7069d0

View File

@ -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;
@ -2563,6 +2565,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;
}