public copyPageVersion ( $pageVersionId, $name ) : PageVersion | ||
$pageVersionId | ||
$name | ||
return | PageVersion |
public function copyPageVersion($pageVersionId, $name)
{
// get the old page version we are currently working with
$oldVersion = $this->PageVersion->findOrFail($pageVersionId);
// create a new page version
$newVersion = $this->createNewPageVersion($oldVersion->page_id, $name, $this->UserHelper->currentUserId());
// copy all existing fields from oldVersion to newVersion
$this->copyFieldsFromVersionToVersion($oldVersion, $newVersion);
// copy all existing collections from oldVersion to newVersion
$this->copyCollectionsFromVersionToVersion($oldVersion, $newVersion);
// return the new page version we just created
return $newVersion;
}
/** * Request page version be stored * * @param array $input * @return PageVersion */ public function requestStorePageVersion($input) { return $this->PageVersionManager->copyPageVersion($input['page_version_id'], $input['name']); }