Restore a page version to be the live version
Note that the restored page is saved to the database, replacing the current live version. So consider whether you should backup the live version (by using addPageVersion) before restoring a version to it.
Example
// restore version 2 to live page
$page = $pages->get(1234);
$pagesVersions->restore($page, 2); // restore version 2
// this does the same as the above
$pageV2 = $pagesVersions->getPageVersion($page, 2);
$pagesVersions->restore($pageV2);
Usage
// basic usage
$page = $pagesVersions->restorePageVersion(Page $page);
// usage with all arguments
$page = $pagesVersions->restorePageVersion(Page $page, int $version = 0, array $options = []);
Arguments
Name | Type(s) | Description |
---|---|---|
page | Page | Page to restore version to or a page that was loaded as a version. |
version (optional) | int | Version number to restore. Can be omitted if given $page is already a version. |
options (optional) | array |
|
Return value
Exceptions
Method can throw exceptions on error:
WireException
$pagesVersions methods and properties
API reference based on ProcessWire core version 3.0.236