mirror of
https://github.com/silverstripe/doc.silverstripe.org
synced 2024-10-22 15:05:50 +00:00
git-svn-id: http://svn.silverstripe.com/projects/ss2doc/branches/v2@117896 467b73ca-7a2a-4603-9d3b-597d59a354a9
874 B
874 B
Versioned
The Versioned class is a [api:DataObject]
that adds versioning and staging capabilities to the objects.
Trapping the publication event
Sometimes, you'll want to do something whenever a particular kind of page is published. This example sends an email whenever a blog entry has been published.
SilverStripe 2.3
:::php
class Page extends SiteTree {
// ...
function publish($fromStage, $toStage, $createNewVersion = false) {
mail("sam@silverstripe.com", "Blog published", "The blog has been published");
return $this->extension_instances['Versioned']->publish($fromStage, $toStage, $createNewVersion);
}
}
SilverStripe 2.4
:::php
class Page extends SiteTree {
// ...
function onAfterPublish() {
mail("sam@silverstripe.com", "Blog published", "The blog has been published");
parent::onAfterPublish();
}
}