- ⌂ Content
- Methods
Content::restore()
Restore a previous revision of a content item to the latest stored/saved/approved version.
Prototype
boolean restore(array $options = [])
Parameters
- options - Optional key/value pairs:
- Revision - Revision number used to identify the version to restore, which can be retrieved with get_saved_history(). This is the only required "option".
- Action - store (default), save, approve
- ThrowExceptions - FALSE (default) will log errors to the event log. TRUE will throw an exception instead.
Return
TRUE if the content item was restored in the repository. Otherwise, FALSE.
Example
$repo = \comand::repo();
$contact = $repo->get_first('FROM Contact LIMIT 1');
$history = $contact->get_saved_history();
if($history && count($history) > 1) {
// restore the previous version (second newest)
$contact->restore(['Revision' => $history[1]['_StartRevision']);
}