Doctrine\ODM\PHPCR\UnitOfWork::restoreVersion PHP Метод

restoreVersion() публичный Метод

Restore the document to the state it was before
См. также: VersionManager::restore
public restoreVersion ( string $documentVersion, boolean $removeExisting )
$documentVersion string the version name to restore
$removeExisting boolean how to handle identifier collisions
    public function restoreVersion($documentVersion, $removeExisting)
    {
        $oid = spl_object_hash($documentVersion);
        $history = $this->documentHistory[$oid];
        $version = $this->documentVersion[$oid];
        $document = $this->dm->find(null, $history->getVersionableIdentifier());
        $vm = $this->session->getWorkspace()->getVersionManager();
        $vm->restore($removeExisting, $version);
        $this->dm->refresh($document);
    }

Usage Example

Пример #1
0
 /**
  * Restores the current checked out document to the values of the given
  * version in storage and refreshes the document object.
  *
  * Note that this does not change anything on the version history.
  *
  * The restore is immediately propagated to the backend.
  *
  * @see findVersionByName
  *
  * @param string $DocumentVersion the version to be restored
  * @param bool $removeExisting how to handle conflicts with unique
  *      identifiers. If true, existing documents with the identical
  *      identifier will be replaced, otherwise an exception is thrown.
  */
 public function restoreVersion($documentVersion, $removeExisting = true)
 {
     $this->errorIfClosed();
     $this->unitOfWork->restoreVersion($documentVersion, $removeExisting);
 }
UnitOfWork