本文整理匯總了PHP中Doctrine\ODM\PHPCR\DocumentManager::detach方法的典型用法代碼示例。如果您正苦於以下問題:PHP DocumentManager::detach方法的具體用法?PHP DocumentManager::detach怎麽用?PHP DocumentManager::detach使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine\ODM\PHPCR\DocumentManager
的用法示例。
在下文中一共展示了DocumentManager::detach方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: findVersionByName
/**
* @see DocumentManager::findVersionByName
*/
public function findVersionByName($className, $id, $versionName)
{
$versionManager = $this->session->getWorkspace()->getVersionManager();
try {
$history = $versionManager->getVersionHistory($id);
} catch (ItemNotFoundException $e) {
// there is no document with $id
return null;
} catch (UnsupportedRepositoryOperationException $e) {
throw new InvalidArgumentException("Document with id {$id} is not versionable", $e->getCode(), $e);
}
try {
$version = $history->getVersion($versionName);
$node = $version->getFrozenNode();
} catch (RepositoryException $e) {
throw new InvalidArgumentException("No version {$versionName} on document {$id}", $e->getCode(), $e);
}
$hints = array('versionName' => $versionName, 'ignoreHardReferenceNotFound' => true);
$frozenDocument = $this->getOrCreateDocument($className, $node, $hints);
$this->dm->detach($frozenDocument);
$oid = spl_object_hash($frozenDocument);
$this->documentHistory[$oid] = $history;
$this->documentVersion[$oid] = $version;
// Set the annotations
$metadata = $this->dm->getClassMetadata(get_class($frozenDocument));
if ($metadata->versionNameField) {
$metadata->reflFields[$metadata->versionNameField]->setValue($frozenDocument, $versionName);
}
if ($metadata->versionCreatedField) {
$metadata->reflFields[$metadata->versionCreatedField]->setValue($frozenDocument, $version->getCreated());
}
return $frozenDocument;
}
示例2: testDetachWithChildren
public function testDetachWithChildren()
{
$parent = $this->dm->find(null, '/functional');
$this->dm->detach($parent);
}